summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbui duc phuc <phucduc.bui@gmail.com>2026-07-31 10:06:39 +0700
committerMark Brown <broonie@kernel.org>2026-07-31 16:30:59 +0100
commitb0515499ffdd5d72884eb780dc2cc58dd2a18ba8 (patch)
tree333d621d6651d02043b777080a9dbb3c22f7f2a9
parentc7e517ed25438f3cc572ca27fbcdb6d0dc0af04f (diff)
downloadlinux-next-b0515499ffdd5d72884eb780dc2cc58dd2a18ba8.tar.gz
linux-next-b0515499ffdd5d72884eb780dc2cc58dd2a18ba8.zip
ASoC: codecs: wm2000: Use guard() for mutex locks
Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20260731030648.8706-18-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm2000.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 9b68ee69324b..897b0acac5f3 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -23,6 +23,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/firmware.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/pm.h>
@@ -612,20 +613,15 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
unsigned int anc_active = ucontrol->value.integer.value[0];
- int ret;
if (anc_active > 1)
return -EINVAL;
- mutex_lock(&wm2000->lock);
+ guard(mutex)(&wm2000->lock);
wm2000->anc_active = anc_active;
- ret = wm2000_anc_set_mode(wm2000);
-
- mutex_unlock(&wm2000->lock);
-
- return ret;
+ return wm2000_anc_set_mode(wm2000);
}
static int wm2000_speaker_get(struct snd_kcontrol *kcontrol,
@@ -645,20 +641,15 @@ static int wm2000_speaker_put(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
unsigned int val = ucontrol->value.integer.value[0];
- int ret;
if (val > 1)
return -EINVAL;
- mutex_lock(&wm2000->lock);
+ guard(mutex)(&wm2000->lock);
wm2000->spk_ena = val;
- ret = wm2000_anc_set_mode(wm2000);
-
- mutex_unlock(&wm2000->lock);
-
- return ret;
+ return wm2000_anc_set_mode(wm2000);
}
static const struct snd_kcontrol_new wm2000_controls[] = {
@@ -676,9 +667,8 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
- int ret;
- mutex_lock(&wm2000->lock);
+ guard(mutex)(&wm2000->lock);
if (SND_SOC_DAPM_EVENT_ON(event))
wm2000->anc_eng_ena = 1;
@@ -686,11 +676,7 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
if (SND_SOC_DAPM_EVENT_OFF(event))
wm2000->anc_eng_ena = 0;
- ret = wm2000_anc_set_mode(wm2000);
-
- mutex_unlock(&wm2000->lock);
-
- return ret;
+ return wm2000_anc_set_mode(wm2000);
}
static const struct snd_soc_dapm_widget wm2000_dapm_widgets[] = {