Re: [PATCH 19/26] ASoC: codecs: wm8731: Use guard() for mutex locks

Richard Fitzgerald <[email protected]>
Newsgroups org.kernel.vger.linux-sound,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 23/07/2026 5:53 am, [email protected] wrote:
> From: bui duc phuc <[email protected]>
> 
> Clean up the code using guard() for mutex locks.
> Merely code refactoring, and no behavior change.
> 
> Signed-off-by: bui duc phuc <[email protected]>
> ---
>   sound/soc/codecs/wm8731.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
> index a2f0e2f5c407..ce87280d590d 100644
> --- a/sound/soc/codecs/wm8731.c
> +++ b/sound/soc/codecs/wm8731.c
> @@ -10,6 +10,7 @@
>    * Based on wm8753.c by Liam Girdwood
>    */
>   
> +#include <linux/cleanup.h>
>   #include <linux/module.h>
>   #include <linux/moduleparam.h>
>   #include <linux/init.h>
> @@ -110,22 +111,20 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol,
>   	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
>   	struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component);
>   	unsigned int deemph = ucontrol->value.integer.value[0];
> -	int ret = 0;
>   
>   	if (deemph > 1)
>   		return -EINVAL;
>   
> -	mutex_lock(&wm8731->lock);
> +	guard(mutex)(&wm8731->lock);
>   	if (wm8731->deemph != deemph) {
>   		wm8731->deemph = deemph;
>   
>   		wm8731_set_deemph(component);
>   
> -		ret = 1;
> +		return 1;
>   	}
> -	mutex_unlock(&wm8731->lock);
>   
> -	return ret;
> +	return 0;
>   }
>   
>   static const DECLARE_TLV_DB_SCALE(in_tlv, -3450, 150, 0);

Reviewed-by: Richard Fitzgerald <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.