mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] of: skip machine device creation on subsequent of_probe
@ 2021-11-25 16:06 Ahmad Fatoum
  2021-11-25 16:06 ` [PATCH 2/2] of: base: improve documentation of global exports Ahmad Fatoum
  2021-11-30 10:36 ` [PATCH 1/2] of: skip machine device creation on subsequent of_probe Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-11-25 16:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

of_probe may be called more than once, e.g. after oftree -p or by board
code after fixing up device tree. This currently leads to a harmless,
but annoying error message about machine already being registered.

Avoid this by creating the device only once.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/base.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 910348fb81b9..ec4f9327036c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2333,9 +2333,12 @@ mem_initcall(of_probe_memory);
 
 static void of_platform_device_create_root(struct device_node *np)
 {
-	struct device_d *dev;
+	static struct device_d *dev;
 	int ret;
 
+	if (dev)
+		return;
+
 	dev = xzalloc(sizeof(*dev));
 	dev->id = DEVICE_ID_SINGLE;
 	dev->device_node = np;
-- 
2.30.2


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


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

end of thread, other threads:[~2021-11-30 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 16:06 [PATCH 1/2] of: skip machine device creation on subsequent of_probe Ahmad Fatoum
2021-11-25 16:06 ` [PATCH 2/2] of: base: improve documentation of global exports Ahmad Fatoum
2021-11-30 10:36 ` [PATCH 1/2] of: skip machine device creation on subsequent of_probe Sascha Hauer

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