aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/devices.c10
-rw-r--r--drivers/usb/core/hcd.c21
-rw-r--r--drivers/usb/core/usb.c1
3 files changed, 9 insertions, 23 deletions
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index b35a6a52210f..6118a04f0b84 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -110,13 +110,6 @@ static const char format_endpt[] =
110/* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */ 110/* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */
111 "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n"; 111 "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n";
112 112
113
114/*
115 * Need access to the driver and USB bus lists.
116 * extern struct list_head usb_bus_list;
117 * However, these will come from functions that return ptrs to each of them.
118 */
119
120/* 113/*
121 * Wait for an connect/disconnect event to happen. We initialize 114 * Wait for an connect/disconnect event to happen. We initialize
122 * the event counter with an odd number, and each event will increment 115 * the event counter with an odd number, and each event will increment
@@ -618,6 +611,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
618 struct usb_bus *bus; 611 struct usb_bus *bus;
619 ssize_t ret, total_written = 0; 612 ssize_t ret, total_written = 0;
620 loff_t skip_bytes = *ppos; 613 loff_t skip_bytes = *ppos;
614 int id;
621 615
622 if (*ppos < 0) 616 if (*ppos < 0)
623 return -EINVAL; 617 return -EINVAL;
@@ -628,7 +622,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
628 622
629 mutex_lock(&usb_bus_list_lock); 623 mutex_lock(&usb_bus_list_lock);
630 /* print devices for all busses */ 624 /* print devices for all busses */
631 list_for_each_entry(bus, &usb_bus_list, bus_list) { 625 idr_for_each_entry(&usb_bus_idr, bus, id) {
632 /* recurse through all children of the root hub */ 626 /* recurse through all children of the root hub */
633 if (!bus_to_hcd(bus)->rh_registered) 627 if (!bus_to_hcd(bus)->rh_registered)
634 continue; 628 continue;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 232c8c93dd3a..cf3eb22dbeb4 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -90,12 +90,11 @@ unsigned long usb_hcds_loaded;
90EXPORT_SYMBOL_GPL(usb_hcds_loaded); 90EXPORT_SYMBOL_GPL(usb_hcds_loaded);
91 91
92/* host controllers we manage */ 92/* host controllers we manage */
93LIST_HEAD (usb_bus_list); 93DEFINE_IDR (usb_bus_idr);
94EXPORT_SYMBOL_GPL (usb_bus_list); 94EXPORT_SYMBOL_GPL (usb_bus_idr);
95 95
96/* used when allocating bus numbers */ 96/* used when allocating bus numbers */
97#define USB_MAXBUS 64 97#define USB_MAXBUS 64
98static DECLARE_BITMAP(busmap, USB_MAXBUS);
99 98
100/* used when updating list of hcds */ 99/* used when updating list of hcds */
101DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ 100DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */
@@ -996,8 +995,6 @@ static void usb_bus_init (struct usb_bus *bus)
996 bus->bandwidth_int_reqs = 0; 995 bus->bandwidth_int_reqs = 0;
997 bus->bandwidth_isoc_reqs = 0; 996 bus->bandwidth_isoc_reqs = 0;
998 mutex_init(&bus->usb_address0_mutex); 997 mutex_init(&bus->usb_address0_mutex);
999
1000 INIT_LIST_HEAD (&bus->bus_list);
1001} 998}
1002 999
1003/*-------------------------------------------------------------------------*/ 1000/*-------------------------------------------------------------------------*/
@@ -1018,16 +1015,12 @@ static int usb_register_bus(struct usb_bus *bus)
1018 int busnum; 1015 int busnum;
1019 1016
1020 mutex_lock(&usb_bus_list_lock); 1017 mutex_lock(&usb_bus_list_lock);
1021 busnum = find_next_zero_bit(busmap, USB_MAXBUS, 1); 1018 busnum = idr_alloc(&usb_bus_idr, bus, 1, USB_MAXBUS, GFP_KERNEL);
1022 if (busnum >= USB_MAXBUS) { 1019 if (busnum < 0) {
1023 printk (KERN_ERR "%s: too many buses\n", usbcore_name); 1020 pr_err("%s: failed to get bus number\n", usbcore_name);
1024 goto error_find_busnum; 1021 goto error_find_busnum;
1025 } 1022 }
1026 set_bit(busnum, busmap);
1027 bus->busnum = busnum; 1023 bus->busnum = busnum;
1028
1029 /* Add it to the local list of buses */
1030 list_add (&bus->bus_list, &usb_bus_list);
1031 mutex_unlock(&usb_bus_list_lock); 1024 mutex_unlock(&usb_bus_list_lock);
1032 1025
1033 usb_notify_add_bus(bus); 1026 usb_notify_add_bus(bus);
@@ -1059,12 +1052,10 @@ static void usb_deregister_bus (struct usb_bus *bus)
1059 * itself up 1052 * itself up
1060 */ 1053 */
1061 mutex_lock(&usb_bus_list_lock); 1054 mutex_lock(&usb_bus_list_lock);
1062 list_del (&bus->bus_list); 1055 idr_remove(&usb_bus_idr, bus->busnum);
1063 mutex_unlock(&usb_bus_list_lock); 1056 mutex_unlock(&usb_bus_list_lock);
1064 1057
1065 usb_notify_remove_bus(bus); 1058 usb_notify_remove_bus(bus);
1066
1067 clear_bit(bus->busnum, busmap);
1068} 1059}
1069 1060
1070/** 1061/**
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 16ade41759cd..524c9822d2bb 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1115,6 +1115,7 @@ static void __exit usb_exit(void)
1115 bus_unregister(&usb_bus_type); 1115 bus_unregister(&usb_bus_type);
1116 usb_acpi_unregister(); 1116 usb_acpi_unregister();
1117 usb_debugfs_cleanup(); 1117 usb_debugfs_cleanup();
1118 idr_destroy(&usb_bus_idr);
1118} 1119}
1119 1120
1120subsys_initcall(usb_init); 1121subsys_initcall(usb_init);