From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Subject: [PATCH v2 3/3] gpio: pca9570: use lock guards
Date: Tue, 13 Jan 2026 12:10:54 +0100 [thread overview]
Message-ID: <20260113111156.188051-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20260113111156.188051-1-andriy.shevchenko@linux.intel.com>
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>
---
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
next prev parent reply other threads:[~2026-01-13 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 11:10 [PATCH v2 0/3] gpio: pca9570: Ad-hoc cleanups Andy Shevchenko
2026-01-13 11:10 ` [PATCH v2 1/3] gpio: pca9570: Use devm_mutex_init() for mutex initialization Andy Shevchenko
2026-01-13 11:10 ` [PATCH v2 2/3] gpio: pca9570: Don't use "proxy" headers Andy Shevchenko
2026-01-13 11:10 ` Andy Shevchenko [this message]
2026-01-13 14:17 ` [PATCH v2 0/3] gpio: pca9570: Ad-hoc cleanups Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260113111156.188051-4-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox