[PATCH master 37/39] efi: payload: register dummy device tree

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:44:37 PST 2026


EFI payload support can enabled on top of an existing multi-image build
and thus runs into problems when the SoC specific initcalls implicitly
assume a device tree to be available.

Register a tentative empty device tree in this case to avoid issues.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/of/base.c       |  8 ++++++--
 efi/payload/boarddata.c | 11 +++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4e83a757a4e9..8a17b0853ad4 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2103,8 +2103,12 @@ of_populate_initcall(barebox_of_populate);
 
 int barebox_register_of(struct device_node *root)
 {
-	if (root_node)
-		return -EBUSY;
+	if (root_node) {
+		if (!list_empty(&root->children))
+			return -EBUSY;
+		/* Not necessarily safe to free, so leak it.. */
+		root_node = NULL;
+	}
 
 	of_set_root_node(root);
 	of_fix_tree(root);
diff --git a/efi/payload/boarddata.c b/efi/payload/boarddata.c
index a2f4b8d21b4a..ec6ee7bbd98f 100644
--- a/efi/payload/boarddata.c
+++ b/efi/payload/boarddata.c
@@ -14,6 +14,7 @@
 #include <linux/printk.h>
 #include <debug_ll.h>
 #include <init.h>
+#include <of.h>
 #include <pbl/handoff-data.h>
 
 static int handle_efi_boarddata(void)
@@ -46,3 +47,13 @@ static int handle_efi_boarddata(void)
 	return 0;
 }
 pure_initcall(handle_efi_boarddata);
+
+static __maybe_unused int efi_register_of(void)
+{
+	if (!BS)
+		return 0;
+	return barebox_register_of(of_new_node(NULL, NULL));
+}
+#ifdef CONFIG_OFDEVICE
+core_initcall(efi_register_of);
+#endif
-- 
2.47.3




More information about the barebox mailing list