mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 05/10] bootm: booti: make device tree optional
Date: Wed, 28 May 2025 12:50:41 +0200	[thread overview]
Message-ID: <20250528105046.3270397-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250528105046.3270397-1-a.fatoum@pengutronix.de>

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@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




  parent reply	other threads:[~2025-05-28 12:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28 10:50 [PATCH 00/10] ARM32: allow disabling ATAGS and DT fallback Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 01/10] arch: add new HAVE_ARCH_BOOTM_OFTREE symbol Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 02/10] bootm: enable CONFIG_BOOTM_OFTREE by default Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 03/10] ARM: lib32: disable ATAGS support " Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 04/10] kvx: bootm: enforce existence of device tree Ahmad Fatoum
2025-05-28 10:50 ` Ahmad Fatoum [this message]
2025-05-28 10:50 ` [PATCH 06/10] filetype: add new file type for 0-sized files Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 07/10] bootm: have bootm_get_devicetree return NULL if passed empty DT Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 08/10] bootm: make fallback to barebox internal tree optional Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 09/10] commands: oftree: add option to return device tree without fixups Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 10/10] of: drop undefined fdt_get_tree declaration Ahmad Fatoum

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=20250528105046.3270397-6-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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