Re: [PATCH 1/2] driver core: provide device_match_fwnode_ext()
From: Bartosz Golaszewski
Date: Fri Feb 20 2026 - 06:06:47 EST
On Fri, 20 Feb 2026 01:47:59 +0100, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> said:
> On Thu, Feb 19, 2026 at 03:15:53PM -0600, Bartosz Golaszewski wrote:
>> On Thu, 19 Feb 2026 17:54:24 +0100, Dmitry Torokhov
>> <dmitry.torokhov@xxxxxxxxx> said:
>> > Hi Bartosz,
>> >
>> > On Thu, Feb 19, 2026 at 05:39:47PM +0100, Bartosz Golaszewski wrote:
>> >> On Thu, Feb 19, 2026 at 5:36 PM Greg Kroah-Hartman
>> >> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>> >> >
>> >> > 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.
>> >> > >
>> >> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
>> >> > > ---
>> >> > > drivers/base/core.c | 14 ++++++++++++++
>> >> > > include/linux/device/bus.h | 1 +
>> >> > > 2 files changed, 15 insertions(+)
>> >> > >
>> >> > > diff --git a/drivers/base/core.c b/drivers/base/core.c
>> >> > > index f599a1384eec90c104601422b04dc2b4c19d4382..bbf1337978fafc35eb94bda85e0bb7f6879879c0 100644
>> >> > > --- a/drivers/base/core.c
>> >> > > +++ b/drivers/base/core.c
>> >> > > @@ -5326,6 +5326,20 @@ int device_match_fwnode(struct device *dev, const void *fwnode)
>> >> > > }
>> >> > > EXPORT_SYMBOL_GPL(device_match_fwnode);
>> >> > >
>> >> > > +int device_match_fwnode_ext(struct device *dev, const void *fwnode)
>> >> >
>> >> > No kernel doc to explain what this function does?
>> >> >
>> >> > :(
>> >> >
>> >>
>> >> It's not like any of the other variants from this file were documented
>> >> but ok, I can add it in v2. Still, I'd like to hear if this even makes
>> >> sense.
>> >
>> > I think it really needs a good explanation given how it goes through
>> > secondaries on one side but not on the other (but maybe it should? Why
>> > one would not want to match secondary?)
>> >
>>
>> I don't think it should. You have one, concrete fwnode and you want to match
>> it against a struct device: in this variant both its primary and secondary
>> nodes. I don't think we should do a four-way matching.
>
> I wonder why you consider these 2 distinct fwnodes instead of a single
> object that has multiple components? After all in device we have a
> pointer to fwnode, and not list of fwnodes....
>
Yes, and we've run into problems due to that. I can't find the series in
question but someone had a device which in DT looked like this:
parent {
compatible = "foo,bar";
child@1 {
...
};
child@1 {
...
};
};
And children would inherit the firmware node of the parent but the user wanted
to attach a separate software node to each child and that can't be done right
now so ideally we'd move to having a list of firmware nodes in struct device
and remove the secondary pointer from struct fwnode_handle.
And to that end: I'd like to limit the usage of secondary fwnodes. In this
case we have an fwnode address we get from fwnode_get_reference_args() and
we match it against all fwnodes of a struct device.
Bart