diff options
| -rw-r--r-- | drivers/usb/core/hcd.c | 12 | ||||
| -rw-r--r-- | drivers/usb/core/usb.c | 37 | ||||
| -rw-r--r-- | include/linux/usb.h | 4 |
3 files changed, 43 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, | |||
| 1606 | struct usb_interface *new_intf) | 1606 | struct usb_interface *new_intf) |
| 1607 | { | 1607 | { |
| 1608 | int num_intfs, i, j; | 1608 | int num_intfs, i, j; |
| 1609 | struct usb_interface_cache *intf_cache; | ||
| 1610 | struct usb_host_interface *alt = NULL; | 1609 | struct usb_host_interface *alt = NULL; |
| 1611 | int ret = 0; | 1610 | int ret = 0; |
| 1612 | struct usb_hcd *hcd; | 1611 | struct usb_hcd *hcd; |
| @@ -1654,15 +1653,8 @@ int usb_hcd_check_bandwidth(struct usb_device *udev, | |||
| 1654 | } | 1653 | } |
| 1655 | } | 1654 | } |
| 1656 | for (i = 0; i < num_intfs; ++i) { | 1655 | for (i = 0; i < num_intfs; ++i) { |
| 1657 | 1656 | /* Set up endpoints for alternate interface setting 0 */ | |
| 1658 | /* Dig the endpoints for alt setting 0 out of the | 1657 | alt = usb_find_alt_setting(new_config, i, 0); |
| 1659 | * interface cache for this interface | ||
| 1660 | */ | ||
| 1661 | intf_cache = new_config->intf_cache[i]; | ||
| 1662 | for (j = 0; j < intf_cache->num_altsetting; j++) { | ||
| 1663 | if (intf_cache->altsetting[j].desc.bAlternateSetting == 0) | ||
| 1664 | alt = &intf_cache->altsetting[j]; | ||
| 1665 | } | ||
| 1666 | if (!alt) { | 1658 | if (!alt) { |
| 1667 | printk(KERN_DEBUG "Did not find alt setting 0 for intf %d\n", i); | 1659 | printk(KERN_DEBUG "Did not find alt setting 0 for intf %d\n", i); |
| 1668 | continue; | 1660 | continue; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index d1e9440799de..99e54586a545 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -64,6 +64,43 @@ MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); | |||
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | /** | 66 | /** |
| 67 | * usb_find_alt_setting() - Given a configuration, find the alternate setting | ||
| 68 | * for the given interface. | ||
| 69 | * @config - the configuration to search (not necessarily the current config). | ||
| 70 | * @iface_num - interface number to search in | ||
| 71 | * @alt_num - alternate interface setting number to search for. | ||
| 72 | * | ||
| 73 | * Search the configuration's interface cache for the given alt setting. | ||
| 74 | */ | ||
| 75 | struct usb_host_interface *usb_find_alt_setting( | ||
| 76 | struct usb_host_config *config, | ||
| 77 | unsigned int iface_num, | ||
| 78 | unsigned int alt_num) | ||
| 79 | { | ||
| 80 | struct usb_interface_cache *intf_cache = NULL; | ||
| 81 | int i; | ||
| 82 | |||
| 83 | for (i = 0; i < config->desc.bNumInterfaces; i++) { | ||
| 84 | if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber | ||
| 85 | == iface_num) { | ||
| 86 | intf_cache = config->intf_cache[i]; | ||
| 87 | break; | ||
| 88 | } | ||
| 89 | } | ||
| 90 | if (!intf_cache) | ||
| 91 | return NULL; | ||
| 92 | for (i = 0; i < intf_cache->num_altsetting; i++) | ||
| 93 | if (intf_cache->altsetting[i].desc.bAlternateSetting == alt_num) | ||
| 94 | return &intf_cache->altsetting[i]; | ||
| 95 | |||
| 96 | printk(KERN_DEBUG "Did not find alt setting %u for intf %u, " | ||
| 97 | "config %u\n", alt_num, iface_num, | ||
| 98 | config->desc.bConfigurationValue); | ||
| 99 | return NULL; | ||
| 100 | } | ||
| 101 | EXPORT_SYMBOL_GPL(usb_find_alt_setting); | ||
| 102 | |||
| 103 | /** | ||
| 67 | * usb_ifnum_to_if - get the interface object with a given interface number | 104 | * usb_ifnum_to_if - get the interface object with a given interface number |
| 68 | * @dev: the device whose current configuration is considered | 105 | * @dev: the device whose current configuration is considered |
| 69 | * @ifnum: the desired interface | 106 | * @ifnum: the desired interface |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 6af3581e1114..e101a2d04d75 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -619,6 +619,10 @@ extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, | |||
| 619 | unsigned ifnum); | 619 | unsigned ifnum); |
| 620 | extern struct usb_host_interface *usb_altnum_to_altsetting( | 620 | extern struct usb_host_interface *usb_altnum_to_altsetting( |
| 621 | const struct usb_interface *intf, unsigned int altnum); | 621 | const struct usb_interface *intf, unsigned int altnum); |
| 622 | extern struct usb_host_interface *usb_find_alt_setting( | ||
| 623 | struct usb_host_config *config, | ||
| 624 | unsigned int iface_num, | ||
| 625 | unsigned int alt_num); | ||
| 622 | 626 | ||
| 623 | 627 | ||
| 624 | /** | 628 | /** |
