On Fri, Apr 24, 2026 at 11:01 AM Andy Shevchenko
<[email protected]> wrote:
>
> On Thu, Apr 23, 2026 at 02:12:02PM +0200, Bartosz Golaszewski wrote:
> > If we pass a software node to a newly created device using struct
> > platform_device_info, it will not be removed when the device is
> > released. This may happen when a module creating the device is removed
> > or on failure in platform_device_add().
> >
> > When we try to reuse that software node in a subsequent call to
> > platform_device_register_full(), it will fails with -EBUSY. Add the
> > missing call to device_remove_software_node() in release path.
> >
> > Make sure that we still function correctly if a software node is used as
> > the primary firmware node.
>
> ...
>
> > +     device_remove_software_node(dev);
>
> >       of_node_put(pa->pdev.dev.of_node);
>
> Can we rather replace of_* get/put with the fwnode_* get/put and make a
> conditional here?
>

I thought about it but I'm not sure why we bump the refcount of OF
nodes but not of the firmware nodes supplied in struct
platform_device_info. Maybe there was a reason for it. That would
simplify things.

>         if (is_software_node(...))
>                 device_remove...
>         else
>                 fwnode_handle_put().
>
> (or something like this)
>
> And IIRC the above pattern has been already seen somewhere else. But I can't
> point to it, just some weak memories of seeing that already.
>

That needs to account for two software nodes, I think it's fine to
call the two in sequence unconditionally (like I do this this patch)
and just dump the refcount on registration as necessary.

Bart

Reply via email to