summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/usb.c9
-rw-r--r--drivers/usb/core/usb.c39
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--include/usb/usb.h6
4 files changed, 19 insertions, 37 deletions
diff --git a/commands/usb.c b/commands/usb.c
index c158852ca9..a37d50327f 100644
--- a/commands/usb.c
+++ b/commands/usb.c
@@ -112,13 +112,10 @@ static void usb_show_devices(bool tree)
static int do_usb(int argc, char *argv[])
{
int opt;
- int force = 0, tree = 0, show = 0;
+ int tree = 0, show = 0;
- while ((opt = getopt(argc, argv, "fts")) > 0) {
+ while ((opt = getopt(argc, argv, "ts")) > 0) {
switch (opt) {
- case 'f':
- force = 1;
- break;
case 't':
tree = 1;
show = 1;
@@ -129,7 +126,7 @@ static int do_usb(int argc, char *argv[])
}
}
- usb_rescan(force);
+ usb_rescan();
if (show)
usb_show_devices(tree);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index faf509ec9d..fdf9d94a52 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -492,50 +492,35 @@ struct usb_device *usb_alloc_new_device(void)
return usbdev;
}
-int usb_host_detect(struct usb_host *host, int force)
+int usb_host_detect(struct usb_host *host)
{
- struct usb_device *dev, *tmp;
int ret;
- if (host->scanned && !force)
- return -EBUSY;
-
- list_for_each_entry_safe(dev, tmp, &usb_device_list, list) {
- if (dev->host != host)
- continue;
+ if (!host->root_dev) {
+ ret = host->init(host);
+ if (ret)
+ return ret;
- list_del(&dev->list);
- unregister_device(&dev->dev);
- free(dev->hub);
- dma_free(dev->setup_packet);
- dma_free(dev->descriptor);
- free(dev);
+ host->root_dev = usb_alloc_new_device();
+ host->root_dev->dev.parent = host->hw_dev;
+ host->root_dev->host = host;
+ usb_new_device(host->root_dev);
}
- ret = host->init(host);
- if (ret)
- return ret;
-
- dev = usb_alloc_new_device();
- dev->dev.parent = host->hw_dev;
- dev->host = host;
- usb_new_device(dev);
-
- host->scanned = 1;
+ device_detect(&host->root_dev->dev);
return 0;
}
-void usb_rescan(int force)
+void usb_rescan(void)
{
struct usb_host *host;
int ret;
pr_info("USB: scanning bus for devices...\n");
- dev_index = 0;
list_for_each_entry(host, &host_list, list) {
- ret = usb_host_detect(host, force);
+ ret = usb_host_detect(host);
if (ret)
continue;
}
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d30c3aa1d1..9e30deb419 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -871,7 +871,7 @@ static int ehci_detect(struct device_d *dev)
{
struct ehci_priv *ehci = dev->priv;
- return usb_host_detect(&ehci->host, 0);
+ return usb_host_detect(&ehci->host);
}
int ehci_register(struct device_d *dev, struct ehci_data *data)
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 34edbae0a5..41f92c2df0 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -150,12 +150,12 @@ struct usb_host {
struct device_d *hw_dev;
int busnum;
- int scanned;
+ struct usb_device *root_dev;
};
int usb_register_host(struct usb_host *);
-int usb_host_detect(struct usb_host *host, int force);
+int usb_host_detect(struct usb_host *host);
int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol);
int usb_set_idle(struct usb_device *dev, int ifnum, int duration,
@@ -185,7 +185,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(int force);
+void usb_rescan(void);
/* big endian -> little endian conversion */
/* some CPUs are already little endian e.g. the ARM920T */