Re: [PATCH v23 08/13] mfd: core: Add firmware-node support to MFD cells

From: Bartosz Golaszewski

Date: Wed Jul 22 2026 - 06:06:33 EST


On Tue, 21 Jul 2026 14:48:46 +0200, Shivendra Pratap
<shivendra.pratap@xxxxxxxxxxxxxxxx> said:
>>
>>> + struct device_node *named_np;
>>> +
>>> + fwnode = device_get_named_child_node(parent, cell->named_fwnode);
>>> + if (!fwnode) {
>>> + ret = -ENODEV;
>>> + goto fail_alias;
>>> + }
>>> +
>>> + named_np = to_of_node(fwnode);
>>> + if (named_np) {
>>> + ret = mfd_claim_of_node_to_dev(pdev, named_np);
>>> + fwnode_handle_put(fwnode);
>>> + if (ret == -EAGAIN)
>>> + ret = -EBUSY;
>>> + if (ret)
>>> + goto fail_alias;
>>> + } else {
>>> + ret = mfd_claim_named_fwnode(pdev, fwnode);
>>> + if (ret) {
>>> + fwnode_handle_put(fwnode);
>>> + if (ret == -EAGAIN)
>>> + ret = -EBUSY;
>>> + goto fail_alias;
>>> + }
>>> + device_set_node(&pdev->dev, fwnode);
>>> + fwnode_handle_put(fwnode);
>>> + }
>>
>> What is the reason to have this split into OF and fwnode functions? I don't
>> really see why you would need to do it twice, isn't fwnode sufficient for the
>> OF node case too?
>
> We do a duplicate check here before adding the named_fwnode and split it
> for two reasons:
> 1. of_node list pre-exists. We add a new list of fwnode. of_node based
> duplicate check go wrong, if its checked with the fwnode list.
> 2. of_node need to go to its respective list as fwnode list, release
> path, is different for us.
>

I see. This could use a unification to fwnodes as well but that's out of scope
for this series.

Bart