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 1/3] gpio: pca9570: Use devm_mutex_init() for mutex initialization
Date: Tue, 13 Jan 2026 12:10:52 +0100 [thread overview]
Message-ID: <20260113111156.188051-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20260113111156.188051-1-andriy.shevchenko@linux.intel.com>
Use devm_mutex_init() since it brings some benefits when
CONFIG_DEBUG_MUTEXES is enabled.
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-pca9570.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-pca9570.c b/drivers/gpio/gpio-pca9570.c
index c5a1287079a0..eae35135c71e 100644
--- a/drivers/gpio/gpio-pca9570.c
+++ b/drivers/gpio/gpio-pca9570.c
@@ -115,7 +115,9 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
static int pca9570_probe(struct i2c_client *client)
{
+ struct device *dev = &client->dev;
struct pca9570 *gpio;
+ int ret;
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
if (!gpio)
@@ -132,7 +134,9 @@ static int pca9570_probe(struct i2c_client *client)
gpio->chip.ngpio = gpio->chip_data->ngpio;
gpio->chip.can_sleep = true;
- mutex_init(&gpio->lock);
+ ret = devm_mutex_init(dev, &gpio->lock);
+ if (ret)
+ return ret;
/* Read the current output level */
pca9570_read(gpio, &gpio->out);
--
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 ` Andy Shevchenko [this message]
2026-01-13 11:10 ` [PATCH v2 2/3] gpio: pca9570: Don't use "proxy" headers Andy Shevchenko
2026-01-13 11:10 ` [PATCH v2 3/3] gpio: pca9570: use lock guards Andy Shevchenko
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-2-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