diff options
-rw-r--r-- | commands/usb.c | 10 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 9 | ||||
-rw-r--r-- | include/usb/usb.h | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/commands/usb.c b/commands/usb.c index e5030659b4..9aee4308da 100644 --- a/commands/usb.c +++ b/commands/usb.c @@ -22,24 +22,20 @@ #include <usb/usb.h> #include <getopt.h> -static int scanned; - static int do_usb(int argc, char *argv[]) { int opt; + int force = 0; while ((opt = getopt(argc, argv, "f")) > 0) { switch (opt) { case 'f': - scanned = 0; + force = 1; break; } } - if (!scanned) { - usb_rescan(); - scanned = 1; - } + usb_rescan(force); return 0; } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index e232111410..07175dc3f1 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -488,12 +488,19 @@ static struct usb_device *usb_alloc_new_device(void) return usbdev; } -void usb_rescan(void) +static int scanned; + +void usb_rescan(int force) { struct usb_device *dev, *tmp; struct usb_host *host; int ret; + if (scanned && !force) + return; + + scanned = 1; + list_for_each_entry_safe(dev, tmp, &usb_device_list, list) { list_del(&dev->list); unregister_device(&dev->dev); diff --git a/include/usb/usb.h b/include/usb/usb.h index da0090e039..2e1498c8b6 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -248,7 +248,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe); int usb_string(struct usb_device *dev, int index, char *buf, size_t size); int usb_set_interface(struct usb_device *dev, int interface, int alternate); -void usb_rescan(void); +void usb_rescan(int force); /* big endian -> little endian conversion */ /* some CPUs are already little endian e.g. the ARM920T */ |