]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: tegra: Use guard() for mutex locks
authorbui duc phuc <phucduc.bui@gmail.com>
Wed, 29 Apr 2026 10:27:43 +0000 (17:27 +0700)
committerMark Brown <broonie@kernel.org>
Mon, 4 May 2026 13:06:32 +0000 (22:06 +0900)
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260429102743.103197-1-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/tegra/tegra_isomgr_bw.c

index c0f300fb3d381bde6cf191e8985c7cc8619fd6e9..1c007f870759a7f3f2346efc1fc9359dd721aa7c 100644 (file)
@@ -56,19 +56,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);