diff --git a/commands/usb.c b/commands/usb.c index e503065..9aee430 100644 --- a/commands/usb.c +++ b/commands/usb.c @@ -22,24 +22,20 @@ #include #include -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 e232111..07175dc 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -488,12 +488,19 @@ 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 da0090e..2e1498c 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -248,7 +248,7 @@ 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 */