From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH 2/3] gpio: shared: verify con_id when adding proxy lookup
Date: Mon, 22 Dec 2025 11:01:27 +0100 [thread overview]
Message-ID: <20251222-gpio-shared-reset-gpio-proxy-v1-2-8d4bba7d8c14@oss.qualcomm.com> (raw)
In-Reply-To: <20251222-gpio-shared-reset-gpio-proxy-v1-0-8d4bba7d8c14@oss.qualcomm.com>
When matching the firmware node with the potential consumer, we
currently omit the con_id string. This can lead to false positives in
the unlikely case of the consumer having been assigned more than one
shared GPIO. Check the connector ID before proceeding.
Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/gpiolib-shared.c | 7 ++++++-
drivers/gpio/gpiolib-shared.h | 4 +++-
drivers/gpio/gpiolib.c | 3 ++-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index ba4b718d40a087608fc06f59d242932df1d117e9..f589109590c7c6bc9c0c1828ea15ab9003846523 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -365,7 +365,8 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
}
#endif /* CONFIG_RESET_GPIO */
-int gpio_shared_add_proxy_lookup(struct device *consumer, unsigned long lflags)
+int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
+ unsigned long lflags)
{
const char *dev_id = dev_name(consumer);
struct gpio_shared_entry *entry;
@@ -384,6 +385,10 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, unsigned long lflags)
guard(mutex)(&ref->lock);
+ if ((!con_id && ref->con_id) || (con_id && !ref->con_id) ||
+ (con_id && ref->con_id && strcmp(con_id, ref->con_id) != 0))
+ continue;
+
/* We've already done that on a previous request. */
if (ref->lookup)
return 0;
diff --git a/drivers/gpio/gpiolib-shared.h b/drivers/gpio/gpiolib-shared.h
index 667dbdff3585066b7cbe2ebe476725fe7d683d84..40568ef7364ccbf08b7f583e279a7d5b572af477 100644
--- a/drivers/gpio/gpiolib-shared.h
+++ b/drivers/gpio/gpiolib-shared.h
@@ -16,7 +16,8 @@ struct device;
int gpio_device_setup_shared(struct gpio_device *gdev);
void gpio_device_teardown_shared(struct gpio_device *gdev);
-int gpio_shared_add_proxy_lookup(struct device *consumer, unsigned long lflags);
+int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
+ unsigned long lflags);
#else
@@ -28,6 +29,7 @@ static inline int gpio_device_setup_shared(struct gpio_device *gdev)
static inline void gpio_device_teardown_shared(struct gpio_device *gdev) { }
static inline int gpio_shared_add_proxy_lookup(struct device *consumer,
+ const char *con_id,
unsigned long lflags)
{
return 0;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6d583b3b07bb5c3e5886ced53deca7cd02460890..9ccfb7af67cca61207e8479842b78942a22cb919 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4717,7 +4717,8 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer,
* lookup table for the proxy device as previously
* we only knew the consumer's fwnode.
*/
- ret = gpio_shared_add_proxy_lookup(consumer, lookupflags);
+ ret = gpio_shared_add_proxy_lookup(consumer, con_id,
+ lookupflags);
if (ret)
return ERR_PTR(ret);
--
2.47.3
next prev parent reply other threads:[~2025-12-22 10:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 10:01 [PATCH 0/3] gpio: shared: close remaining gaps Bartosz Golaszewski
2025-12-22 10:01 ` [PATCH 1/3] gpiolib: allow multiple lookup tables per consumer Bartosz Golaszewski
2025-12-22 10:01 ` Bartosz Golaszewski [this message]
2025-12-22 10:01 ` [PATCH 3/3] gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib Bartosz Golaszewski
[not found] ` <CGME20260105115023eucas1p1af1f8e80041f94843beb664966894fb9@eucas1p1.samsung.com>
2026-01-05 11:50 ` Marek Szyprowski
2026-01-05 12:28 ` Bartosz Golaszewski
2026-01-05 17:26 ` Marek Szyprowski
2026-01-05 18:16 ` Marek Szyprowski
2026-01-06 10:55 ` Bartosz Golaszewski
2026-01-05 15:53 ` Bartosz Golaszewski
2026-01-06 12:21 ` Mark Brown
2026-01-06 12:25 ` Bartosz Golaszewski
2026-01-08 15:46 ` Mark Brown
2026-01-08 15:52 ` Bartosz Golaszewski
2026-01-08 16:29 ` Mark Brown
2026-01-08 18:04 ` Bartosz Golaszewski
2026-01-02 9:34 ` [PATCH 0/3] gpio: shared: close remaining gaps 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=20251222-gpio-shared-reset-gpio-proxy-v1-2-8d4bba7d8c14@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linus.walleij@linaro.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
all inboxes | Powered by JetHome®