Thread (57 messages) 57 messages, 14 authors, 5d ago

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
Also in: dri-devel, driver-core, imx, intel-xe, linux-arm-msm, linux-devicetree, linux-i2c, linux-iommu, linux-mips, linux-pm, linux-sound, linux-usb, lkml, netdev, platform-driver-x86

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


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help