[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240912095337.41507-1-andrei.simion@microchip.com>
Date: Thu, 12 Sep 2024 12:53:38 +0300
From: Andrei Simion <andrei.simion@...rochip.com>
To: <claudiu.beznea@...on.dev>
CC: <alexandre.belloni@...tlin.com>, <alsa-devel@...a-project.org>,
<andrei.simion@...rochip.com>, <broonie@...nel.org>,
<codrin.ciubotariu@...rochip.com>, <lgirdwood@...il.com>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<linux-sound@...r.kernel.org>, <nicolas.ferre@...rochip.com>,
<perex@...ex.cz>, <tiwai@...e.com>
Subject: Re: [PATCH 3/3] ASoC: atmel: mchp-pdmc: Retain Non-Runtime Controls
>> 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;
>> }
Powered by blists - more mailing lists