Skip to content
Snippets Groups Projects
Commit 79adb7a2 authored by Peter Korsgaard's avatar Peter Korsgaard Committed by Tom Rini
Browse files

spl_mmc: return error from mmc_load_image_{raw, fat} rather than hanging


So we can instead fallback to doing something else on errors.

Signed-off-by: default avatarPeter Korsgaard <peter.korsgaard@barco.com>
parent 47b8e527
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
static void mmc_load_image_raw(struct mmc *mmc) static int mmc_load_image_raw(struct mmc *mmc)
{ {
unsigned long err; unsigned long err;
u32 image_size_sectors; u32 image_size_sectors;
...@@ -61,14 +61,14 @@ static void mmc_load_image_raw(struct mmc *mmc) ...@@ -61,14 +61,14 @@ static void mmc_load_image_raw(struct mmc *mmc)
image_size_sectors, (void *)spl_image.load_addr); image_size_sectors, (void *)spl_image.load_addr);
end: end:
if (err == 0) { if (err == 0)
printf("spl: mmc blk read err - %lu\n", err); printf("spl: mmc blk read err - %lu\n", err);
hang();
} return (err == 0);
} }
#ifdef CONFIG_SPL_FAT_SUPPORT #ifdef CONFIG_SPL_FAT_SUPPORT
static void mmc_load_image_fat(struct mmc *mmc) static int mmc_load_image_fat(struct mmc *mmc)
{ {
int err; int err;
struct image_header *header; struct image_header *header;
...@@ -94,11 +94,11 @@ static void mmc_load_image_fat(struct mmc *mmc) ...@@ -94,11 +94,11 @@ static void mmc_load_image_fat(struct mmc *mmc)
(u8 *)spl_image.load_addr, 0); (u8 *)spl_image.load_addr, 0);
end: end:
if (err <= 0) { if (err <= 0)
printf("spl: error reading image %s, err - %d\n", printf("spl: error reading image %s, err - %d\n",
CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err); CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
hang();
} return (err <= 0);
} }
#endif #endif
...@@ -121,17 +121,21 @@ void spl_mmc_load_image(void) ...@@ -121,17 +121,21 @@ void spl_mmc_load_image(void)
printf("spl: mmc init failed: err - %d\n", err); printf("spl: mmc init failed: err - %d\n", err);
hang(); hang();
} }
boot_mode = spl_boot_mode(); boot_mode = spl_boot_mode();
if (boot_mode == MMCSD_MODE_RAW) { if (boot_mode == MMCSD_MODE_RAW) {
debug("boot mode - RAW\n"); debug("boot mode - RAW\n");
mmc_load_image_raw(mmc); err = mmc_load_image_raw(mmc);
#ifdef CONFIG_SPL_FAT_SUPPORT #ifdef CONFIG_SPL_FAT_SUPPORT
} else if (boot_mode == MMCSD_MODE_FAT) { } else if (boot_mode == MMCSD_MODE_FAT) {
debug("boot mode - FAT\n"); debug("boot mode - FAT\n");
mmc_load_image_fat(mmc); err = mmc_load_image_fat(mmc);
#endif #endif
} else { } else {
puts("spl: wrong MMC boot mode\n"); puts("spl: wrong MMC boot mode\n");
hang(); hang();
} }
if (err)
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