Re: [PATCH v3] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
From: Andy Shevchenko
Date: Wed Feb 25 2026 - 05:57:20 EST
On Wed, Feb 25, 2026 at 12:52:35PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 25, 2026 at 11:12:25AM +0100, Bartosz Golaszewski wrote:
...
> > + if (IS_ERR(fwnode))
> > + return 0;
> > +
> > + if (device_match_fwnode(dev, fwnode))
> > + return 1;
> > +
> > + return node && !IS_ERR(node->secondary) && node->secondary == fwnode;
>
> I believe Rafael is right in suggesting just
>
> return node && node->secondary == fwnode;
>
> At this point fwnode either NULL or valid. 'node' comes from device,
> so it may be all three. Assuming it's actually can't be error pointer
> the above check is sufficient. But maybe you wanted full check, then
>
> return !IS_ERR_OR_NULL(node) && node->secondary == fwnode;
And probably NULL should be excluded from fwnode:
return fwnode && !IS_ERR_OR_NULL(node) && node->secondary == fwnode;
--
With Best Regards,
Andy Shevchenko