Re: [PATCH v2 2/2] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
From: Sakari Ailus
Date: Tue Feb 24 2026 - 03:56:29 EST
Hi Bartosz,
On Tue, Feb 24, 2026 at 09:47:57AM +0100, Bartosz Golaszewski wrote:
> On Mon, Feb 23, 2026 at 11:07 PM Sakari Ailus
> <sakari.ailus@xxxxxxxxxxxxxxx> wrote:
> >
> > > > >
> > > > > static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode)
> > > > > {
> > > > > - return device_match_fwnode(&gc->gpiodev->dev, fwnode);
> > > > > + struct device *dev = &gc->gpiodev->dev;
> > > > > + struct fwnode_handle *node = dev_fwnode(dev);
> > > > > +
> > > > > + if (IS_ERR(fwnode))
> > > > > + return 0;
> > > > > +
> > > > > + if (device_match_fwnode(dev, fwnode))
> > > >
> > > > Could device_match_fwnode() match secondary fwnode as well?
> > >
> > > In the previous discussion on this, Andy was against doing that due to
> > > the concern that it might introduce subtle bugs, which I agree with.
> >
> > Could you elaborate or provide an example?
> >
> > The function has some 27 users although few are individual drivers.
> >
> > My understanding is that we only have the secondary fwnode for being able
> > to attach objects from different backend to the same node. The fwnode API
> > in the meantime generally tries to hide the existence of the secondary
> > fwnode; a rewrite (which ideally would have happened perhaps a few years
> > ago?) would probably make the fwnode a linked list instead so we'd lose
> > that secondary pointer in the process.
> >
>
> It already is a (singly) linked list. Ideally it would be a
With two entries at most.
> doubly-linked list moved into struct device with struct fwnode_handle
> having no concept of primary and secondary nodes.
I'd think we had that list in struct fwnode_handle, which will still
represent nodes. But let's see the details when someone gets to implement
it. :-)
--
Kind regards,
Sakari Ailus