summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>2026-07-06 14:44:15 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-10 16:07:09 +0200
commit8877c06885ce43780f7630973dc47cd3a625524b (patch)
treec5250bd95da4b901b6919982d53d90d8bae54505 /drivers/base
parent714cfe9e143feb2136e9dc331c43e2453b3c3d4d (diff)
driver core: platform: provide platform_device_set_fwnode()
Provide a helper function encapsulating the logic of assigning firmware nodes to platform devices created with platform_device_alloc(). Make the kerneldoc state that this is the proper interface for assigning firmware nodes to dynamically allocated platform devices. This will allow us to switch to counting the references of the device's firmware nodes in the future, not only the OF nodes. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://patch.msgid.link/20260706-pdev-fwnode-ref-v3-3-1ff028e33779@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/platform.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 3188d5aba5f9..6520b70cf305 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -712,6 +712,25 @@ void platform_device_set_of_node(struct platform_device *pdev,
EXPORT_SYMBOL_GPL(platform_device_set_of_node);
/**
+ * platform_device_set_fwnode - assign a firmware node to device
+ * @pdev: platform device to set the node for
+ * @fwnode: new firmware node
+ *
+ * Assign a firmware 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_fwnode(struct platform_device *pdev,
+ struct fwnode_handle *fwnode)
+{
+ if (is_of_node(fwnode))
+ platform_device_set_of_node(pdev, to_of_node(fwnode));
+ else
+ pdev->dev.fwnode = fwnode;
+}
+EXPORT_SYMBOL_GPL(platform_device_set_fwnode);
+
+/**
* platform_device_add - add a platform device to device hierarchy
* @pdev: platform device we're adding
*