mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-12-04 21:10:57 -06:00
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>
This commit is contained in:
@@ -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[] = {
|
||||
|
||||
Reference in New Issue
Block a user