mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-12-04 21:00:56 -06:00
ASoC: codecs: wm5102: 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-19-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
@@ -667,10 +668,9 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct arizona *arizona = dev_get_drvdata(component->dev->parent);
|
||||
|
||||
mutex_lock(&arizona->dac_comp_lock);
|
||||
guard(mutex)(&arizona->dac_comp_lock);
|
||||
put_unaligned_be16(arizona->dac_comp_coeff,
|
||||
ucontrol->value.bytes.data);
|
||||
mutex_unlock(&arizona->dac_comp_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -681,16 +681,14 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct arizona *arizona = dev_get_drvdata(component->dev->parent);
|
||||
uint16_t dac_comp_coeff = get_unaligned_be16(ucontrol->value.bytes.data);
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&arizona->dac_comp_lock);
|
||||
guard(mutex)(&arizona->dac_comp_lock);
|
||||
if (arizona->dac_comp_coeff != dac_comp_coeff) {
|
||||
arizona->dac_comp_coeff = dac_comp_coeff;
|
||||
ret = 1;
|
||||
return 1;
|
||||
}
|
||||
mutex_unlock(&arizona->dac_comp_lock);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
|
||||
@@ -699,9 +697,8 @@ static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct arizona *arizona = dev_get_drvdata(component->dev->parent);
|
||||
|
||||
mutex_lock(&arizona->dac_comp_lock);
|
||||
guard(mutex)(&arizona->dac_comp_lock);
|
||||
ucontrol->value.integer.value[0] = arizona->dac_comp_enabled;
|
||||
mutex_unlock(&arizona->dac_comp_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -712,19 +709,17 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct arizona *arizona = dev_get_drvdata(component->dev->parent);
|
||||
struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
|
||||
int ret = 0;
|
||||
|
||||
if (ucontrol->value.integer.value[0] > mc->max)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&arizona->dac_comp_lock);
|
||||
guard(mutex)(&arizona->dac_comp_lock);
|
||||
if (arizona->dac_comp_enabled != ucontrol->value.integer.value[0]) {
|
||||
arizona->dac_comp_enabled = ucontrol->value.integer.value[0];
|
||||
ret = 1;
|
||||
return 1;
|
||||
}
|
||||
mutex_unlock(&arizona->dac_comp_lock);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const wm5102_osr_text[] = {
|
||||
|
||||
Reference in New Issue
Block a user