Re: [PATCH 25/26] ASoC: codecs: wm_adsp: Use guard() for mutex locks
Richard Fitzgerald <[email protected]>
| Newsgroups | org.kernel.vger.linux-sound,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 23/07/2026 5:53 am, [email protected] wrote: > From: bui duc phuc <[email protected]> > > Clean up the code using guard() for mutex locks. > Merely code refactoring, and no behavior change. > > Signed-off-by: bui duc phuc <[email protected]> > --- > sound/soc/codecs/wm_adsp.c | 77 +++++++++++--------------------------- > 1 file changed, 22 insertions(+), 55 deletions(-) > > diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c > index baa75e7ff53b..cef8472dda8c 100644 > --- a/sound/soc/codecs/wm_adsp.c > +++ b/sound/soc/codecs/wm_adsp.c > @@ -348,7 +348,6 @@ int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, > struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); > struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; > struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); > - int ret = 1; > > if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) > return 0; > @@ -356,16 +355,14 @@ int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, > if (ucontrol->value.enumerated.item[0] >= WM_ADSP_NUM_FW) > return -EINVAL; > > - mutex_lock(&dsp[e->shift_l].cs_dsp.pwr_lock); > + guard(mutex)(&dsp[e->shift_l].cs_dsp.pwr_lock); > > if (dsp[e->shift_l].cs_dsp.booted || !list_empty(&dsp[e->shift_l].compr_list)) > - ret = -EBUSY; > + return -EBUSY; > else > dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; > > - mutex_unlock(&dsp[e->shift_l].cs_dsp.pwr_lock); > - > - return ret; > + return 1; > } > EXPORT_SYMBOL_GPL(wm_adsp_fw_put); > > @@ -450,15 +447,11 @@ static int wm_coeff_put_acked(struct snd_kcontrol *kctl, > if (val == 0) > return 0; /* 0 means no event */ > > - mutex_lock(&cs_ctl->dsp->pwr_lock); > - > if (cs_ctl->enabled) > ret = cs_dsp_coeff_write_acked_control(cs_ctl, val); > else > ret = -EPERM; > > - mutex_unlock(&cs_ctl->dsp->pwr_lock); > - > if (ret < 0) > return ret; This has removed the mutex lock but hasn't replaced it with a guard(mutex).