ASoC: codecs: wcd938x: 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-15-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-07-31 10:06:36 +07:00 committed by Mark Brown
parent 5a66f232aa
commit 7f9f904515
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
#include <linux/cleanup.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
@ -1976,7 +1977,7 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
int req_volt, int micb_num)
{
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0;
int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en;
switch (micb_num) {
case MIC_BIAS_1:
@ -1994,7 +1995,7 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
default:
return -EINVAL;
}
mutex_lock(&wcd938x->micb_lock);
guard(mutex)(&wcd938x->micb_lock);
/*
* If requested micbias voltage is same as current micbias
* voltage, then just return. Otherwise, adjust voltage as
@ -2009,15 +2010,11 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
WCD938X_MICB_VOUT_MASK);
req_vout_ctl = wcd_get_micb_vout_ctl_val(component->dev, req_volt);
if (req_vout_ctl < 0) {
ret = -EINVAL;
goto exit;
}
if (req_vout_ctl < 0)
return -EINVAL;
if (cur_vout_ctl == req_vout_ctl) {
ret = 0;
goto exit;
}
if (cur_vout_ctl == req_vout_ctl)
return 0;
if (micb_en == WCD938X_MICB_ENABLE)
snd_soc_component_write_field(component, micb_reg,
@ -2038,9 +2035,8 @@ static int wcd938x_mbhc_micb_adjust_voltage(struct snd_soc_component *component,
*/
usleep_range(2000, 2100);
}
exit:
mutex_unlock(&wcd938x->micb_lock);
return ret;
return 0;
}
static int wcd938x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component,