Skip to contentSkip to conversation

ASoC: ux500: Use guard() for mutex locks

PATCH In review [email protected] 2 participants 2 messages Apr 29 – May 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: ux500: Use guard() for mutex locks

From: bui duc phuc <[email protected]>

Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.

---
 sound/soc/ux500/mop500_ab8500.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
sound/soc/ux500/mop500_ab8500.c +11 -13
index 2e6ed19a18cd..2a459267f0f9 100644
@@ -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;
 }
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 1 line · On Wed, 29 Apr 2026 14:52:21 +0700, [email protected] wrote:

ASoC: ux500: Use guard() for mutex locks

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/1] ASoC: ux500: Use guard() for mutex locks
https://git.kernel.org/broonie/sound/c/fca2abdf1dd7

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark