Re: [PATCH 1/2] driver core: provide device_match_fwnode_ext()
From: Andy Shevchenko
Date: Thu Feb 19 2026 - 14:58:45 EST
On Thu, Feb 19, 2026 at 05:31:22PM +0100, Bartosz Golaszewski wrote:
> Provide an extended variant of device_match_fwnode() that also tries to
> match the device's secondary fwnode.
...
> +int device_match_fwnode_ext(struct device *dev, const void *fwnode)
> +{
> + struct fwnode_handle *dev_node = dev_fwnode(dev);
> + if (!fwnode)
IS_ERR_OR_NULL()
If supplied @fwnode is secondary, it might be an error pointer.
> + return 0;
> + if (dev_node == fwnode)
> + return 1;
> +
> + return fwnode_is_primary(dev_node) && dev_node->secondary == fwnode;
> +}
I think we can refactor this.
struct fwnode_handle *node;
// I would name it like this, because in 3 cases in drivers/base/property.c
// 2 with node and 1 with dev_node when the same API is called.
if (IS_ERR(fwnode))
return 0;
if (device_match_fwnode(dev, fwnode)) // NULL check is inside
return 1;
node = dev_fwnode(dev);
return fwnode_is_primary(node) && node->secondary == fwnode; // NULL check is inside
> + if (!fwnode)
> + return 0;
> + if (dev_node == fwnode)
> + return 1;
> +
> + return fwnode_is_primary(dev_node) && dev_node->secondary == fwnode;
> +}
...
> +int device_match_fwnode_ext(struct device *dev, const void *fwnode);
Perhaps ext --> or_secondary ?
--
With Best Regards,
Andy Shevchenko