From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>, david@protonic.nl
Subject: [PATCH v1] drivers: of: register DT root as device
Date: Tue, 14 Jul 2020 14:46:10 +0200 [thread overview]
Message-ID: <20200714124610.12655-1-o.rempel@pengutronix.de> (raw)
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
reply other threads:[~2020-07-14 12:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200714124610.12655-1-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=david@protonic.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox