From: bui duc phuc Date: Fri, 15 May 2026 11:24:55 +0000 (+0700) Subject: ASoC: stm: stm32_adfsdm: Use guard() for mutex locks X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=dabf5b45b18cb249bbe57a6aaa173e155d247f08;p=thirdparty%2Fkernel%2Flinux.git ASoC: stm: stm32_adfsdm: 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 Link: https://patch.msgid.link/20260515112458.34378-2-phucduc.bui@gmail.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index 0f6d32814c222..a585cb9fc011a 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -62,12 +62,11 @@ static void stm32_adfsdm_shutdown(struct snd_pcm_substream *substream, { struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai); - mutex_lock(&priv->lock); + guard(mutex)(&priv->lock); if (priv->iio_active) { iio_channel_stop_all_cb(priv->iio_cb); priv->iio_active = false; } - mutex_unlock(&priv->lock); } static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, @@ -76,7 +75,7 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai); int ret; - mutex_lock(&priv->lock); + guard(mutex)(&priv->lock); if (priv->iio_active) { iio_channel_stop_all_cb(priv->iio_cb); priv->iio_active = false; @@ -88,7 +87,7 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, if (ret < 0) { dev_err(dai->dev, "%s: Failed to set %d sampling rate\n", __func__, substream->runtime->rate); - goto out; + return ret; } if (!priv->iio_active) { @@ -100,9 +99,6 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, __func__, ret); } -out: - mutex_unlock(&priv->lock); - return ret; }