All of lore.kernel.org
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: Thierry Reding <thierry.reding@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Sheetal <sheetal@nvidia.com>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH] ASoC: tegra: Use guard() for mutex locks
Date: Wed, 29 Apr 2026 17:27:43 +0700	[thread overview]
Message-ID: <20260429102743.103197-1-phucduc.bui@gmail.com> (raw)

From: bui duc phuc <phucduc.bui@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@gmail.com>
---
 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


             reply	other threads:[~2026-04-29 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 10:27 phucduc.bui [this message]
2026-05-04 13:06 ` [PATCH] ASoC: tegra: Use guard() for mutex locks Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429102743.103197-1-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sheetal@nvidia.com \
    --cc=thierry.reding@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.