From: Andy Shevchenko Date: Tue, 13 Jan 2026 11:10:54 +0000 (+0100) Subject: gpio: pca9570: use lock guards X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aa573002ba6884d392dbfce24c3ce057f2dbb6a;p=thirdparty%2Fkernel%2Flinux.git gpio: pca9570: use lock guards Shrink the code by a couple lines and improve lock management by using lock guards from cleanup.h. Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20260113111156.188051-4-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/gpio/gpio-pca9570.c b/drivers/gpio/gpio-pca9570.c index a41837f1201bd..4a368803fb038 100644 --- a/drivers/gpio/gpio-pca9570.c +++ b/drivers/gpio/gpio-pca9570.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -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)