[PATCH 05/10] bootm: booti: make device tree optional

Ahmad Fatoum a.fatoum at pengutronix.de
Wed May 28 03:50:41 PDT 2025


In case the user supplied a /dev/null device tree with a follow-up
commit, we want to pass a long a NULL pointer to the booted kernel and
skip all device tree and initrd related work.

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 arch/arm/lib64/armlinux.c |  2 +-
 arch/riscv/lib/bootm.c    |  2 +-
 common/booti.c            | 14 ++++++++------
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/lib64/armlinux.c b/arch/arm/lib64/armlinux.c
index 13721a71236b..74922cecd9ba 100644
--- a/arch/arm/lib64/armlinux.c
+++ b/arch/arm/lib64/armlinux.c
@@ -11,7 +11,7 @@
 static int do_bootm_linux(struct image_data *data)
 {
 	void *image;
-	phys_addr_t devicetree;
+	phys_addr_t devicetree = 0;
 	int ret;
 
 	image = booti_load_image(data, &devicetree);
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 23ce3873b151..08791458f824 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -8,7 +8,7 @@
 static int do_bootm_linux(struct image_data *data)
 {
 	void (*fn)(unsigned long a0, unsigned long dtb, unsigned long a2);
-	phys_addr_t devicetree;
+	phys_addr_t devicetree = 0;
 	long hartid = riscv_hartid();
 	int ret;
 
diff --git a/common/booti.c b/common/booti.c
index 40611b8f7228..2d4cb3598737 100644
--- a/common/booti.c
+++ b/common/booti.c
@@ -66,6 +66,12 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
 		unsigned long devicetree;
 		const struct resource *initrd_res;
 
+		fdt = bootm_get_devicetree(data);
+		if (IS_ERR(fdt))
+			return fdt;
+		if (!fdt)
+			goto out;
+
 		initrd_res = bootm_load_initrd(data, image_end);
 		if (IS_ERR(initrd_res)) {
 			return ERR_CAST(initrd_res);
@@ -76,12 +82,7 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
 
 		devicetree = image_end;
 
-		fdt = bootm_get_devicetree(data);
-		if (IS_ERR(fdt))
-			return fdt;
-
 		ret = bootm_load_devicetree(data, fdt, devicetree);
-
 		free(fdt);
 
 		if (ret)
@@ -90,8 +91,9 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
 		*oftree = devicetree;
 	}
 
+out:
 	printf("Loaded kernel to 0x%08lx", kernel);
-	if (oftree)
+	if (oftree && *oftree)
 		printf(", devicetree at %pa", oftree);
 	printf("\n");
 
-- 
2.39.5




More information about the barebox mailing list