Re: [PATCH v3] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
From: Andy Shevchenko
Date: Wed Feb 25 2026 - 05:52:49 EST
On Wed, Feb 25, 2026 at 11:12:25AM +0100, Bartosz Golaszewski wrote:
> In GPIOLIB, during fwnode lookup, after having resolved the consumer's
> reference to a specific fwnode, we only match it against the primary
> node of the controllers. Let's extend that to also the secondary node by
> reworking gpio_chip_match_by_fwnode()
...
> + 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;
--
With Best Regards,
Andy Shevchenko