]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: Intel: catpt: Utilize lock-guard helper
authorCezary Rojewski <cezary.rojewski@intel.com>
Wed, 3 Jun 2026 08:58:21 +0000 (10:58 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 4 Jun 2026 16:00:22 +0000 (17:00 +0100)
The lock-guard helps simplify the driver's code.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260603085827.1964796-2-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/catpt/dsp.c
sound/soc/intel/catpt/ipc.c

index 677f348909c8f1aa0cd6af3c7ffa7ab6a2b230e5..b1865d10f9957be7a30b22d861bbaf3d65d85e7f 100644 (file)
@@ -5,6 +5,7 @@
 // Author: Cezary Rojewski <cezary.rojewski@intel.com>
 //
 
+#include <linux/cleanup.h>
 #include <linux/devcoredump.h>
 #include <linux/dma-mapping.h>
 #include <linux/firmware.h>
@@ -256,17 +257,15 @@ static int catpt_dsp_select_lpclock(struct catpt_dev *cdev, bool lp, bool waiti)
        u32 mask, reg, val;
        int ret;
 
-       mutex_lock(&cdev->clk_mutex);
+       guard(mutex)(&cdev->clk_mutex);
 
        val = lp ? CATPT_CS_LPCS : 0;
        reg = catpt_readl_shim(cdev, CS1) & CATPT_CS_LPCS;
        dev_dbg(cdev->dev, "LPCS [0x%08lx] 0x%08x -> 0x%08x",
                CATPT_CS_LPCS, reg, val);
 
-       if (reg == val) {
-               mutex_unlock(&cdev->clk_mutex);
+       if (reg == val)
                return 0;
-       }
 
        if (waiti) {
                /* wait for DSP to signal WAIT state */
@@ -276,10 +275,8 @@ static int catpt_dsp_select_lpclock(struct catpt_dev *cdev, bool lp, bool waiti)
                if (ret) {
                        dev_warn(cdev->dev, "await WAITI timeout\n");
                        /* no signal - only high clock selection allowed */
-                       if (lp) {
-                               mutex_unlock(&cdev->clk_mutex);
+                       if (lp)
                                return 0;
-                       }
                }
        }
 
@@ -303,7 +300,6 @@ static int catpt_dsp_select_lpclock(struct catpt_dev *cdev, bool lp, bool waiti)
        /* update PLL accordingly */
        cdev->spec->pll_shutdown(cdev, lp);
 
-       mutex_unlock(&cdev->clk_mutex);
        return 0;
 }
 
index 225757e6a7766c71d117e43395040a071642032c..8092944d6cb7e34f7c2105e20d625ebba6866f3a 100644 (file)
@@ -128,14 +128,9 @@ int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
                               struct catpt_ipc_msg request,
                               struct catpt_ipc_msg *reply, int timeout, const char *name)
 {
-       struct catpt_ipc *ipc = &cdev->ipc;
-       int ret;
+       guard(mutex)(&cdev->ipc.mutex);
 
-       mutex_lock(&ipc->mutex);
-       ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout, name);
-       mutex_unlock(&ipc->mutex);
-
-       return ret;
+       return catpt_dsp_do_send_msg(cdev, request, reply, timeout, name);
 }
 
 int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request,