Skip to content
Snippets Groups Projects
Commit fd61d399 authored by Nikita Kiryanov's avatar Nikita Kiryanov Committed by Tom Rini
Browse files

spl: mmc: add break statements in spl_mmc_load_image()


The original intention of the mmc load_image() function was to try multiple
boot modes before failing. This is evident by the lack of break statements
in the switch, and the following line in the default case:
puts("spl: mmc: no boot mode left to try\n");

This implementation is problematic because:
- The availability of alternative boot modes is very arbitrary since it
depends on the specific order of the switch cases. If your boot mode happens to
be the first case, then you'll have a bunch of other boot modes as alternatives.
If it happens to be the last case, then you have none.
- Opting in/out is tied to config options, so the only way for you to prevent an
alternative boot mode from being attempted is to give up on the feature completely.
- This implementation makes the code more complicated and difficult to
understand.

Address these issues by inserting a break statements between the cases to make the
function try only one boot mode.

Signed-off-by: default avatarNikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent 483ab3dc
No related branches found
No related tags found
No related merge requests found
...@@ -164,6 +164,7 @@ void spl_mmc_load_image(void) ...@@ -164,6 +164,7 @@ void spl_mmc_load_image(void)
if (!err) if (!err)
return; return;
#endif #endif
break;
case MMCSD_MODE_FS: case MMCSD_MODE_FS:
debug("spl: mmc boot mode: fs\n"); debug("spl: mmc boot mode: fs\n");
...@@ -203,6 +204,7 @@ void spl_mmc_load_image(void) ...@@ -203,6 +204,7 @@ void spl_mmc_load_image(void)
#endif #endif
#endif #endif
#endif #endif
break;
#ifdef CONFIG_SUPPORT_EMMC_BOOT #ifdef CONFIG_SUPPORT_EMMC_BOOT
case MMCSD_MODE_EMMCBOOT: case MMCSD_MODE_EMMCBOOT:
/* /*
...@@ -240,15 +242,14 @@ void spl_mmc_load_image(void) ...@@ -240,15 +242,14 @@ void spl_mmc_load_image(void)
if (!err) if (!err)
return; return;
#endif #endif
break;
#endif #endif
case MMCSD_MODE_UNDEFINED: case MMCSD_MODE_UNDEFINED:
default:
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
if (err) default:
puts("spl: mmc: no boot mode left to try\n"); puts("spl: mmc: wrong boot mode\n");
else
puts("spl: mmc: wrong boot mode\n");
#endif #endif
hang();
} }
hang();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment