summaryrefslogtreecommitdiff
path: root/drivers/of/platform.c
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2023-07-17 17:37:17 +0300
committerRob Herring <robh@kernel.org>2023-08-04 20:36:33 +0300
commit66a4210bc82e024e6de0f94298ad9230984a5924 (patch)
tree3b7786c7d39872cf7b9cfe2cfb41431adc769adb /drivers/of/platform.c
parent73aca58b781e3e3d52bb7247b374fb5334a05001 (diff)
downloadlinux-66a4210bc82e024e6de0f94298ad9230984a5924.tar.xz
of: Move of_device_{add,register,unregister} to platform.c
The declarations for of_device_{add,register,unregister} were moved into of_platform.h, so the implementations should be moved to platform.c as well. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20230717143718.1715773-2-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r--drivers/of/platform.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index e71adb394b41..8d03d9e65ef9 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -56,6 +56,38 @@ struct platform_device *of_find_device_by_node(struct device_node *np)
}
EXPORT_SYMBOL(of_find_device_by_node);
+int of_device_add(struct platform_device *ofdev)
+{
+ BUG_ON(ofdev->dev.of_node == NULL);
+
+ /* name and id have to be set so that the platform bus doesn't get
+ * confused on matching */
+ ofdev->name = dev_name(&ofdev->dev);
+ ofdev->id = PLATFORM_DEVID_NONE;
+
+ /*
+ * If this device has not binding numa node in devicetree, that is
+ * of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this
+ * device is on the same node as the parent.
+ */
+ set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node));
+
+ return device_add(&ofdev->dev);
+}
+
+int of_device_register(struct platform_device *pdev)
+{
+ device_initialize(&pdev->dev);
+ return of_device_add(pdev);
+}
+EXPORT_SYMBOL(of_device_register);
+
+void of_device_unregister(struct platform_device *ofdev)
+{
+ device_unregister(&ofdev->dev);
+}
+EXPORT_SYMBOL(of_device_unregister);
+
#ifdef CONFIG_OF_ADDRESS
/*
* The following routines scan a subtree and registers a device for