[U-Boot] [PATCH V2 02/13] spl: mmc: add break statements in spl_mmc_load_image()

Simon Glass sjg at chromium.org
Thu Oct 29 18:19:13 CET 2015


On 28 October 2015 at 03:23, Nikita Kiryanov <nikita at compulab.co.il> wrote:
> 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: Nikita Kiryanov <nikita at compulab.co.il>
> Cc: Igor Grinberg <grinberg at compulab.co.il>
> Cc: Paul Kocialkowski <contact at paulk.fr>
> Cc: Pantelis Antoniou <panto at antoniou-consulting.com>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
> Changes in V2:
>         - Removed hang() in default cases, moved default case into ifdef
>           LIBCOMMON.
>
>  common/spl/spl_mmc.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list