]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Prevent USB commands from working when USB is stopped.
authorBartlomiej Sieka <tur@semihalf.com>
Thu, 3 Aug 2006 21:20:13 +0000 (23:20 +0200)
committerBartlomiej Sieka <tur@semihalf.com>
Thu, 3 Aug 2006 21:20:13 +0000 (23:20 +0200)
CHANGELOG
common/cmd_usb.c
common/usb.c

index e9811168a6327b2541d327c10da4800875ad2f77..df1b6d0b12bc6c0eac990e548fe81771e6550be6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* Prevent USB commands from working when USB is stopped.
+
 * Add rudimentary handling of alternate settings of USB interfaces.
   This is in order to fix issues with some USB sticks or knives timing
   out during initialisation. Some code readability improvements.
index fcc66621a3f7bb9dd974399983084cb62b8d5a8c..28c05aa20eaf69afa8a4145a61a293c0ae0f6f4a 100644 (file)
@@ -444,6 +444,7 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        int i;
        struct usb_device *dev = NULL;
+       extern char usb_started;
 #ifdef CONFIG_USB_STORAGE
        block_dev_desc_t *stor_dev;
 #endif
@@ -477,6 +478,10 @@ int do_usb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                usb_stop();
                return 0;
        }
+       if (!usb_started) {
+               printf("USB is stopped. Please issue 'usb start' first.\n");
+               return 1;
+       }
        if (strncmp(argv[1],"tree",4) == 0) {
                printf("\nDevice Tree:\n");
                usb_show_tree(usb_get_dev_index(0));
index b1b7aec621a013b2ce4237038bd30bf2ee4d5d28..0857494b27b974c442b07d96b4f30c46d8d0c54b 100644 (file)
@@ -72,6 +72,8 @@ static int running;
 static int asynch_allowed;
 static struct devrequest setup_packet;
 
+char usb_started; /* flag for the started/stopped USB status */
+
 /**********************************************************************
  * some forward declerations...
  */
@@ -110,10 +112,12 @@ int usb_init(void)
                printf("scanning bus for devices... ");
                running=1;
                usb_scan_devices();
+               usb_started = 1;
                return 0;
        }
        else {
                printf("Error, couldn't init Lowlevel part\n");
+               usb_started = 0;
                return -1;
        }
 }
@@ -124,6 +128,7 @@ int usb_init(void)
 int usb_stop(void)
 {
        asynch_allowed=1;
+       usb_started = 0;
        usb_hub_reset();
        return usb_lowlevel_stop();
 }