[PATCH 32/78] ASoC: codecs: hdmi-codec: Use guard() for mutex locks
phucduc.bui at gmail.com
phucduc.bui at gmail.com
Wed Jun 17 03:31:49 PDT 2026
From: bui duc phuc <phucduc.bui at gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui at gmail.com>
---
sound/soc/codecs/hdmi-codec.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 13ae9e83bc21..608a0bf28887 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -452,31 +452,30 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
if (!((has_playback && tx) || (has_capture && !tx)))
return 0;
- mutex_lock(&hcp->lock);
+ guard(mutex)(&hcp->lock);
if (hcp->busy) {
dev_err(dai->dev, "Only one simultaneous stream supported!\n");
- mutex_unlock(&hcp->lock);
return -EINVAL;
}
if (hcp->hcd.ops->audio_startup) {
ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data);
if (ret)
- goto err;
+ return ret;
}
if (tx && hcp->hcd.ops->get_eld) {
ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data,
hcp->eld, sizeof(hcp->eld));
if (ret)
- goto err;
+ return ret;
snd_parse_eld(dai->dev, &hcp->eld_parsed,
hcp->eld, sizeof(hcp->eld));
ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld);
if (ret)
- goto err;
+ return ret;
/* Select chmap supported */
hdmi_codec_eld_chmap(hcp);
@@ -484,8 +483,6 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
hcp->busy = true;
-err:
- mutex_unlock(&hcp->lock);
return ret;
}
@@ -503,9 +500,8 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream,
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data);
- mutex_lock(&hcp->lock);
- hcp->busy = false;
- mutex_unlock(&hcp->lock);
+ scoped_guard(mutex, &hcp->lock)
+ hcp->busy = false;
}
static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai,
--
2.43.0
More information about the linux-arm-kernel
mailing list