From: Jerome Brunet <jbrunet@baylibre.com>
To: phucduc.bui@gmail.com
Cc: Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks
Date: Wed, 10 Jun 2026 14:54:08 +0200 [thread overview]
Message-ID: <1j8q8mfte7.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20260610102153.83367-1-phucduc.bui@gmail.com> (phucduc bui's message of "Wed, 10 Jun 2026 17:21:53 +0700")
On mer. 10 juin 2026 at 17:21, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
>
> Clean up the code using guard() for mutex locks.
> Merely code refactoring, and no behavior change.
I suppose it is OK but it does not seem to really clean anything and
make the code easier to follow in that instance, from my perspective at
least.
If there is policy to systematically use guard() whenever
possible then OK, otherwise it seems unnecessary.
>
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
> ---
> sound/soc/meson/axg-tdm-formatter.c | 22 ++++++++--------------
> 1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c
> index f451e4dce442..a6ba401104d5 100644
> --- a/sound/soc/meson/axg-tdm-formatter.c
> +++ b/sound/soc/meson/axg-tdm-formatter.c
> @@ -157,20 +157,19 @@ static int axg_tdm_formatter_attach(struct axg_tdm_formatter *formatter)
> struct axg_tdm_stream *ts = formatter->stream;
> int ret = 0;
>
> - mutex_lock(&ts->lock);
> + guard(mutex)(&ts->lock);
>
> /* Catch up if the stream is already running when we attach */
> if (ts->ready) {
> ret = axg_tdm_formatter_enable(formatter);
> if (ret) {
> pr_err("failed to enable formatter\n");
> - goto out;
> + return ret;
> }
> }
>
> list_add_tail(&formatter->list, &ts->formatter_list);
> -out:
> - mutex_unlock(&ts->lock);
> +
> return ret;
> }
>
> @@ -178,9 +177,8 @@ static void axg_tdm_formatter_dettach(struct axg_tdm_formatter *formatter)
> {
> struct axg_tdm_stream *ts = formatter->stream;
>
> - mutex_lock(&ts->lock);
> - list_del(&formatter->list);
> - mutex_unlock(&ts->lock);
> + scoped_guard(mutex, &ts->lock)
> + list_del(&formatter->list);
>
> axg_tdm_formatter_disable(formatter);
> }
> @@ -330,7 +328,7 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts)
> struct axg_tdm_formatter *formatter;
> int ret = 0;
>
> - mutex_lock(&ts->lock);
> + guard(mutex)(&ts->lock);
> ts->ready = true;
>
> /* Start all the formatters attached to the stream */
> @@ -338,12 +336,10 @@ int axg_tdm_stream_start(struct axg_tdm_stream *ts)
> ret = axg_tdm_formatter_enable(formatter);
> if (ret) {
> pr_err("failed to start tdm stream\n");
> - goto out;
> + return ret;
> }
> }
>
> -out:
> - mutex_unlock(&ts->lock);
> return ret;
> }
> EXPORT_SYMBOL_GPL(axg_tdm_stream_start);
> @@ -352,15 +348,13 @@ void axg_tdm_stream_stop(struct axg_tdm_stream *ts)
> {
> struct axg_tdm_formatter *formatter;
>
> - mutex_lock(&ts->lock);
> + guard(mutex)(&ts->lock);
> ts->ready = false;
>
> /* Stop all the formatters attached to the stream */
> list_for_each_entry(formatter, &ts->formatter_list, list) {
> axg_tdm_formatter_disable(formatter);
> }
> -
> - mutex_unlock(&ts->lock);
> }
> EXPORT_SYMBOL_GPL(axg_tdm_stream_stop);
--
Jerome
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-06-10 12:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 10:21 phucduc.bui
2026-06-10 10:32 ` sashiko-bot
2026-06-10 13:11 ` Jerome Brunet
2026-06-10 12:54 ` Jerome Brunet [this message]
2026-06-10 15:46 ` Mark Brown
2026-06-10 16:27 ` Bui Duc Phuc
2026-06-11 8:10 ` Jerome Brunet
2026-06-12 2:36 ` Bui Duc Phuc
2026-06-11 19:42 ` 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=1j8q8mfte7.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=broonie@kernel.org \
--cc=khilman@baylibre.com \
--cc=lgirdwood@gmail.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=perex@perex.cz \
--cc=phucduc.bui@gmail.com \
--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
Powered by JetHome