9
0
Fork 0

usb: move scanned status into core

A command should not be interested in the internal USB core state, so
move the state handling into the core.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-06-19 23:48:32 +02:00
parent 1e60cbaf63
commit 31879ed96f
3 changed files with 12 additions and 9 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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 */