mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
ASoC: img: Use guard() for spin locks
bui duc phuc <phucduc.bui@gmail.com> says: This series converts spinlock handling in several IMG ASoC drivers to use guard() helpers. All patches are straightforward cleanups with no functional change intended. Compile-tested only. Link: https://patch.msgid.link/20260610104524.87166-1-phucduc.bui@gmail.com
This commit is contained in:
commit
c582790397
|
|
@ -179,7 +179,7 @@ static int img_spdif_in_do_clkgen_single(struct img_spdif_in *spdif,
|
|||
unsigned int rate)
|
||||
{
|
||||
unsigned int nom, hld;
|
||||
unsigned long flags, clk_rate;
|
||||
unsigned long clk_rate;
|
||||
int ret = 0;
|
||||
u32 reg;
|
||||
|
||||
|
|
@ -196,19 +196,15 @@ static int img_spdif_in_do_clkgen_single(struct img_spdif_in *spdif,
|
|||
reg |= (hld << IMG_SPDIF_IN_CLKGEN_HLD_SHIFT) &
|
||||
IMG_SPDIF_IN_CLKGEN_HLD_MASK;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CLKGEN);
|
||||
|
||||
spdif->single_freq = rate;
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +212,7 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif,
|
|||
unsigned int multi_freqs[])
|
||||
{
|
||||
unsigned int nom, hld, rate, max_rate = 0;
|
||||
unsigned long flags, clk_rate;
|
||||
unsigned long clk_rate;
|
||||
int i, ret = 0;
|
||||
u32 reg, trk_reg, temp_regs[IMG_SPDIF_IN_NUM_ACLKGEN];
|
||||
|
||||
|
|
@ -242,12 +238,10 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif,
|
|||
temp_regs[i] = reg;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
trk_reg = spdif->trk << IMG_SPDIF_IN_ACLKGEN_TRK_SHIFT;
|
||||
|
||||
|
|
@ -262,8 +256,6 @@ static int img_spdif_in_do_clkgen_multi(struct img_spdif_in *spdif,
|
|||
spdif->multi_freqs[2] = multi_freqs[2];
|
||||
spdif->multi_freqs[3] = multi_freqs[3];
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -323,9 +315,8 @@ static int img_spdif_in_get_multi_freq(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
if (spdif->multi_freq) {
|
||||
ucontrol->value.integer.value[0] = spdif->multi_freqs[0];
|
||||
ucontrol->value.integer.value[1] = spdif->multi_freqs[1];
|
||||
|
|
@ -337,7 +328,6 @@ static int img_spdif_in_get_multi_freq(struct snd_kcontrol *kcontrol,
|
|||
ucontrol->value.integer.value[2] = 0;
|
||||
ucontrol->value.integer.value[3] = 0;
|
||||
}
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -349,7 +339,6 @@ static int img_spdif_in_set_multi_freq(struct snd_kcontrol *kcontrol,
|
|||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
unsigned int multi_freqs[IMG_SPDIF_IN_NUM_ACLKGEN];
|
||||
bool multi_freq;
|
||||
unsigned long flags;
|
||||
|
||||
if ((ucontrol->value.integer.value[0] == 0) &&
|
||||
(ucontrol->value.integer.value[1] == 0) &&
|
||||
|
|
@ -367,17 +356,13 @@ static int img_spdif_in_set_multi_freq(struct snd_kcontrol *kcontrol,
|
|||
if (multi_freq)
|
||||
return img_spdif_in_do_clkgen_multi(spdif, multi_freqs);
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spdif->multi_freq = false;
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -399,9 +384,8 @@ static int img_spdif_in_get_lock_freq(struct snd_kcontrol *kcontrol,
|
|||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
u32 reg;
|
||||
int i;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
reg = img_spdif_in_readl(spdif, IMG_SPDIF_IN_STATUS);
|
||||
if (reg & IMG_SPDIF_IN_STATUS_LOCK_MASK) {
|
||||
|
|
@ -416,8 +400,6 @@ static int img_spdif_in_get_lock_freq(struct snd_kcontrol *kcontrol,
|
|||
uc->value.integer.value[0] = 0;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -448,16 +430,13 @@ static int img_spdif_in_set_trk(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
unsigned long flags;
|
||||
int i;
|
||||
u32 reg;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spdif->trk = ucontrol->value.integer.value[0];
|
||||
|
||||
|
|
@ -474,8 +453,6 @@ static int img_spdif_in_set_trk(struct snd_kcontrol *kcontrol,
|
|||
img_spdif_in_aclkgen_writel(spdif, i);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -506,15 +483,12 @@ static int img_spdif_in_set_lock_acquire(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
unsigned long flags;
|
||||
u32 reg;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spdif->lock_acquire = ucontrol->value.integer.value[0];
|
||||
|
||||
|
|
@ -524,8 +498,6 @@ static int img_spdif_in_set_lock_acquire(struct snd_kcontrol *kcontrol,
|
|||
IMG_SPDIF_IN_CTL_LOCKHI_MASK;
|
||||
img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CTL);
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -545,15 +517,12 @@ static int img_spdif_in_set_lock_release(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
unsigned long flags;
|
||||
u32 reg;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
if (spdif->active) {
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
if (spdif->active)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
spdif->lock_release = ucontrol->value.integer.value[0];
|
||||
|
||||
|
|
@ -563,8 +532,6 @@ static int img_spdif_in_set_lock_release(struct snd_kcontrol *kcontrol,
|
|||
IMG_SPDIF_IN_CTL_LOCKLO_MASK;
|
||||
img_spdif_in_writel(spdif, reg, IMG_SPDIF_IN_CTL);
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -625,12 +592,11 @@ static struct snd_kcontrol_new img_spdif_in_controls[] = {
|
|||
static int img_spdif_in_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct img_spdif_in *spdif = snd_soc_dai_get_drvdata(dai);
|
||||
int ret = 0;
|
||||
u32 reg;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
|
|
@ -657,8 +623,6 @@ static int img_spdif_in_trigger(struct snd_pcm_substream *substream, int cmd,
|
|||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,9 +135,8 @@ static int img_spdif_out_get_status(struct snd_kcontrol *kcontrol,
|
|||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_out *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
u32 reg;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
reg = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CSL);
|
||||
ucontrol->value.iec958.status[0] = reg & 0xff;
|
||||
|
|
@ -150,8 +149,6 @@ static int img_spdif_out_get_status(struct snd_kcontrol *kcontrol,
|
|||
(reg & IMG_SPDIF_OUT_CSH_UV_CSH_MASK) >>
|
||||
IMG_SPDIF_OUT_CSH_UV_CSH_SHIFT;
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -161,14 +158,13 @@ static int img_spdif_out_set_status(struct snd_kcontrol *kcontrol,
|
|||
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
|
||||
struct img_spdif_out *spdif = snd_soc_dai_get_drvdata(cpu_dai);
|
||||
u32 reg;
|
||||
unsigned long flags;
|
||||
|
||||
reg = ((u32)ucontrol->value.iec958.status[3] << 24);
|
||||
reg |= ((u32)ucontrol->value.iec958.status[2] << 16);
|
||||
reg |= ((u32)ucontrol->value.iec958.status[1] << 8);
|
||||
reg |= (u32)ucontrol->value.iec958.status[0];
|
||||
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
guard(spinlock_irqsave)(&spdif->lock);
|
||||
|
||||
img_spdif_out_writel(spdif, reg, IMG_SPDIF_OUT_CSL);
|
||||
|
||||
|
|
@ -178,8 +174,6 @@ static int img_spdif_out_set_status(struct snd_kcontrol *kcontrol,
|
|||
IMG_SPDIF_OUT_CSH_UV_CSH_SHIFT;
|
||||
img_spdif_out_writel(spdif, reg, IMG_SPDIF_OUT_CSH_UV);
|
||||
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +199,6 @@ static int img_spdif_out_trigger(struct snd_pcm_substream *substream, int cmd,
|
|||
{
|
||||
struct img_spdif_out *spdif = snd_soc_dai_get_drvdata(dai);
|
||||
u32 reg;
|
||||
unsigned long flags;
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
|
|
@ -218,9 +211,8 @@ static int img_spdif_out_trigger(struct snd_pcm_substream *substream, int cmd,
|
|||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
spin_lock_irqsave(&spdif->lock, flags);
|
||||
img_spdif_out_reset(spdif);
|
||||
spin_unlock_irqrestore(&spdif->lock, flags);
|
||||
scoped_guard(spinlock_irqsave, &spdif->lock)
|
||||
img_spdif_out_reset(spdif);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user