]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: meson: axg-tdm-formatter: Use guard() for mutex locks
authorbui duc phuc <phucduc.bui@gmail.com>
Wed, 10 Jun 2026 10:21:53 +0000 (17:21 +0700)
committerMark Brown <broonie@kernel.org>
Thu, 11 Jun 2026 19:42:38 +0000 (20:42 +0100)
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>
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://patch.msgid.link/20260610102153.83367-1-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/meson/axg-tdm-formatter.c

index f451e4dce442db94ff44d1bf1fd3cb3720216e82..a6ba401104d522d6cac3d8595edd3dcab98fe9a6 100644 (file)
@@ -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);