Re: [PATCH 20/26] ASoC: codecs: wm8903: Use guard() for mutex locks
From: Richard Fitzgerald
Date: Thu Jul 23 2026 - 06:06:54 EST
On 23/07/2026 5:53 am, phucduc.bui@xxxxxxxxx wrote:
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/codecs/wm8903.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 320d7737699d..156e1e24a388 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
+#include <linux/cleanup.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/gpio/driver.h>
@@ -458,22 +459,20 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol,
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
unsigned int deemph = ucontrol->value.integer.value[0];
- int ret = 0;
if (deemph > 1)
return -EINVAL;
- mutex_lock(&wm8903->lock);
+ guard(mutex)(&wm8903->lock);
if (wm8903->deemph != deemph) {
wm8903->deemph = deemph;
wm8903_set_deemph(component);
- ret = 1;
+ return 1;
}
- mutex_unlock(&wm8903->lock);
- return ret;
+ return 0;
}
/* ALSA can only do steps of .01dB */
Reviewed-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>