Re: [PATCH v2 1/3] driver core: platform: remove software node on release()

Bartosz Golaszewski
2026-04-24T12:26:52Z

On Thu, Apr 23, 2026 at 7:32 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> >
> > + /*
> > + * If the primary firmware node is a software node and there's no
> > + * secondary firmware node, the primary will be affected by the call
> > + * to device_remove_software_node() in platform_device_release() and
> > + * its reference count will be dropped by one. Take another reference
> > + * here to make it have no effect.
> > + */
> > + if (is_software_node(pdevinfo->fwnode) && !pdevinfo->swnode)
> > + fwnode_handle_get(pdevinfo->fwnode);
>
> It is possible to pass already registered node in pdevinfo->swnode
> (because device_add_software_node() can handle this just fine). In this
> case we also need to take an extra reference (or figure out whether we
> need to drop the reference when removing the device).
>

But device_add_software_node() checks if the software node is
registered and - if so - just bumps the reference so the effect is the
same as when it registers the swnode.

Bart