From: Hans de Goede <hansg@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Mika Westerberg <westeri@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] gpiolib: Extend software-node support to support secondary software-nodes
Date: Mon, 15 Sep 2025 19:49:16 +0200 [thread overview]
Message-ID: <f6c18910-d870-4fa7-8035-abc8700aef2b@kernel.org> (raw)
In-Reply-To: <kpoek6bs3rea4fl6b4h55grmsykw2zw2j6kohu3aijlabjngyc@7fbnoon3ilhw>
Hi,
On 15-Sep-25 3:21 AM, Dmitry Torokhov wrote:
> Hi Hans,
>
> On Sat, Sep 13, 2025 at 08:43:09PM +0200, Hans de Goede wrote:
>> When a software-node gets added to a device which already has another
>> fwnode as primary node it will become the secondary fwnode for that
>> device.
>>
>> Currently if a software-node with GPIO properties ends up as the secondary
>> fwnode then gpiod_find_by_fwnode() will fail to find the GPIOs.
>>
>> Add a check to gpiod_find_by_fwnode() to try a software-node lookup on
>> the secondary fwnode if the GPIO was not found in the primary fwnode.
>
> Thanks for catching this. I think it would be better if we added
> handling of the secondary node to gpiod_find_and_request(). This way the
> fallback will work for all kind of combinations, even if secondary node
> happens to be an OF or ACPI one.
IOW something like this:
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b619fea498c8..1a3b5ca00554 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4630,6 +4630,13 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer,
scoped_guard(srcu, &gpio_devices_srcu) {
desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx,
&flags, &lookupflags);
+
+ if (gpiod_not_found(desc) && fwnode) {
+ dev_dbg(consumer, "trying secondary fwnode for GPIO lookup\n");
+ desc = gpiod_find_by_fwnode(fwnode->secondary, consumer,
+ con_id, idx, &flags, &lookupflags);
+ }
+
if (gpiod_not_found(desc) && platform_lookup_allowed) {
/*
* Either we are not using DT or ACPI, or their lookup
That should work too, but if there is an OF or ACPI node it should always
be the primary one. So my original patch id fine as is.
Either way works for me. If you prefer the above approach instead of my
original patch let me know and I'll give it a test-run and then post a v2.
Regards,
Hans
next prev parent reply other threads:[~2025-09-15 17:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 18:43 [PATCH] gpiolib: Extend software-node support to support secondary software-nodes Hans de Goede
2025-09-14 13:34 ` Andy Shevchenko
2025-09-14 13:37 ` Andy Shevchenko
2025-09-15 1:21 ` Dmitry Torokhov
2025-09-15 17:49 ` Hans de Goede [this message]
2025-09-16 8:01 ` Andy Shevchenko
2025-09-16 9:31 ` 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=f6c18910-d870-4fa7-8035-abc8700aef2b@kernel.org \
--to=hansg@kernel.org \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=westeri@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