# Re: \[PATCH 06/23\] driver core: platform: provide platform\_device\_set\_of\_node()

- From: Andy Shevchenko \<andriy.shevchenko@linux.intel.com\>
- Date: 2026-06-02 21:40:24 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2026/06/17080165
- Thread: https://ratatoskr.run/netdev/2026/05/17013086/t.md

```text
On Thu, May 21, 2026 at 10:36:29AM +0200, Bartosz Golaszewski wrote:
> Encapsulate the reference counting logic for OF nodes assigned to
> platform devices created with platform_device_alloc() in a helper
> function. Make the kerneldoc state that this is the proper interface for
> assigning OF nodes to dynamically allocated platform devices. This will
> allow us to switch to counting the references of the device's firmware
> nodes, not only the OF nodes.

...

> +/**
> + * platform_device_set_of_node - assign an OF node to device
> + * @pdev: platform device to add the node for
> + * @np: new device node
> + *
> + * Assign an OF node to this platform device. Internally keep track of the
> + * reference count. Devices created with platform_device_alloc() must use this
> + * function instead of assigning the node manually.
> + */
> +void platform_device_set_of_node(struct platform_device *pdev,
> +				 struct device_node *np)

Why not fwnode to begin with?

> +{
> +	of_node_put(pdev->dev.of_node);

And if it has an fwnode?

> +	pdev->dev.of_node = of_node_get(np);
> +	pdev->dev.fwnode = of_fwnode_handle(np);

This looks like

	device_set_node(&pdev->dev, fwnode_handle_get(...));

> +}

-- 
With Best Regards,
Andy Shevchenko



```
