]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: pca9570: use lock guards
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 13 Jan 2026 11:10:54 +0000 (12:10 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Tue, 13 Jan 2026 14:17:35 +0000 (15:17 +0100)
Shrink the code by a couple lines and improve lock management by using
lock guards from cleanup.h.

Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20260113111156.188051-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpio-pca9570.c

index a41837f1201bd4f0ceb86087bc17908215989a7f..4a368803fb038556a188b3e763358afdf810c221 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/bits.h>
+#include <linux/cleanup.h>
 #include <linux/device/devres.h>
 #include <linux/errno.h>
 #include <linux/gpio/driver.h>
@@ -98,7 +99,7 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
        u8 buffer;
        int ret;
 
-       mutex_lock(&gpio->lock);
+       guard(mutex)(&gpio->lock);
 
        buffer = gpio->out;
        if (value)
@@ -108,13 +109,11 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
 
        ret = pca9570_write(gpio, buffer);
        if (ret)
-               goto out;
+               return ret;
 
        gpio->out = buffer;
 
-out:
-       mutex_unlock(&gpio->lock);
-       return ret;
+       return 0;
 }
 
 static int pca9570_probe(struct i2c_client *client)