[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260113111156.188051-4-andriy.shevchenko@linux.intel.com>
Date: Tue, 13 Jan 2026 12:10:54 +0100
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Linus Walleij <linusw@...nel.org>,
Bartosz Golaszewski <brgl@...nel.org>
Subject: [PATCH v2 3/3] 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 <linusw@...nel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/gpio/gpio-pca9570.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-pca9570.c b/drivers/gpio/gpio-pca9570.c
index a41837f1201b..4a368803fb03 100644
--- a/drivers/gpio/gpio-pca9570.c
+++ b/drivers/gpio/gpio-pca9570.c
@@ -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)
--
2.50.1
Powered by blists - more mailing lists