Re: [PATCH 3/3] ASoC: atmel: mchp-pdmc: Retain Non-Runtime Controls
From: Andrei Simion
Date: Thu Sep 12 2024 - 05:55:16 EST
>> struct mchp_pdmc {
>> struct mic_map channel_mic_map[MCHP_PDMC_MAX_CHANNELS];
>> + spinlock_t busy_lock; /* lock protecting busy */
>> struct device *dev;
>> struct snd_dmaengine_dai_dma_data addr;
>> struct regmap *regmap;
>> @@ -124,6 +126,7 @@ struct mchp_pdmc {
>> int mic_no;
>> int sinc_order;
>> bool audio_filter_en;
>> + u8 busy:1;
> Can the spinlock and busy flag be replaced by an atomic variable?
I will use atomic_t variable with atomic_set and atomic_read.
I will do a test and send V2.
>> };
>>
>> static const char *const mchp_pdmc_sinc_filter_order_text[] = {
>> @@ -167,10 +170,19 @@ static int mchp_pdmc_sinc_order_put(struct snd_kcontrol *kcontrol,
>> return -EINVAL;
>>
>> val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
>> - if (val == dd->sinc_order)
>> +
>> + spin_lock(&dd->busy_lock);
>> + if (dd->busy) {
>> + spin_unlock((&dd->busy_lock));
> You can remove () around (&dd->busy_lock). Valid for the rest of occurrences.
OK. Got it!
>> + return -EBUSY;
>> + }
>> + if (val == dd->sinc_order) {
>> + spin_unlock((&dd->busy_lock));
>> return 0;
>> + }
>>
>> dd->sinc_order = val;
>> + spin_unlock((&dd->busy_lock));
>>
>> return 1;
>> }