aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hub.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r--drivers/usb/core/hub.c111
1 files changed, 55 insertions, 56 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 2e804a5354c5..6e451ca4c2df 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -120,7 +120,7 @@ static inline char *portspeed(struct usb_hub *hub, int portstatus)
120 if (hub_is_superspeed(hub->hdev)) 120 if (hub_is_superspeed(hub->hdev))
121 return "5.0 Gb/s"; 121 return "5.0 Gb/s";
122 if (portstatus & USB_PORT_STAT_HIGH_SPEED) 122 if (portstatus & USB_PORT_STAT_HIGH_SPEED)
123 return "480 Mb/s"; 123 return "480 Mb/s";
124 else if (portstatus & USB_PORT_STAT_LOW_SPEED) 124 else if (portstatus & USB_PORT_STAT_LOW_SPEED)
125 return "1.5 Mb/s"; 125 return "1.5 Mb/s";
126 else 126 else
@@ -862,7 +862,7 @@ static int hub_hub_status(struct usb_hub *hub,
862 "%s failed (err = %d)\n", __func__, ret); 862 "%s failed (err = %d)\n", __func__, ret);
863 } else { 863 } else {
864 *status = le16_to_cpu(hub->status->hub.wHubStatus); 864 *status = le16_to_cpu(hub->status->hub.wHubStatus);
865 *change = le16_to_cpu(hub->status->hub.wHubChange); 865 *change = le16_to_cpu(hub->status->hub.wHubChange);
866 ret = 0; 866 ret = 0;
867 } 867 }
868 mutex_unlock(&hub->status_mutex); 868 mutex_unlock(&hub->status_mutex);
@@ -961,7 +961,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
961 */ 961 */
962 962
963 set_bit(port1, hub->change_bits); 963 set_bit(port1, hub->change_bits);
964 kick_khubd(hub); 964 kick_khubd(hub);
965} 965}
966 966
967/** 967/**
@@ -1366,7 +1366,7 @@ static int hub_configure(struct usb_hub *hub,
1366 if ((wHubCharacteristics & HUB_CHAR_COMPOUND) && 1366 if ((wHubCharacteristics & HUB_CHAR_COMPOUND) &&
1367 !(hub_is_superspeed(hdev))) { 1367 !(hub_is_superspeed(hdev))) {
1368 int i; 1368 int i;
1369 char portstr [USB_MAXCHILDREN + 1]; 1369 char portstr[USB_MAXCHILDREN + 1];
1370 1370
1371 for (i = 0; i < hdev->maxchild; i++) 1371 for (i = 0; i < hdev->maxchild; i++)
1372 portstr[i] = hub->descriptor->u.hs.DeviceRemovable 1372 portstr[i] = hub->descriptor->u.hs.DeviceRemovable
@@ -1434,32 +1434,32 @@ static int hub_configure(struct usb_hub *hub,
1434 1434
1435 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ 1435 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */
1436 switch (wHubCharacteristics & HUB_CHAR_TTTT) { 1436 switch (wHubCharacteristics & HUB_CHAR_TTTT) {
1437 case HUB_TTTT_8_BITS: 1437 case HUB_TTTT_8_BITS:
1438 if (hdev->descriptor.bDeviceProtocol != 0) { 1438 if (hdev->descriptor.bDeviceProtocol != 0) {
1439 hub->tt.think_time = 666; 1439 hub->tt.think_time = 666;
1440 dev_dbg(hub_dev, "TT requires at most %d "
1441 "FS bit times (%d ns)\n",
1442 8, hub->tt.think_time);
1443 }
1444 break;
1445 case HUB_TTTT_16_BITS:
1446 hub->tt.think_time = 666 * 2;
1447 dev_dbg(hub_dev, "TT requires at most %d "
1448 "FS bit times (%d ns)\n",
1449 16, hub->tt.think_time);
1450 break;
1451 case HUB_TTTT_24_BITS:
1452 hub->tt.think_time = 666 * 3;
1453 dev_dbg(hub_dev, "TT requires at most %d "
1454 "FS bit times (%d ns)\n",
1455 24, hub->tt.think_time);
1456 break;
1457 case HUB_TTTT_32_BITS:
1458 hub->tt.think_time = 666 * 4;
1459 dev_dbg(hub_dev, "TT requires at most %d " 1440 dev_dbg(hub_dev, "TT requires at most %d "
1460 "FS bit times (%d ns)\n", 1441 "FS bit times (%d ns)\n",
1461 32, hub->tt.think_time); 1442 8, hub->tt.think_time);
1462 break; 1443 }
1444 break;
1445 case HUB_TTTT_16_BITS:
1446 hub->tt.think_time = 666 * 2;
1447 dev_dbg(hub_dev, "TT requires at most %d "
1448 "FS bit times (%d ns)\n",
1449 16, hub->tt.think_time);
1450 break;
1451 case HUB_TTTT_24_BITS:
1452 hub->tt.think_time = 666 * 3;
1453 dev_dbg(hub_dev, "TT requires at most %d "
1454 "FS bit times (%d ns)\n",
1455 24, hub->tt.think_time);
1456 break;
1457 case HUB_TTTT_32_BITS:
1458 hub->tt.think_time = 666 * 4;
1459 dev_dbg(hub_dev, "TT requires at most %d "
1460 "FS bit times (%d ns)\n",
1461 32, hub->tt.think_time);
1462 break;
1463 } 1463 }
1464 1464
1465 /* probe() zeroes hub->indicator[] */ 1465 /* probe() zeroes hub->indicator[] */
@@ -1565,7 +1565,7 @@ static int hub_configure(struct usb_hub *hub,
1565 1565
1566 /* maybe cycle the hub leds */ 1566 /* maybe cycle the hub leds */
1567 if (hub->has_indicators && blinkenlights) 1567 if (hub->has_indicators && blinkenlights)
1568 hub->indicator [0] = INDICATOR_CYCLE; 1568 hub->indicator[0] = INDICATOR_CYCLE;
1569 1569
1570 for (i = 0; i < hdev->maxchild; i++) { 1570 for (i = 0; i < hdev->maxchild; i++) {
1571 ret = usb_hub_create_port_device(hub, i + 1); 1571 ret = usb_hub_create_port_device(hub, i + 1);
@@ -1983,7 +1983,7 @@ static void choose_devnum(struct usb_device *udev)
1983 if (devnum >= 128) 1983 if (devnum >= 128)
1984 devnum = find_next_zero_bit(bus->devmap.devicemap, 1984 devnum = find_next_zero_bit(bus->devmap.devicemap,
1985 128, 1); 1985 128, 1);
1986 bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); 1986 bus->devnum_next = (devnum >= 127 ? 1 : devnum + 1);
1987 } 1987 }
1988 if (devnum < 128) { 1988 if (devnum < 128) {
1989 set_bit(devnum, bus->devmap.devicemap); 1989 set_bit(devnum, bus->devmap.devicemap);
@@ -2237,8 +2237,7 @@ static int usb_enumerate_device(struct usb_device *udev)
2237 udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2237 udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2238 udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2238 udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2239 udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2239 udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2240 } 2240 } else {
2241 else {
2242 /* read the standard strings and cache them if present */ 2241 /* read the standard strings and cache them if present */
2243 udev->product = usb_cache_string(udev, udev->descriptor.iProduct); 2242 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2244 udev->manufacturer = usb_cache_string(udev, 2243 udev->manufacturer = usb_cache_string(udev,
@@ -3113,8 +3112,8 @@ static int finish_port_resume(struct usb_device *udev)
3113 retry_reset_resume: 3112 retry_reset_resume:
3114 status = usb_reset_and_verify_device(udev); 3113 status = usb_reset_and_verify_device(udev);
3115 3114
3116 /* 10.5.4.5 says be sure devices in the tree are still there. 3115 /* 10.5.4.5 says be sure devices in the tree are still there.
3117 * For now let's assume the device didn't go crazy on resume, 3116 * For now let's assume the device didn't go crazy on resume,
3118 * and device drivers will know about any resume quirks. 3117 * and device drivers will know about any resume quirks.
3119 */ 3118 */
3120 if (status == 0) { 3119 if (status == 0) {
@@ -3860,7 +3859,7 @@ EXPORT_SYMBOL_GPL(usb_enable_ltm);
3860 * Between connect detection and reset signaling there must be a delay 3859 * Between connect detection and reset signaling there must be a delay
3861 * of 100ms at least for debounce and power-settling. The corresponding 3860 * of 100ms at least for debounce and power-settling. The corresponding
3862 * timer shall restart whenever the downstream port detects a disconnect. 3861 * timer shall restart whenever the downstream port detects a disconnect.
3863 * 3862 *
3864 * Apparently there are some bluetooth and irda-dongles and a number of 3863 * Apparently there are some bluetooth and irda-dongles and a number of
3865 * low-speed devices for which this debounce period may last over a second. 3864 * low-speed devices for which this debounce period may last over a second.
3866 * Not covered by the spec - but easy to deal with. 3865 * Not covered by the spec - but easy to deal with.
@@ -4060,7 +4059,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4060 udev->tt = &hub->tt; 4059 udev->tt = &hub->tt;
4061 udev->ttport = port1; 4060 udev->ttport = port1;
4062 } 4061 }
4063 4062
4064 /* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way? 4063 /* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way?
4065 * Because device hardware and firmware is sometimes buggy in 4064 * Because device hardware and firmware is sometimes buggy in
4066 * this area, and this is how Linux has done it for ages. 4065 * this area, and this is how Linux has done it for ages.
@@ -4135,11 +4134,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4135#undef GET_DESCRIPTOR_BUFSIZE 4134#undef GET_DESCRIPTOR_BUFSIZE
4136 } 4135 }
4137 4136
4138 /* 4137 /*
4139 * If device is WUSB, we already assigned an 4138 * If device is WUSB, we already assigned an
4140 * unauthorized address in the Connect Ack sequence; 4139 * unauthorized address in the Connect Ack sequence;
4141 * authorization will assign the final address. 4140 * authorization will assign the final address.
4142 */ 4141 */
4143 if (udev->wusb == 0) { 4142 if (udev->wusb == 0) {
4144 for (j = 0; j < SET_ADDRESS_TRIES; ++j) { 4143 for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
4145 retval = hub_set_address(udev, devnum); 4144 retval = hub_set_address(udev, devnum);
@@ -4168,7 +4167,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4168 msleep(10); 4167 msleep(10);
4169 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) 4168 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3))
4170 break; 4169 break;
4171 } 4170 }
4172 4171
4173 retval = usb_get_device_descriptor(udev, 8); 4172 retval = usb_get_device_descriptor(udev, 8);
4174 if (retval < 8) { 4173 if (retval < 8) {
@@ -4224,7 +4223,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4224 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i); 4223 udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
4225 usb_ep0_reinit(udev); 4224 usb_ep0_reinit(udev);
4226 } 4225 }
4227 4226
4228 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 4227 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
4229 if (retval < (signed)sizeof(udev->descriptor)) { 4228 if (retval < (signed)sizeof(udev->descriptor)) {
4230 if (retval != -ENODEV) 4229 if (retval != -ENODEV)
@@ -4321,7 +4320,7 @@ hub_power_remaining (struct usb_hub *hub)
4321 } 4320 }
4322 if (remaining < 0) { 4321 if (remaining < 0) {
4323 dev_warn(hub->intfdev, "%dmA over power budget!\n", 4322 dev_warn(hub->intfdev, "%dmA over power budget!\n",
4324 - remaining); 4323 -remaining);
4325 remaining = 0; 4324 remaining = 0;
4326 } 4325 }
4327 return remaining; 4326 return remaining;
@@ -4432,7 +4431,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4432 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 4431 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
4433 4432
4434 if (portstatus & USB_PORT_STAT_ENABLE) 4433 if (portstatus & USB_PORT_STAT_ENABLE)
4435 goto done; 4434 goto done;
4436 return; 4435 return;
4437 } 4436 }
4438 if (hub_is_superspeed(hub->hdev)) 4437 if (hub_is_superspeed(hub->hdev))
@@ -4455,7 +4454,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4455 } 4454 }
4456 4455
4457 usb_set_device_state(udev, USB_STATE_POWERED); 4456 usb_set_device_state(udev, USB_STATE_POWERED);
4458 udev->bus_mA = hub->mA_per_port; 4457 udev->bus_mA = hub->mA_per_port;
4459 udev->level = hdev->level + 1; 4458 udev->level = hdev->level + 1;
4460 udev->wusb = hub_is_wusb(hub); 4459 udev->wusb = hub_is_wusb(hub);
4461 4460
@@ -4509,7 +4508,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4509 goto loop_disable; 4508 goto loop_disable;
4510 } 4509 }
4511 } 4510 }
4512 4511
4513 /* check for devices running slower than they could */ 4512 /* check for devices running slower than they could */
4514 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200 4513 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0200
4515 && udev->speed == USB_SPEED_FULL 4514 && udev->speed == USB_SPEED_FULL
@@ -4569,7 +4568,7 @@ loop:
4569 dev_err(hub_dev, "unable to enumerate USB device on port %d\n", 4568 dev_err(hub_dev, "unable to enumerate USB device on port %d\n",
4570 port1); 4569 port1);
4571 } 4570 }
4572 4571
4573done: 4572done:
4574 hub_port_disable(hub, port1, 1); 4573 hub_port_disable(hub, port1, 1);
4575 if (hcd->driver->relinquish_port && !hub->hdev->parent) 4574 if (hcd->driver->relinquish_port && !hub->hdev->parent)
@@ -4734,7 +4733,7 @@ static void hub_events(void)
4734 * EM interference sometimes causes badly 4733 * EM interference sometimes causes badly
4735 * shielded USB devices to be shutdown by 4734 * shielded USB devices to be shutdown by
4736 * the hub, this hack enables them again. 4735 * the hub, this hack enables them again.
4737 * Works at least with mouse driver. 4736 * Works at least with mouse driver.
4738 */ 4737 */
4739 if (!(portstatus & USB_PORT_STAT_ENABLE) 4738 if (!(portstatus & USB_PORT_STAT_ENABLE)
4740 && !connect_change 4739 && !connect_change
@@ -4846,7 +4845,7 @@ static void hub_events(void)
4846 dev_dbg(hub_dev, "over-current change\n"); 4845 dev_dbg(hub_dev, "over-current change\n");
4847 clear_hub_feature(hdev, C_HUB_OVER_CURRENT); 4846 clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
4848 msleep(500); /* Cool down */ 4847 msleep(500); /* Cool down */
4849 hub_power_on(hub, true); 4848 hub_power_on(hub, true);
4850 hub_hub_status(hub, &status, &unused); 4849 hub_hub_status(hub, &status, &unused);
4851 if (status & HUB_STATUS_OVERCURRENT) 4850 if (status & HUB_STATUS_OVERCURRENT)
4852 dev_err(hub_dev, "over-current " 4851 dev_err(hub_dev, "over-current "
@@ -4866,7 +4865,7 @@ static void hub_events(void)
4866 usb_unlock_device(hdev); 4865 usb_unlock_device(hdev);
4867 kref_put(&hub->kref, hub_release); 4866 kref_put(&hub->kref, hub_release);
4868 4867
4869 } /* end while (1) */ 4868 } /* end while (1) */
4870} 4869}
4871 4870
4872static int hub_thread(void *__unused) 4871static int hub_thread(void *__unused)
@@ -4891,7 +4890,7 @@ static int hub_thread(void *__unused)
4891 4890
4892static const struct usb_device_id hub_id_table[] = { 4891static const struct usb_device_id hub_id_table[] = {
4893 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 4892 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR
4894 | USB_DEVICE_ID_MATCH_INT_CLASS, 4893 | USB_DEVICE_ID_MATCH_INT_CLASS,
4895 .idVendor = USB_VENDOR_GENESYS_LOGIC, 4894 .idVendor = USB_VENDOR_GENESYS_LOGIC,
4896 .bInterfaceClass = USB_CLASS_HUB, 4895 .bInterfaceClass = USB_CLASS_HUB,
4897 .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND}, 4896 .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND},
@@ -5125,13 +5124,13 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
5125 5124
5126 if (ret < 0) 5125 if (ret < 0)
5127 goto re_enumerate; 5126 goto re_enumerate;
5128 5127
5129 /* Device might have changed firmware (DFU or similar) */ 5128 /* Device might have changed firmware (DFU or similar) */
5130 if (descriptors_changed(udev, &descriptor, bos)) { 5129 if (descriptors_changed(udev, &descriptor, bos)) {
5131 dev_info(&udev->dev, "device firmware changed\n"); 5130 dev_info(&udev->dev, "device firmware changed\n");
5132 udev->descriptor = descriptor; /* for disconnect() calls */ 5131 udev->descriptor = descriptor; /* for disconnect() calls */
5133 goto re_enumerate; 5132 goto re_enumerate;
5134 } 5133 }
5135 5134
5136 /* Restore the device's previous configuration */ 5135 /* Restore the device's previous configuration */
5137 if (!udev->actconfig) 5136 if (!udev->actconfig)
@@ -5156,7 +5155,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
5156 udev->actconfig->desc.bConfigurationValue, ret); 5155 udev->actconfig->desc.bConfigurationValue, ret);
5157 mutex_unlock(hcd->bandwidth_mutex); 5156 mutex_unlock(hcd->bandwidth_mutex);
5158 goto re_enumerate; 5157 goto re_enumerate;
5159 } 5158 }
5160 mutex_unlock(hcd->bandwidth_mutex); 5159 mutex_unlock(hcd->bandwidth_mutex);
5161 usb_set_device_state(udev, USB_STATE_CONFIGURED); 5160 usb_set_device_state(udev, USB_STATE_CONFIGURED);
5162 5161
@@ -5203,7 +5202,7 @@ done:
5203 usb_release_bos_descriptor(udev); 5202 usb_release_bos_descriptor(udev);
5204 udev->bos = bos; 5203 udev->bos = bos;
5205 return 0; 5204 return 0;
5206 5205
5207re_enumerate: 5206re_enumerate:
5208 /* LPM state doesn't matter when we're about to destroy the device. */ 5207 /* LPM state doesn't matter when we're about to destroy the device. */
5209 hub_port_logical_disconnect(parent_hub, port1); 5208 hub_port_logical_disconnect(parent_hub, port1);