From: Anatoliy Oleinikov via B4 Relay <devnull+admin.wizle.tech@kernel.org>
To: Andi Shyti <andi.shyti@kernel.org>, linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Markus Stockhausen <markus.stockhausen@gmx.de>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Anatoliy Oleinikov <admin@wizle.tech>
Subject: [PATCH v2 1/2] i2c: i2c-gpio: Release a shared SCL before it can be requested again
Date: Wed, 02 Dec 2026 16:15:46 +0300 [thread overview]
Message-ID: <20261202-i2c-gpio-shared-sda-v2-1-7b6afaa5ab2a@wizle.tech> (raw)
In-Reply-To: <20261202-i2c-gpio-shared-sda-v2-0-7b6afaa5ab2a@wizle.tech>
From: Anatoliy Oleinikov <admin@wizle.tech>
Releasing the last reference to a shared SCL removes it from the list
and drops the list lock before it releases the GPIO. An adapter sharing
the pin that probes in between finds no entry and requests the GPIO,
which is still held, so its probe fails with -EBUSY instead of deferring.
Release the GPIO while the list lock is still held.
Fixes: 645c3d7d07fa ("i2c: i2c-gpio: Enhance driver for buses with shared SCL")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Anatoliy Oleinikov <admin@wizle.tech>
---
drivers/i2c/busses/i2c-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 56d6847cbf6d..552fcbb1eaed 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -512,8 +512,9 @@ static void i2c_gpio_cleanup_scl(struct i2c_gpio_scl_data *scl)
return;
list_del(&scl->list);
- mutex_unlock(&i2c_gpio_scl_list_lock);
+ /* An adapter that finds no entry requests the pin, so it must be free by then */
gpiod_put(scl->gpio);
+ mutex_unlock(&i2c_gpio_scl_list_lock);
i2c_gpio_free_scl(scl);
}
--
Git-157)
next prev parent reply other threads:[~2026-12-02 13:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:15 [PATCH v2 0/2] i2c: i2c-gpio: Support buses with shared SDA Anatoliy Oleinikov via B4 Relay
2026-12-02 13:15 ` Anatoliy Oleinikov via B4 Relay [this message]
2026-12-02 13:15 ` [PATCH v2 2/2] i2c: i2c-gpio: Enhance driver for " Anatoliy Oleinikov via B4 Relay
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=20261202-i2c-gpio-shared-sda-v2-1-7b6afaa5ab2a@wizle.tech \
--to=devnull+admin.wizle.tech@kernel.org \
--cc=admin@wizle.tech \
--cc=andi.shyti@kernel.org \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.stockhausen@gmx.de \
--cc=wsa+renesas@sang-engineering.com \
/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
all inboxes | Powered by JetHome®