[PATCH] ASoC: tegra: Use guard() for mutex locks
From: phucduc . bui
Date: Wed Apr 29 2026 - 06:29:27 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/tegra/tegra_isomgr_bw.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/sound/soc/tegra/tegra_isomgr_bw.c b/sound/soc/tegra/tegra_isomgr_bw.c
index fa979960bc09..db33acbf6c67 100644
--- a/sound/soc/tegra/tegra_isomgr_bw.c
+++ b/sound/soc/tegra/tegra_isomgr_bw.c
@@ -55,19 +55,18 @@ int tegra_isomgr_adma_setbw(struct snd_pcm_substream *substream,
sample_bytes;
}
- mutex_lock(&adma_isomgr->mutex);
-
- if (is_running) {
- if (bandwidth + adma_isomgr->current_bandwidth > adma_isomgr->max_bw)
- bandwidth = adma_isomgr->max_bw - adma_isomgr->current_bandwidth;
-
- adma_isomgr->current_bandwidth += bandwidth;
- } else {
- adma_isomgr->current_bandwidth -= adma_isomgr->bw_per_dev[type][pcm->device];
+ scoped_guard(mutex, &adma_isomgr->mutex) {
+ if (is_running) {
+ if (bandwidth + adma_isomgr->current_bandwidth > adma_isomgr->max_bw)
+ bandwidth = adma_isomgr->max_bw - adma_isomgr->current_bandwidth;
+
+ adma_isomgr->current_bandwidth += bandwidth;
+ } else {
+ adma_isomgr->current_bandwidth -=
+ adma_isomgr->bw_per_dev[type][pcm->device];
+ }
}
- mutex_unlock(&adma_isomgr->mutex);
-
adma_isomgr->bw_per_dev[type][pcm->device] = bandwidth;
dev_dbg(dev, "Setting up bandwidth to %d KBps\n", adma_isomgr->current_bandwidth);
--
2.43.0