[PATCH] ASoC: ux500: Use guard() for mutex locks
From: phucduc . bui
Date: Wed Apr 29 2026 - 03:54:09 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/ux500/mop500_ab8500.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/sound/soc/ux500/mop500_ab8500.c b/sound/soc/ux500/mop500_ab8500.c
index 2e6ed19a18cd..2a459267f0f9 100644
--- a/sound/soc/ux500/mop500_ab8500.c
+++ b/sound/soc/ux500/mop500_ab8500.c
@@ -234,19 +234,18 @@ static int mop500_ab8500_hw_params(struct snd_pcm_substream *substream,
substream->number);
/* Ensure configuration consistency between DAIs */
- mutex_lock(&mop500_ab8500_params_lock);
- if (mop500_ab8500_usage) {
- if (mop500_ab8500_rate != params_rate(params) ||
- mop500_ab8500_channels != params_channels(params)) {
- mutex_unlock(&mop500_ab8500_params_lock);
- return -EBUSY;
+ scoped_guard(mutex, &mop500_ab8500_params_lock) {
+ if (mop500_ab8500_usage) {
+ if (mop500_ab8500_rate != params_rate(params) ||
+ mop500_ab8500_channels != params_channels(params)) {
+ return -EBUSY;
+ }
+ } else {
+ mop500_ab8500_rate = params_rate(params);
+ mop500_ab8500_channels = params_channels(params);
}
- } else {
- mop500_ab8500_rate = params_rate(params);
- mop500_ab8500_channels = params_channels(params);
+ __set_bit(cpu_dai->id, &mop500_ab8500_usage);
}
- __set_bit(cpu_dai->id, &mop500_ab8500_usage);
- mutex_unlock(&mop500_ab8500_params_lock);
channels = params_channels(params);
@@ -339,9 +338,8 @@ static int mop500_ab8500_hw_free(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
- mutex_lock(&mop500_ab8500_params_lock);
+ guard(mutex)(&mop500_ab8500_params_lock);
__clear_bit(cpu_dai->id, &mop500_ab8500_usage);
- mutex_unlock(&mop500_ab8500_params_lock);
return 0;
}
--
2.43.0