From 36afd451361dd4386c5527154d94bff4c6c538da Mon Sep 17 00:00:00 2001 From: Nikita Kiryanov Date: Sun, 8 Nov 2015 17:11:49 +0200 Subject: spl: change return values of spl_*_load_image() Make spl_*_load_image() functions return a value instead of hanging if a problem is encountered. This enables main spl code to make the decision whether to hang or not, thus preparing it to support alternative boot devices. Some boot devices (namely nand and spi) do not hang on error. Instead, they return normally and SPL proceeds to boot the contents of the load address. This is considered a bug and is rectified by hanging on error for these devices as well. Signed-off-by: Nikita Kiryanov Cc: Igor Grinberg Cc: Tom Rini Cc: Simon Glass Cc: Ian Campbell Cc: Hans De Goede Cc: Albert Aribaud Cc: Jagan Teki Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- common/spl/spl_usb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'common/spl/spl_usb.c') diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index c81672b798..588b85c4a5 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -21,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR; static int usb_stor_curr_dev = -1; /* current device */ #endif -void spl_usb_load_image(void) +int spl_usb_load_image(void) { int err; block_dev_desc_t *stor_dev; @@ -32,13 +33,15 @@ void spl_usb_load_image(void) #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: usb init failed: err - %d\n", __func__, err); #endif - hang(); + return err; } #ifdef CONFIG_USB_STORAGE /* try to recognize storage devices immediately */ usb_stor_curr_dev = usb_stor_scan(1); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); + if (!stor_dev) + return -ENODEV; #endif debug("boot mode - FAT\n"); @@ -51,8 +54,10 @@ void spl_usb_load_image(void) CONFIG_SYS_USB_FAT_BOOT_PARTITION, CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); - if (err) { - puts("Error loading USB device\n"); - hang(); - } + if (err) { + puts("Error loading from USB device\n"); + return err; + } + + return 0; } -- cgit v1.2.1