mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
ASoC: samsung: spdif: 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/20260423125646.156599-6-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
02f43a0d0d
commit
922fc982af
|
|
@ -143,7 +143,6 @@ static int spdif_trigger(struct snd_pcm_substream *substream, int cmd,
|
|||
{
|
||||
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
||||
struct samsung_spdif_info *spdif = to_info(snd_soc_rtd_to_cpu(rtd, 0));
|
||||
unsigned long flags;
|
||||
|
||||
dev_dbg(spdif->dev, "Entered %s\n", __func__);
|
||||
|
||||
|
|
@ -151,16 +150,14 @@ static int spdif_trigger(struct snd_pcm_substream *substream, int cmd,
|
|||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
spdif_snd_txctrl(spdif, 1);
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
scoped_guard(spinlock_irqsave, &spdif->lock)
|
||||
spdif_snd_txctrl(spdif, 1);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
spdif_snd_txctrl(spdif, 0);
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
scoped_guard(spinlock_irqsave, &spdif->lock)
|
||||
spdif_snd_txctrl(spdif, 0);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
@ -182,7 +179,6 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
void __iomem *regs = spdif->regs;
|
||||
struct snd_dmaengine_dai_dma_data *dma_data;
|
||||
u32 con, clkcon, cstas;
|
||||
unsigned long flags;
|
||||
int i, ratio;
|
||||
|
||||
dev_dbg(spdif->dev, "Entered %s\n", __func__);
|
||||
|
|
@ -196,7 +192,7 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
snd_soc_dai_set_dma_data(snd_soc_rtd_to_cpu(rtd, 0), substream, dma_data);
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
con = readl(regs + CON) & CON_MASK;
|
||||
cstas = readl(regs + CSTAS) & CSTAS_MASK;
|
||||
|
|
@ -214,7 +210,7 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
break;
|
||||
default:
|
||||
dev_err(spdif->dev, "Unsupported data size.\n");
|
||||
goto err;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ratio = spdif->clk_rate / params_rate(params);
|
||||
|
|
@ -224,7 +220,7 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
if (i == ARRAY_SIZE(spdif_sysclk_ratios)) {
|
||||
dev_err(spdif->dev, "Invalid clock ratio %ld/%d\n",
|
||||
spdif->clk_rate, params_rate(params));
|
||||
goto err;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
con &= ~CON_MCLKDIV_MASK;
|
||||
|
|
@ -257,7 +253,7 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
default:
|
||||
dev_err(spdif->dev, "Invalid sampling rate %d\n",
|
||||
params_rate(params));
|
||||
goto err;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cstas &= ~CSTAS_CATEGORY_MASK;
|
||||
|
|
@ -268,12 +264,7 @@ static int spdif_hw_params(struct snd_pcm_substream *substream,
|
|||
writel(cstas, regs + CSTAS);
|
||||
writel(clkcon, regs + CLKCON);
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
err:
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void spdif_shutdown(struct snd_pcm_substream *substream,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user