[Concept,17/24] arm: Update boot_prep_linux() to return an error

Message ID 20250922180116.3088502-18-sjg@u-boot.org
State New
Headers
Series boot: efi: Various improvements to booting with the EFI app |

Commit Message

Simon Glass Sept. 22, 2025, 6:01 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Rather than panicing, return the error so that the top-level bootm logic
can decide what to do.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/arm/lib/bootm.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
  

Patch

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 02ff8beaeab..7c650c3ab67 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -164,14 +164,15 @@  static void do_nonsec_virt_switch(void)
 __weak void board_prep_linux(struct bootm_headers *images) { }
 
 /* Subcommand: PREP */
-static void boot_prep_linux(struct bootm_headers *images)
+static int boot_prep_linux(struct bootm_headers *images)
 {
 	char *commandline = env_get("bootargs");
 
 	if (CONFIG_IS_ENABLED(OF_LIBFDT) && IS_ENABLED(CONFIG_LMB) && images->ft_len) {
 		debug("using: FDT\n");
 		if (image_setup_linux(images)) {
-			panic("FDT creation failed!");
+			log_err("FDT creation failed!");
+			return -EINVAL;
 		}
 	} else if (BOOTM_ENABLE_TAGS) {
 		debug("using: ATAGS\n");
@@ -207,6 +208,8 @@  static void boot_prep_linux(struct bootm_headers *images)
 	}
 
 	board_prep_linux(images);
+
+	return 0;
 }
 
 __weak bool armv7_boot_nonsec_default(void)
@@ -345,6 +348,7 @@  static void boot_jump_linux(struct bootm_headers *images, int flag)
 int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
 	struct bootm_headers *images = bmi->images;
+	int ret;
 
 	log_debug("boot linux flag %x\n", flag);
 	/* No need for those on ARM */
@@ -353,7 +357,9 @@  int do_bootm_linux(int flag, struct bootm_info *bmi)
 
 	if (flag & BOOTM_STATE_OS_PREP) {
 		log_debug("Preparing to boot Linux\n");
-		boot_prep_linux(images);
+		ret = boot_prep_linux(images);
+		if (ret)
+			return ret;
 		return 0;
 	}
 
@@ -364,7 +370,9 @@  int do_bootm_linux(int flag, struct bootm_info *bmi)
 	}
 
 	log_debug("No flags set: continuing to prepare and jump to Linux\n");
-	boot_prep_linux(images);
+	ret = boot_prep_linux(images);
+	if (ret)
+		return ret;
 	boot_jump_linux(images, flag);
 	return 0;
 }