ASoC: stm: stm32_spdifrx: Use guard() for spin locks

Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260515112458.34378-5-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-05-15 18:24:58 +07:00 committed by Mark Brown
parent 5e54b4c280
commit 3f0d573c32
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -322,7 +322,6 @@ static void stm32_spdifrx_dma_ctrl_stop(struct stm32_spdifrx_data *spdifrx)
static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
{
int cr, cr_mask, imr, ret;
unsigned long flags;
/* Enable IRQs */
imr = SPDIFRX_IMR_IFEIE | SPDIFRX_IMR_SYNCDIE | SPDIFRX_IMR_PERRIE;
@ -330,7 +329,7 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
if (ret)
return ret;
spin_lock_irqsave(&spdifrx->lock, flags);
guard(spinlock_irqsave)(&spdifrx->lock);
spdifrx->refcount++;
@ -365,22 +364,17 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
"Failed to start synchronization\n");
}
spin_unlock_irqrestore(&spdifrx->lock, flags);
return ret;
}
static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx)
{
int cr, cr_mask, reg;
unsigned long flags;
spin_lock_irqsave(&spdifrx->lock, flags);
guard(spinlock_irqsave)(&spdifrx->lock);
if (--spdifrx->refcount) {
spin_unlock_irqrestore(&spdifrx->lock, flags);
if (--spdifrx->refcount)
return;
}
cr = SPDIFRX_CR_SPDIFENSET(SPDIFRX_SPDIFEN_DISABLE);
cr_mask = SPDIFRX_CR_SPDIFEN_MASK | SPDIFRX_CR_RXDMAEN;
@ -396,8 +390,6 @@ static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx)
/* dummy read to clear CSRNE and RXNE in status register */
regmap_read(spdifrx->regmap, STM32_SPDIFRX_DR, &reg);
regmap_read(spdifrx->regmap, STM32_SPDIFRX_CSR, &reg);
spin_unlock_irqrestore(&spdifrx->lock, flags);
}
static int stm32_spdifrx_dma_ctrl_register(struct device *dev,
@ -744,19 +736,19 @@ static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)
return IRQ_HANDLED;
}
spin_lock(&spdifrx->irq_lock);
if (spdifrx->substream)
snd_pcm_stop(spdifrx->substream,
SNDRV_PCM_STATE_DISCONNECTED);
spin_unlock(&spdifrx->irq_lock);
scoped_guard(spinlock, &spdifrx->irq_lock) {
if (spdifrx->substream)
snd_pcm_stop(spdifrx->substream,
SNDRV_PCM_STATE_DISCONNECTED);
}
return IRQ_HANDLED;
}
spin_lock(&spdifrx->irq_lock);
if (err_xrun && spdifrx->substream)
snd_pcm_stop_xrun(spdifrx->substream);
spin_unlock(&spdifrx->irq_lock);
scoped_guard(spinlock, &spdifrx->irq_lock) {
if (err_xrun && spdifrx->substream)
snd_pcm_stop_xrun(spdifrx->substream);
}
return IRQ_HANDLED;
}
@ -765,12 +757,10 @@ static int stm32_spdifrx_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai);
unsigned long flags;
int ret;
spin_lock_irqsave(&spdifrx->irq_lock, flags);
spdifrx->substream = substream;
spin_unlock_irqrestore(&spdifrx->irq_lock, flags);
scoped_guard(spinlock_irqsave, &spdifrx->irq_lock)
spdifrx->substream = substream;
ret = clk_prepare_enable(spdifrx->kclk);
if (ret)
@ -846,11 +836,9 @@ static void stm32_spdifrx_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai);
unsigned long flags;
spin_lock_irqsave(&spdifrx->irq_lock, flags);
spdifrx->substream = NULL;
spin_unlock_irqrestore(&spdifrx->irq_lock, flags);
scoped_guard(spinlock_irqsave, &spdifrx->irq_lock)
spdifrx->substream = NULL;
clk_disable_unprepare(spdifrx->kclk);
}