mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1] drivers: of: register DT root as device
@ 2020-07-14 12:46 Oleksij Rempel
  0 siblings, 0 replies; only message in thread
From: Oleksij Rempel @ 2020-07-14 12:46 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel, david

A usual board file contains at least one of_machine_is_compatible().
Some of the have a rather ling list with complicated version logic.

To avoid own implementation for driver management, register the root node
of devicetree as platform device. So, the main platform bus can attach
proper board driver. After this patch a typical board.c file can reuse
existing driver infrastructure.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/of/platform.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ca84cede23..ab4329314e 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -348,6 +348,7 @@ int of_platform_populate(struct device_node *root,
 			struct device_d *parent)
 {
 	struct device_node *child;
+	struct device_d *dev;
 	int rc = 0;
 
 	if (!root)
@@ -355,6 +356,10 @@ int of_platform_populate(struct device_node *root,
 	if (!root)
 		return -EINVAL;
 
+	dev = of_platform_device_create(root, NULL);
+	if (dev)
+		dev_set_name(dev, "%s.of", "machine");
+
 	for_each_child_of_node(root, child) {
 		rc = of_platform_bus_create(child, matches, parent);
 		if (rc)
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-14 12:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 12:46 [PATCH v1] drivers: of: register DT root as device Oleksij Rempel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox