summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hcd.c
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-12-03 18:44:34 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 20:55:27 +0100
commit91017f9cf5fcfb601b8d583c896ac7de7d200c57 (patch)
treeca601c606ded366e14df0ac019ecd4c43c5b11d9 /drivers/usb/core/hcd.c
parentUSB: xhci: Fix command completion after a drop endpoint. (diff)
downloadlinux-91017f9cf5fcfb601b8d583c896ac7de7d200c57.tar.xz
linux-91017f9cf5fcfb601b8d583c896ac7de7d200c57.zip
USB: Refactor code to find alternate interface settings.
Refactor out the code to find alternate interface settings into usb_find_alt_setting(). Print a debugging message and return null if the alt setting is not found. While we're at it, correct a bug in the refactored code. The interfaces in the configuration's interface cache are not necessarily in numerical order, so we can't just use the interface number as an array index. Loop through the interface caches, looking for the correct interface. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/hcd.c')
-rw-r--r--drivers/usb/core/hcd.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index daac0427bfd5..fc235b02ff27 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1606,7 +1606,6 @@ int usb_hcd_check_bandwidth(struct usb_device *udev,
struct usb_interface *new_intf)
{
int num_intfs, i, j;
- struct usb_interface_cache *intf_cache;
struct usb_host_interface *alt = NULL;
int ret = 0;
struct usb_hcd *hcd;
@@ -1654,15 +1653,8 @@ int usb_hcd_check_bandwidth(struct usb_device *udev,
}
}
for (i = 0; i < num_intfs; ++i) {
-
- /* Dig the endpoints for alt setting 0 out of the
- * interface cache for this interface
- */
- intf_cache = new_config->intf_cache[i];
- for (j = 0; j < intf_cache->num_altsetting; j++) {
- if (intf_cache->altsetting[j].desc.bAlternateSetting == 0)
- alt = &intf_cache->altsetting[j];
- }
+ /* Set up endpoints for alternate interface setting 0 */
+ alt = usb_find_alt_setting(new_config, i, 0);
if (!alt) {
printk(KERN_DEBUG "Did not find alt setting 0 for intf %d\n", i);
continue;