mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 09:41:03 +02:00
ASoC: samsung: i2s: 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-2-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
254f49634e
commit
3d08517b5c
|
|
@ -510,14 +510,13 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
|
||||||
unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
|
unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
|
||||||
unsigned int rsrc_mask = 1 << i2s_regs->rclksrc_off;
|
unsigned int rsrc_mask = 1 << i2s_regs->rclksrc_off;
|
||||||
u32 mod, mask, val = 0;
|
u32 mod, mask, val = 0;
|
||||||
unsigned long flags;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
pm_runtime_get_sync(dai->dev);
|
pm_runtime_get_sync(dai->dev);
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock)
|
||||||
mod = readl(priv->addr + I2SMOD);
|
mod = readl(priv->addr + I2SMOD);
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
|
||||||
|
|
||||||
switch (clk_id) {
|
switch (clk_id) {
|
||||||
case SAMSUNG_I2S_OPCLK:
|
case SAMSUNG_I2S_OPCLK:
|
||||||
|
|
@ -612,11 +611,11 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock) {
|
||||||
mod = readl(priv->addr + I2SMOD);
|
mod = readl(priv->addr + I2SMOD);
|
||||||
mod = (mod & ~mask) | val;
|
mod = (mod & ~mask) | val;
|
||||||
writel(mod, priv->addr + I2SMOD);
|
writel(mod, priv->addr + I2SMOD);
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
}
|
||||||
done:
|
done:
|
||||||
pm_runtime_put(dai->dev);
|
pm_runtime_put(dai->dev);
|
||||||
|
|
||||||
|
|
@ -729,7 +728,6 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
|
||||||
struct i2s_dai *i2s = to_info(dai);
|
struct i2s_dai *i2s = to_info(dai);
|
||||||
u32 mod, mask = 0, val = 0;
|
u32 mod, mask = 0, val = 0;
|
||||||
struct clk *rclksrc;
|
struct clk *rclksrc;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
WARN_ON(!pm_runtime_active(dai->dev));
|
WARN_ON(!pm_runtime_active(dai->dev));
|
||||||
|
|
||||||
|
|
@ -801,11 +799,11 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock) {
|
||||||
mod = readl(priv->addr + I2SMOD);
|
mod = readl(priv->addr + I2SMOD);
|
||||||
mod = (mod & ~mask) | val;
|
mod = (mod & ~mask) | val;
|
||||||
writel(mod, priv->addr + I2SMOD);
|
writel(mod, priv->addr + I2SMOD);
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
}
|
||||||
|
|
||||||
snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
|
snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
|
||||||
|
|
||||||
|
|
@ -825,11 +823,10 @@ static int i2s_startup(struct snd_pcm_substream *substream,
|
||||||
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
||||||
struct i2s_dai *i2s = to_info(dai);
|
struct i2s_dai *i2s = to_info(dai);
|
||||||
struct i2s_dai *other = get_other_dai(i2s);
|
struct i2s_dai *other = get_other_dai(i2s);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
pm_runtime_get_sync(dai->dev);
|
pm_runtime_get_sync(dai->dev);
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->pcm_lock, flags);
|
guard(spinlock_irqsave)(&priv->pcm_lock);
|
||||||
|
|
||||||
i2s->mode |= DAI_OPENED;
|
i2s->mode |= DAI_OPENED;
|
||||||
|
|
||||||
|
|
@ -841,8 +838,6 @@ static int i2s_startup(struct snd_pcm_substream *substream,
|
||||||
if (!any_active(i2s) && (priv->quirks & QUIRK_NEED_RSTCLR))
|
if (!any_active(i2s) && (priv->quirks & QUIRK_NEED_RSTCLR))
|
||||||
writel(CON_RSTCLR, i2s->priv->addr + I2SCON);
|
writel(CON_RSTCLR, i2s->priv->addr + I2SCON);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&priv->pcm_lock, flags);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -852,21 +847,18 @@ static void i2s_shutdown(struct snd_pcm_substream *substream,
|
||||||
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
||||||
struct i2s_dai *i2s = to_info(dai);
|
struct i2s_dai *i2s = to_info(dai);
|
||||||
struct i2s_dai *other = get_other_dai(i2s);
|
struct i2s_dai *other = get_other_dai(i2s);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->pcm_lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->pcm_lock) {
|
||||||
|
i2s->mode &= ~DAI_OPENED;
|
||||||
|
i2s->mode &= ~DAI_MANAGER;
|
||||||
|
|
||||||
i2s->mode &= ~DAI_OPENED;
|
if (is_opened(other))
|
||||||
i2s->mode &= ~DAI_MANAGER;
|
other->mode |= DAI_MANAGER;
|
||||||
|
|
||||||
if (is_opened(other))
|
/* Reset any constraint on RFS and BFS */
|
||||||
other->mode |= DAI_MANAGER;
|
i2s->rfs = 0;
|
||||||
|
i2s->bfs = 0;
|
||||||
/* Reset any constraint on RFS and BFS */
|
}
|
||||||
i2s->rfs = 0;
|
|
||||||
i2s->bfs = 0;
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&priv->pcm_lock, flags);
|
|
||||||
|
|
||||||
pm_runtime_put(dai->dev);
|
pm_runtime_put(dai->dev);
|
||||||
}
|
}
|
||||||
|
|
@ -939,7 +931,6 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
|
||||||
int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
|
int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
|
||||||
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
||||||
struct i2s_dai *i2s = to_info(snd_soc_rtd_to_cpu(rtd, 0));
|
struct i2s_dai *i2s = to_info(snd_soc_rtd_to_cpu(rtd, 0));
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
|
@ -950,37 +941,31 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
|
||||||
if (priv->fixup_early)
|
if (priv->fixup_early)
|
||||||
priv->fixup_early(substream, dai);
|
priv->fixup_early(substream, dai);
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock) {
|
||||||
|
if (config_setup(i2s))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (config_setup(i2s)) {
|
if (priv->fixup_late)
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
priv->fixup_late(substream, dai);
|
||||||
return -EINVAL;
|
|
||||||
|
if (capture)
|
||||||
|
i2s_rxctrl(i2s, 1);
|
||||||
|
else
|
||||||
|
i2s_txctrl(i2s, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->fixup_late)
|
|
||||||
priv->fixup_late(substream, dai);
|
|
||||||
|
|
||||||
if (capture)
|
|
||||||
i2s_rxctrl(i2s, 1);
|
|
||||||
else
|
|
||||||
i2s_txctrl(i2s, 1);
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
|
||||||
break;
|
break;
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock) {
|
||||||
|
if (capture) {
|
||||||
if (capture) {
|
i2s_rxctrl(i2s, 0);
|
||||||
i2s_rxctrl(i2s, 0);
|
i2s_fifo(i2s, FIC_RXFLUSH);
|
||||||
i2s_fifo(i2s, FIC_RXFLUSH);
|
} else {
|
||||||
} else {
|
i2s_txctrl(i2s, 0);
|
||||||
i2s_txctrl(i2s, 0);
|
i2s_fifo(i2s, FIC_TXFLUSH);
|
||||||
i2s_fifo(i2s, FIC_TXFLUSH);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
|
||||||
pm_runtime_put(dai->dev);
|
pm_runtime_put(dai->dev);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1056,7 +1041,6 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
|
||||||
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
||||||
struct i2s_dai *i2s = to_info(dai);
|
struct i2s_dai *i2s = to_info(dai);
|
||||||
struct i2s_dai *other = get_other_dai(i2s);
|
struct i2s_dai *other = get_other_dai(i2s);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
pm_runtime_get_sync(dai->dev);
|
pm_runtime_get_sync(dai->dev);
|
||||||
|
|
||||||
|
|
@ -1079,13 +1063,13 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
|
||||||
i2s->rfs = 0;
|
i2s->rfs = 0;
|
||||||
i2s->bfs = 0;
|
i2s->bfs = 0;
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock) {
|
||||||
i2s_txctrl(i2s, 0);
|
i2s_txctrl(i2s, 0);
|
||||||
i2s_rxctrl(i2s, 0);
|
i2s_rxctrl(i2s, 0);
|
||||||
i2s_fifo(i2s, FIC_TXFLUSH);
|
i2s_fifo(i2s, FIC_TXFLUSH);
|
||||||
i2s_fifo(other, FIC_TXFLUSH);
|
i2s_fifo(other, FIC_TXFLUSH);
|
||||||
i2s_fifo(i2s, FIC_RXFLUSH);
|
i2s_fifo(i2s, FIC_RXFLUSH);
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
}
|
||||||
|
|
||||||
/* Gate CDCLK by default */
|
/* Gate CDCLK by default */
|
||||||
if (!is_opened(other))
|
if (!is_opened(other))
|
||||||
|
|
@ -1100,15 +1084,13 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
struct samsung_i2s_priv *priv = snd_soc_dai_get_drvdata(dai);
|
||||||
struct i2s_dai *i2s = to_info(dai);
|
struct i2s_dai *i2s = to_info(dai);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
pm_runtime_get_sync(dai->dev);
|
pm_runtime_get_sync(dai->dev);
|
||||||
|
|
||||||
if (!is_secondary(i2s)) {
|
if (!is_secondary(i2s)) {
|
||||||
if (priv->quirks & QUIRK_NEED_RSTCLR) {
|
if (priv->quirks & QUIRK_NEED_RSTCLR) {
|
||||||
spin_lock_irqsave(&priv->lock, flags);
|
scoped_guard(spinlock_irqsave, &priv->lock)
|
||||||
writel(0, priv->addr + I2SCON);
|
writel(0, priv->addr + I2SCON);
|
||||||
spin_unlock_irqrestore(&priv->lock, flags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user