]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/spl/spl_usb.c
spl: Rework image header parse to allow abort on raw image and os boot
[karo-tx-uboot.git] / common / spl / spl_usb.c
index c81672b7981ebd2f17deb446403f110a55364f6d..04fa66758cbc0255da1fa97632dd655aeb1dd918 100644 (file)
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <spl.h>
 #include <asm/u-boot.h>
+#include <errno.h>
 #include <usb.h>
 #include <fat.h>
 
@@ -21,10 +22,10 @@ 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;
+       struct blk_desc *stor_dev;
 
        usb_stop();
        err = usb_init();
@@ -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);
+       stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, 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;
 }