Patchwork [U-Boot,v2,3/5] bootm: Require boot function only if it is about to be used

login
register
mail settings
Submitter Simon Glass
Date July 4, 2013, 8:26 p.m.
Message ID <1372969571-17043-3-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/256996/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Simon Glass - July 4, 2013, 8:26 p.m.
The original bootm code (before commit 35fc84f) did not check for a valid
boot function in the subcommand case, which was incorrect.

This check was introduced in all cases, but in fact we should only check
for the function when we need it. Otherwise in some cases the check fires
before the OS type is known.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add new patch to limit checking of rboot function validity

 common/cmd_bootm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 0c88be1..63cbfae 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -605,7 +605,7 @@  static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 {
 	boot_os_fn *boot_fn;
 	ulong iflag = 0;
-	int ret = 0;
+	int ret = 0, need_boot_fn;
 
 	images->state |= states;
 
@@ -665,7 +665,10 @@  static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 	if (ret)
 		return ret;
 	boot_fn = boot_os[images->os.os];
-	if (boot_fn == NULL) {
+	need_boot_fn = states & (BOOTM_STATE_OS_CMDLINE |
+			BOOTM_STATE_OS_BD_T | BOOTM_STATE_OS_PREP |
+			BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO);
+	if (boot_fn == NULL && need_boot_fn) {
 		if (iflag)
 			enable_interrupts();
 		printf("ERROR: booting os '%s' (%d) is not supported\n",