mirror of
https://github.com/torvalds/linux.git
synced 2026-10-09 20:09:02 +02:00
ASoC: codecs: pcm512x: 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> Link: https://patch.msgid.link/20260721102600.523199-15-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
3ec678539a
commit
b812b16661
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2014 Linaro Ltd
|
||||
*/
|
||||
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/clk.h>
|
||||
|
|
@ -399,10 +399,9 @@ static int pcm512x_digital_playback_switch_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
ucontrol->value.integer.value[0] = !(pcm512x->mute & 0x4);
|
||||
ucontrol->value.integer.value[1] = !(pcm512x->mute & 0x2);
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -414,7 +413,7 @@ static int pcm512x_digital_playback_switch_put(struct snd_kcontrol *kcontrol,
|
|||
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
|
||||
int ret, changed = 0;
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
|
||||
if ((pcm512x->mute & 0x4) == (ucontrol->value.integer.value[0] << 2)) {
|
||||
pcm512x->mute ^= 0x4;
|
||||
|
|
@ -430,13 +429,10 @@ static int pcm512x_digital_playback_switch_put(struct snd_kcontrol *kcontrol,
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to update digital mute: %d\n", ret);
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
|
@ -1465,7 +1461,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
int ret;
|
||||
unsigned int mute_det;
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
|
||||
if (mute) {
|
||||
pcm512x->mute |= 0x1;
|
||||
|
|
@ -1475,7 +1471,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to set digital mute: %d\n", ret);
|
||||
goto unlock;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_read_poll_timeout(pcm512x->regmap,
|
||||
|
|
@ -1488,7 +1484,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to update digital mute: %d\n", ret);
|
||||
goto unlock;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_read_poll_timeout(pcm512x->regmap,
|
||||
|
|
@ -1499,9 +1495,6 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
200, 10000);
|
||||
}
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user