Re: [PATCH v2] gpio: swnode: restore the swnode-name-against-chip-label matching

From: Dmitry Torokhov

Date: Wed Feb 18 2026 - 12:18:19 EST


On Wed, Feb 18, 2026 at 09:42:28AM +0100, Bartosz Golaszewski wrote:
> On Wed, Feb 18, 2026 at 1:31 AM Dmitry Torokhov
> <dmitry.torokhov@xxxxxxxxx> wrote:
> >
> > On Wed, Feb 11, 2026 at 09:53:13AM +0100, Bartosz Golaszewski wrote:
> > > Using the remote firmware node for software node lookup is the right
> > > thing to do. The GPIO controller we want to resolve should have the
> > > software node we scooped out of the reference attached to it. However,
> > > there are existing users who abuse the software node API by creating
> > > dummy swnodes whose name is set to the expected label string of the GPIO
> > > controller whose pins they want to control and use them in their local
> > > swnode references as GPIO properties.
> > >
> > > This used to work when we compared the software node's name to the
> > > chip's label. When we switched to using a real fwnode lookup, these
> > > users broke down because the firmware nodes in question were never
> > > attached to the controllers they were looking for.
> > >
> > > Restore the label matching as a fallback to fix the broken users but add
> > > a big FIXME urging for a better solution.
> > >
> > > Cc: stable@xxxxxxxxxxxxxxx # v6.18, v6.19
> > > Fixes: 216c12047571 ("gpio: swnode: allow referencing GPIO chips by firmware nodes")
> > > Link: https://lore.kernel.org/all/aYkdKfP5fg6iywgr@jekhomev/
> > > Acked-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > > ---
> > > Changes in v2:
> > > - check if gdev_node and gdev_node->name are not NULL before trying to
> > > match the label (Hans & Dan)
> > > - use the right link
> > > - collect tags
> > >
> > > drivers/gpio/gpiolib-swnode.c | 19 +++++++++++++++++++
> > > 1 file changed, 19 insertions(+)
> > >
> > > diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
> > > index 21478b45c127d..0d7f3f09a0b4b 100644
> > > --- a/drivers/gpio/gpiolib-swnode.c
> > > +++ b/drivers/gpio/gpiolib-swnode.c
> > > @@ -42,6 +42,25 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
> > >
> > > fwnode_lookup:
> > > gdev = gpio_device_find_by_fwnode(fwnode);
> >
> > By the way, should we extend gpio_device_find_by_fwnode() to use both
> > primary and secondary nodes?
> >
>
> That's already done on a higher lever for all fwnodes in gpiod_fwnode_lookup().

How exactly? I am not talking about checking secondary node for the
fwnode that is used in the reference, I am talking about secondary
fwnode that might be assigned to the gpio chip and you need to check
both primary and secondary if they match with the fwnode that you call
gpio_device_find_by_fwnode() with.

Thanks.

--
Dmitry