From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>
Cc: "Martin Povišer" <povik+lin@cutebit.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
asahi@lists.linux.dev, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org,
"bui duc phuc" <phucduc.bui@gmail.com>
Subject: [PATCH] ASoC: apple: mca: Use guard() for mutex locks
Date: Thu, 23 Apr 2026 19:51:54 +0700 [thread overview]
Message-ID: <20260423125154.156257-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/apple/mca.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 39269cc7def6..492165c0e1ea 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -307,7 +307,7 @@ static bool mca_fe_clocks_in_use(struct mca_cluster *cl)
struct mca_cluster *be_cl;
int stream, i;
- mutex_lock(&mca->port_mutex);
+ guard(mutex)(&mca->port_mutex);
for (i = 0; i < mca->nclusters; i++) {
be_cl = &mca->clusters[i];
@@ -316,12 +316,10 @@ static bool mca_fe_clocks_in_use(struct mca_cluster *cl)
for_each_pcm_streams(stream) {
if (be_cl->clocks_in_use[stream]) {
- mutex_unlock(&mca->port_mutex);
return true;
}
}
}
- mutex_unlock(&mca->port_mutex);
return false;
}
@@ -765,9 +763,8 @@ static int mca_be_startup(struct snd_pcm_substream *substream,
cl->base + REG_PORT_CLOCK_SEL);
writel_relaxed(PORT_DATA_SEL_TXA(fe_cl->no),
cl->base + REG_PORT_DATA_SEL);
- mutex_lock(&mca->port_mutex);
- cl->port_driver = fe_cl->no;
- mutex_unlock(&mca->port_mutex);
+ scoped_guard(mutex, &mca->port_mutex)
+ cl->port_driver = fe_cl->no;
cl->port_started[substream->stream] = true;
return 0;
@@ -788,9 +785,8 @@ static void mca_be_shutdown(struct snd_pcm_substream *substream,
*/
writel_relaxed(0, cl->base + REG_PORT_ENABLES);
writel_relaxed(0, cl->base + REG_PORT_DATA_SEL);
- mutex_lock(&mca->port_mutex);
- cl->port_driver = -1;
- mutex_unlock(&mca->port_mutex);
+ scoped_guard(mutex, &mca->port_mutex)
+ cl->port_driver = -1;
}
}
--
2.43.0
reply other threads:[~2026-04-23 12:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260423125154.156257-1-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=asahi@lists.linux.dev \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=povik+lin@cutebit.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox