From 49204ed803502f13f63ec515144ad656b3381d38 Mon Sep 17 00:00:00 2001 From: bui duc phuc Date: Wed, 8 Jul 2026 19:49:47 +0700 Subject: [PATCH] ASoC: codecs: aw88399: Use guard() for mutex locks Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Reviewed-by: Cezary Rojewski Signed-off-by: bui duc phuc Link: https://patch.msgid.link/20260708125002.202515-11-phucduc.bui@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/aw88399.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/aw88399.c b/sound/soc/codecs/aw88399.c index b2ec3503f7e2..67ea073abdb7 100644 --- a/sound/soc/codecs/aw88399.c +++ b/sound/soc/codecs/aw88399.c @@ -7,6 +7,7 @@ // Author: Weidong Wang // +#include #include #include #include @@ -1140,9 +1141,8 @@ static void aw88399_startup_work(struct work_struct *work) struct aw88399 *aw88399 = container_of(work, struct aw88399, start_work.work); - mutex_lock(&aw88399->lock); + guard(mutex)(&aw88399->lock); aw88399_start_pa(aw88399); - mutex_unlock(&aw88399->lock); } static void aw88399_start(struct aw88399 *aw88399, bool sync_start) @@ -1702,11 +1702,10 @@ static int aw88399_profile_set(struct snd_kcontrol *kcontrol, struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); int ret; - mutex_lock(&aw88399->lock); + guard(mutex)(&aw88399->lock); ret = aw88399_dev_set_profile_index(aw88399->aw_pa, ucontrol->value.integer.value[0]); if (ret) { dev_dbg(codec->dev, "profile index does not change"); - mutex_unlock(&aw88399->lock); return 0; } @@ -1715,8 +1714,6 @@ static int aw88399_profile_set(struct snd_kcontrol *kcontrol, aw88399_start(aw88399, AW88399_SYNC_START); } - mutex_unlock(&aw88399->lock); - return 1; } @@ -1939,12 +1936,11 @@ static int aw88399_request_firmware_file(struct aw88399 *aw88399) return ret; } - mutex_lock(&aw88399->lock); + guard(mutex)(&aw88399->lock); /* aw device init */ ret = aw88399_dev_init(aw88399, aw88399->aw_cfg); if (ret) dev_err(aw88399->aw_pa->dev, "dev init failed"); - mutex_unlock(&aw88399->lock); return ret; } @@ -1975,7 +1971,7 @@ static int aw88399_playback_event(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(component); - mutex_lock(&aw88399->lock); + guard(mutex)(&aw88399->lock); switch (event) { case SND_SOC_DAPM_PRE_PMU: aw88399_start(aw88399, AW88399_ASYNC_START); @@ -1986,7 +1982,6 @@ static int aw88399_playback_event(struct snd_soc_dapm_widget *w, default: break; } - mutex_unlock(&aw88399->lock); return 0; }