aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hub.c
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2012-02-20 11:31:26 -0500
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2012-05-18 18:41:54 -0400
commitd9b2099cd66de3164f6e17a5c0e3f14cce24a9a3 (patch)
tree8e83a7b715f1ddbfbf9fb9130c2df4a1d073f180 /drivers/usb/core/hub.c
parent448b6eb1e04cddc418d4b780ae19ca8cdb42d110 (diff)
USB: Refactor code to set LPM support flag.
Refactor the code that sets the usb_device flag to indicate the device support link power management (lpm_capable). The current code sets lpm_capable unconditionally if the USB devices have a USB 2.0 Extended Capabilities Descriptor. USB 3.0 devices can also have that descriptor, but the xHCI driver code that uses lpm_capable will not run the USB 2.0 LPM test for devices under the USB 3.0 roothub. Therefore, it's fine only set lpm_capable for high speed devices in this refactoring. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r--drivers/usb/core/hub.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c8e0704c6e5d..100e08f8a027 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -177,6 +177,21 @@ static struct usb_hub *hdev_to_hub(struct usb_device *hdev)
177 return usb_get_intfdata(hdev->actconfig->interface[0]); 177 return usb_get_intfdata(hdev->actconfig->interface[0]);
178} 178}
179 179
180static int usb_device_supports_lpm(struct usb_device *udev)
181{
182 /* USB 2.1 (and greater) devices indicate LPM support through
183 * their USB 2.0 Extended Capabilities BOS descriptor.
184 */
185 if (udev->speed == USB_SPEED_HIGH) {
186 if (udev->bos->ext_cap &&
187 (USB_LPM_SUPPORT &
188 le32_to_cpu(udev->bos->ext_cap->bmAttributes)))
189 return 1;
190 return 0;
191 }
192 return 0;
193}
194
180/* USB 2.0 spec Section 11.24.4.5 */ 195/* USB 2.0 spec Section 11.24.4.5 */
181static int get_hub_descriptor(struct usb_device *hdev, void *data) 196static int get_hub_descriptor(struct usb_device *hdev, void *data)
182{ 197{
@@ -3211,11 +3226,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
3211 3226
3212 if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) { 3227 if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) {
3213 retval = usb_get_bos_descriptor(udev); 3228 retval = usb_get_bos_descriptor(udev);
3214 if (!retval) { 3229 if (!retval)
3215 if (udev->bos->ext_cap && (USB_LPM_SUPPORT & 3230 udev->lpm_capable = usb_device_supports_lpm(udev);
3216 le32_to_cpu(udev->bos->ext_cap->bmAttributes)))
3217 udev->lpm_capable = 1;
3218 }
3219 } 3231 }
3220 3232
3221 retval = 0; 3233 retval = 0;