summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbui duc phuc <phucduc.bui@gmail.com>2026-07-31 10:06:37 +0700
committerMark Brown <broonie@kernel.org>2026-07-31 16:30:56 +0100
commit5a230b65cebec2622f6a417671bb6df0b7e82128 (patch)
tree0d6af97aa96eb9e1a7a7db4e4f48403eb909e305
parent7f9f9045153c0d74ee98406e824b3b24878f69b7 (diff)
downloadlinux-next-5a230b65cebec2622f6a417671bb6df0b7e82128.tar.gz
linux-next-5a230b65cebec2622f6a417671bb6df0b7e82128.zip
ASoC: codecs: wcd939x: Use guard() for mutex locks
Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. 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-16-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wcd939x.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 010d12466722..26fe0b6313cd 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
+#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
@@ -1923,7 +1924,6 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
unsigned int micb_reg, cur_vout_ctl, micb_en;
int req_vout_ctl;
- int ret = 0;
switch (micb_num) {
case MIC_BIAS_1:
@@ -1941,7 +1941,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
default:
return -EINVAL;
}
- mutex_lock(&wcd939x->micb_lock);
+ guard(mutex)(&wcd939x->micb_lock);
/*
* If requested micbias voltage is same as current micbias
@@ -1957,15 +1957,11 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
WCD939X_MICB_VOUT_CTL);
req_vout_ctl = wcd_get_micb_vout_ctl_val(component->dev, req_volt);
- if (req_vout_ctl < 0) {
- ret = req_vout_ctl;
- goto exit;
- }
+ if (req_vout_ctl < 0)
+ return req_vout_ctl;
- if (cur_vout_ctl == req_vout_ctl) {
- ret = 0;
- goto exit;
- }
+ if (cur_vout_ctl == req_vout_ctl)
+ return 0;
dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
__func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
@@ -1990,9 +1986,7 @@ static int wcd939x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
usleep_range(2000, 2100);
}
-exit:
- mutex_unlock(&wcd939x->micb_lock);
- return ret;
+ return 0;
}
static int wcd939x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,