devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core
@ 2023-07-17 14:37 Rob Herring
  2023-07-17 14:37 ` [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c Rob Herring
  2023-08-04 14:26 ` [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Rob Herring @ 2023-07-17 14:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Frank Rowand
  Cc: linux-kernel, devicetree

There's no reason the generic platform bus code needs to call
of_platform_register_reconfig_notifier(). The notifier can be setup
before the platform bus is. Let's move it into of_core_init() which is
called just before platform_bus_init() instead to keep more of the DT
bits in the DT code.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/base/platform.c     | 2 +-
 drivers/of/base.c           | 1 +
 drivers/of/of_private.h     | 6 ++++++
 drivers/of/platform.c       | 2 ++
 include/linux/of_platform.h | 6 ------
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 77510e4f47de..76bfcba25003 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1528,6 +1528,6 @@ int __init platform_bus_init(void)
 	error =  bus_register(&platform_bus_type);
 	if (error)
 		device_unregister(&platform_bus);
-	of_platform_register_reconfig_notifier();
+
 	return error;
 }
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 166fb7d75337..e235f3a57ea8 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -167,6 +167,7 @@ void __init of_core_init(void)
 {
 	struct device_node *np;
 
+	of_platform_register_reconfig_notifier();
 
 	/* Create the kset, and register existing nodes */
 	mutex_lock(&of_mutex);
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index b57f1014e419..f38397c7b582 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -60,6 +60,12 @@ static inline int of_property_notify(int action, struct device_node *np,
 }
 #endif /* CONFIG_OF_DYNAMIC */
 
+#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS)
+void of_platform_register_reconfig_notifier(void);
+#else
+static inline void of_platform_register_reconfig_notifier(void) { }
+#endif
+
 #if defined(CONFIG_OF_KOBJ)
 int of_node_is_attached(const struct device_node *node);
 int __of_add_property_sysfs(struct device_node *np, struct property *pp);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 051e29b7ad2b..e71adb394b41 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -21,6 +21,8 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
+#include "of_private.h"
+
 const struct of_device_id of_default_bus_match_table[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "simple-mfd", },
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index d8045bcfc35e..fadfea575485 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -127,10 +127,4 @@ static inline int devm_of_platform_populate(struct device *dev)
 static inline void devm_of_platform_depopulate(struct device *dev) { }
 #endif
 
-#if defined(CONFIG_OF_DYNAMIC) && defined(CONFIG_OF_ADDRESS)
-extern void of_platform_register_reconfig_notifier(void);
-#else
-static inline void of_platform_register_reconfig_notifier(void) { }
-#endif
-
 #endif	/* _LINUX_OF_PLATFORM_H */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c
  2023-07-17 14:37 [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Rob Herring
@ 2023-07-17 14:37 ` Rob Herring
  2023-08-04 14:26   ` Greg Kroah-Hartman
  2023-08-04 14:26 ` [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Greg Kroah-Hartman
  1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2023-07-17 14:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Frank Rowand
  Cc: linux-kernel, devicetree

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.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/device.c   | 32 --------------------------------
 drivers/of/platform.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index 0f00f1b80708..2319e0e73048 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -32,25 +32,6 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches,
 }
 EXPORT_SYMBOL(of_match_device);
 
-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);
-}
-
 static void
 of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
 {
@@ -221,19 +202,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_dma_configure_id);
 
-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);
-
 const void *of_device_get_match_data(const struct device *dev)
 {
 	const struct of_device_id *match;
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
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core
  2023-07-17 14:37 [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Rob Herring
  2023-07-17 14:37 ` [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c Rob Herring
@ 2023-08-04 14:26 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-04 14:26 UTC (permalink / raw)
  To: Rob Herring; +Cc: Rafael J. Wysocki, Frank Rowand, linux-kernel, devicetree

On Mon, Jul 17, 2023 at 08:37:16AM -0600, Rob Herring wrote:
> There's no reason the generic platform bus code needs to call
> of_platform_register_reconfig_notifier(). The notifier can be setup
> before the platform bus is. Let's move it into of_core_init() which is
> called just before platform_bus_init() instead to keep more of the DT
> bits in the DT code.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  drivers/base/platform.c     | 2 +-
>  drivers/of/base.c           | 1 +
>  drivers/of/of_private.h     | 6 ++++++
>  drivers/of/platform.c       | 2 ++
>  include/linux/of_platform.h | 6 ------
>  5 files changed, 10 insertions(+), 7 deletions(-)
> 

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c
  2023-07-17 14:37 ` [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c Rob Herring
@ 2023-08-04 14:26   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-08-04 14:26 UTC (permalink / raw)
  To: Rob Herring; +Cc: Rafael J. Wysocki, Frank Rowand, linux-kernel, devicetree

On Mon, Jul 17, 2023 at 08:37:17AM -0600, Rob Herring wrote:
> 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.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-04 14:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 14:37 [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Rob Herring
2023-07-17 14:37 ` [PATCH 2/2] of: Move of_device_{add,register,unregister} to platform.c Rob Herring
2023-08-04 14:26   ` Greg Kroah-Hartman
2023-08-04 14:26 ` [PATCH 1/2] of: Move of_platform_register_reconfig_notifier() into DT core Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).