Re: [PATCH v2 2/2] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
From: Bartosz Golaszewski
Date: Tue Feb 24 2026 - 03:48:19 EST
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
doubly-linked list moved into struct device with struct fwnode_handle
having no concept of primary and secondary nodes.
Bartosz