]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks
authorbui duc phuc <phucduc.bui@gmail.com>
Wed, 10 Jun 2026 10:20:16 +0000 (17:20 +0700)
committerMark Brown <broonie@kernel.org>
Thu, 11 Jun 2026 19:59:16 +0000 (20:59 +0100)
Convert the explicit mutex_lock()/mutex_unlock() pair to guard(mutex)
to simplify the locking logic and automatically release the mutex on
all exit paths.

This changes the mutex release point from immediately before dev_warn()
to automatic cleanup at scope exit. However, the affected path only emits
a warning and immediately returns -EINVAL, without any further processing.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260610102021.83273-6-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c

index de5e1deaa167d0581ad9d656fca7ecec4db0a021..b993ca2dbd7c83cd1e3dcc48cddbc4728c51820d 100644 (file)
@@ -208,7 +208,7 @@ static int mt8192_afe_gpio_adda_ch34_ul(struct device *dev, bool enable)
 int mt8192_afe_gpio_request(struct device *dev, bool enable,
                            int dai, int uplink)
 {
-       mutex_lock(&gpio_request_mutex);
+       guard(mutex)(&gpio_request_mutex);
        switch (dai) {
        case MT8192_DAI_ADDA:
                if (uplink)
@@ -296,11 +296,9 @@ int mt8192_afe_gpio_request(struct device *dev, bool enable,
                }
                break;
        default:
-               mutex_unlock(&gpio_request_mutex);
                dev_warn(dev, "%s(), invalid dai %d\n", __func__, dai);
                return -EINVAL;
        }
-       mutex_unlock(&gpio_request_mutex);
 
        return 0;
 }