Lines Matching full:hub

3  * USB hub driver.
38 #include "hub.h"
58 /* workqueue to process hub events */
62 /* synchronize hub-port add/remove and peering operations */
90 * hub driver's behavior. On the first initialization attempt, if the
118 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
119 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
122 static inline char *portspeed(struct usb_hub *hub, int portstatus) in portspeed() argument
124 if (hub_is_superspeedplus(hub->hdev)) in portspeed()
126 if (hub_is_superspeed(hub->hdev)) in portspeed()
193 struct usb_hub *hub, in usb_set_lpm_mel() argument
203 * and the hub header decode latency. See USB 3.1 section C 2.2.1 in usb_set_lpm_mel()
208 hub->descriptor->u.ss.bHubHdrDecLat * 100; in usb_set_lpm_mel()
212 * each link + wHubDelay for each hub. Add only for last link. in usb_set_lpm_mel()
216 total_mel += (__le16_to_cpu(hub->descriptor->u.ss.wHubDelay) + in usb_set_lpm_mel()
227 if (!hub->hdev->parent) in usb_set_lpm_mel()
240 struct usb_hub *hub, in usb_set_lpm_pel() argument
250 * device and the parent hub into U0. The exit latency is the bigger of in usb_set_lpm_pel()
251 * the device exit latency or the hub exit latency. in usb_set_lpm_pel()
259 * When the hub starts to receive the LFPS, there is a slight delay for in usb_set_lpm_pel()
262 * delay, plus the PEL that we calculated for this hub. in usb_set_lpm_pel()
316 struct usb_hub *hub; in usb_set_lpm_parameters() local
326 hub = usb_hub_to_struct_hub(udev->parent); in usb_set_lpm_parameters()
330 if (!hub) in usb_set_lpm_parameters()
339 hub, &udev->parent->u1_params, hub_u1_del); in usb_set_lpm_parameters()
342 hub, &udev->parent->u2_params, hub_u2_del); in usb_set_lpm_parameters()
346 * when the parent hub notices the downstream port is trying to in usb_set_lpm_parameters()
347 * transition to U0 to when the hub initiates a U0 transition on its in usb_set_lpm_parameters()
351 * The hub chapter, sections 10.4.2.4 and 10.4.2.5 seem to be talking in usb_set_lpm_parameters()
355 * assume the device exit latencies they are talking about are the hub in usb_set_lpm_parameters()
364 hub, &udev->parent->u1_params, hub_u1_del, in usb_set_lpm_parameters()
373 hub, &udev->parent->u2_params, hub_u2_del, in usb_set_lpm_parameters()
464 static void set_port_led(struct usb_hub *hub, int port1, int selector) in set_port_led() argument
466 struct usb_port *port_dev = hub->ports[port1 - 1]; in set_port_led()
469 status = set_port_feature(hub->hdev, (selector << 8) | port1, in set_port_led()
479 struct usb_hub *hub = in led_work() local
481 struct usb_device *hdev = hub->hdev; in led_work()
486 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) in led_work()
494 switch (hub->indicator[i]) { in led_work()
533 set_port_led(hub, i + 1, selector); in led_work()
534 hub->indicator[i] = mode; in led_work()
539 set_port_led(hub, cursor + 1, HUB_LED_GREEN); in led_work()
540 hub->indicator[cursor] = INDICATOR_CYCLE; in led_work()
545 &hub->leds, LED_CYCLE_PERIOD); in led_work()
548 /* use a short timeout for hub/port status fetches */
587 static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, in hub_ext_port_status() argument
596 mutex_lock(&hub->status_mutex); in hub_ext_port_status()
597 ret = get_port_status(hub->hdev, port1, &hub->status->port, type, len); in hub_ext_port_status()
600 dev_err(hub->intfdev, in hub_ext_port_status()
605 *status = le16_to_cpu(hub->status->port.wPortStatus); in hub_ext_port_status()
606 *change = le16_to_cpu(hub->status->port.wPortChange); in hub_ext_port_status()
609 hub->status->port.dwExtPortStatus); in hub_ext_port_status()
612 mutex_unlock(&hub->status_mutex); in hub_ext_port_status()
616 static int hub_port_status(struct usb_hub *hub, int port1, in hub_port_status() argument
619 return hub_ext_port_status(hub, port1, HUB_PORT_STATUS, in hub_port_status()
623 static void hub_resubmit_irq_urb(struct usb_hub *hub) in hub_resubmit_irq_urb() argument
628 spin_lock_irqsave(&hub->irq_urb_lock, flags); in hub_resubmit_irq_urb()
630 if (hub->quiescing) { in hub_resubmit_irq_urb()
631 spin_unlock_irqrestore(&hub->irq_urb_lock, flags); in hub_resubmit_irq_urb()
635 status = usb_submit_urb(hub->urb, GFP_ATOMIC); in hub_resubmit_irq_urb()
638 dev_err(hub->intfdev, "resubmit --> %d\n", status); in hub_resubmit_irq_urb()
639 mod_timer(&hub->irq_urb_retry, jiffies + HZ); in hub_resubmit_irq_urb()
642 spin_unlock_irqrestore(&hub->irq_urb_lock, flags); in hub_resubmit_irq_urb()
647 struct usb_hub *hub = from_timer(hub, t, irq_urb_retry); in hub_retry_irq_urb() local
649 hub_resubmit_irq_urb(hub); in hub_retry_irq_urb()
653 static void kick_hub_wq(struct usb_hub *hub) in kick_hub_wq() argument
657 if (hub->disconnected || work_pending(&hub->events)) in kick_hub_wq()
665 * work for this hub. Therefore put the interface either when in kick_hub_wq()
668 intf = to_usb_interface(hub->intfdev); in kick_hub_wq()
670 kref_get(&hub->kref); in kick_hub_wq()
672 if (queue_work(hub_wq, &hub->events)) in kick_hub_wq()
677 kref_put(&hub->kref, hub_release); in kick_hub_wq()
682 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_kick_hub_wq() local
684 if (hub) in usb_kick_hub_wq()
685 kick_hub_wq(hub); in usb_kick_hub_wq()
694 * resume through the normal hub interrupt URB.
699 struct usb_hub *hub; in usb_wakeup_notification() local
705 hub = usb_hub_to_struct_hub(hdev); in usb_wakeup_notification()
706 if (hub) { in usb_wakeup_notification()
707 port_dev = hub->ports[portnum - 1]; in usb_wakeup_notification()
711 set_bit(portnum, hub->wakeup_bits); in usb_wakeup_notification()
712 kick_hub_wq(hub); in usb_wakeup_notification()
720 struct usb_hub *hub = urb->context; in hub_irq() local
732 /* Cause a hub reset after 10 consecutive errors */ in hub_irq()
733 dev_dbg(hub->intfdev, "transfer --> %d\n", status); in hub_irq()
734 if ((++hub->nerrors < 10) || hub->error) in hub_irq()
736 hub->error = status; in hub_irq()
743 bits |= ((unsigned long) ((*hub->buffer)[i])) in hub_irq()
745 hub->event_bits[0] = bits; in hub_irq()
749 hub->nerrors = 0; in hub_irq()
752 kick_hub_wq(hub); in hub_irq()
755 hub_resubmit_irq_urb(hub); in hub_irq()
780 * both can talk to the same hub concurrently.
784 struct usb_hub *hub = in hub_tt_work() local
788 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
789 while (!list_empty(&hub->tt.clear_list)) { in hub_tt_work()
792 struct usb_device *hdev = hub->hdev; in hub_tt_work()
796 next = hub->tt.clear_list.next; in hub_tt_work()
801 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
814 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
816 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
820 * usb_hub_set_port_power - control hub port's power state
821 * @hdev: USB device belonging to the usb hub
822 * @hub: target hub
831 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, in usb_hub_set_port_power() argument
845 set_bit(port1, hub->power_bits); in usb_hub_set_port_power()
847 clear_bit(port1, hub->power_bits); in usb_hub_set_port_power()
852 * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub
855 * High speed HCDs use this to tell the hub driver that some split control or
860 * It may not be possible for that hub to handle additional full (or low)
875 * there can be many TTs per hub). even if they're uncommon. in usb_hub_clear_tt_buffer()
907 static void hub_power_on(struct usb_hub *hub, bool do_delay) in hub_power_on() argument
915 * unless we send these messages to the hub. in hub_power_on()
917 if (hub_is_port_power_switchable(hub)) in hub_power_on()
918 dev_dbg(hub->intfdev, "enabling power on all ports\n"); in hub_power_on()
920 dev_dbg(hub->intfdev, "trying to enable port power on " in hub_power_on()
921 "non-switchable hub\n"); in hub_power_on()
922 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) in hub_power_on()
923 if (test_bit(port1, hub->power_bits)) in hub_power_on()
924 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); in hub_power_on()
926 usb_clear_port_feature(hub->hdev, port1, in hub_power_on()
929 msleep(hub_power_on_good_delay(hub)); in hub_power_on()
932 static int hub_hub_status(struct usb_hub *hub, in hub_hub_status() argument
937 mutex_lock(&hub->status_mutex); in hub_hub_status()
938 ret = get_hub_status(hub->hdev, &hub->status->hub); in hub_hub_status()
941 dev_err(hub->intfdev, in hub_hub_status()
944 *status = le16_to_cpu(hub->status->hub.wHubStatus); in hub_hub_status()
945 *change = le16_to_cpu(hub->status->hub.wHubChange); in hub_hub_status()
948 mutex_unlock(&hub->status_mutex); in hub_hub_status()
952 static int hub_set_port_link_state(struct usb_hub *hub, int port1, in hub_set_port_link_state() argument
955 return set_port_feature(hub->hdev, in hub_set_port_link_state()
965 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) in hub_port_logical_disconnect() argument
967 dev_dbg(&hub->ports[port1 - 1]->dev, "logical disconnect\n"); in hub_port_logical_disconnect()
968 hub_port_disable(hub, port1, 1); in hub_port_logical_disconnect()
974 * That's easy if this hub can switch power per-port, and in hub_port_logical_disconnect()
979 set_bit(port1, hub->change_bits); in hub_port_logical_disconnect()
980 kick_hub_wq(hub); in hub_port_logical_disconnect()
984 * usb_remove_device - disable a device's port on its parent hub
997 struct usb_hub *hub; in usb_remove_device() local
1001 if (!udev->parent) /* Can't remove a root hub */ in usb_remove_device()
1003 hub = usb_hub_to_struct_hub(udev->parent); in usb_remove_device()
1004 intf = to_usb_interface(hub->intfdev); in usb_remove_device()
1010 set_bit(udev->portnum, hub->removed_bits); in usb_remove_device()
1011 hub_port_logical_disconnect(hub, udev->portnum); in usb_remove_device()
1024 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) in hub_activate() argument
1026 struct usb_device *hdev = hub->hdev; in hub_activate()
1038 /* Was the hub disconnected while we were waiting? */ in hub_activate()
1039 if (hub->disconnected) in hub_activate()
1045 kref_get(&hub->kref); in hub_activate()
1047 /* The superspeed hub except for root hub has to use Hub Depth in hub_activate()
1049 * it uses to determine the downstream port number. So hub driver in hub_activate()
1050 * should send a set hub depth request to superspeed hub after in hub_activate()
1051 * the superspeed hub is set configuration in initialization or in hub_activate()
1064 dev_err(hub->intfdev, in hub_activate()
1065 "set hub depth failed\n"); in hub_activate()
1069 * hub's initial power-up delays. This is pretty awkward in hub_activate()
1072 * root hub (assuming usbcore is compiled into the kernel in hub_activate()
1081 delay = hub_power_on_good_delay(hub); in hub_activate()
1083 hub_power_on(hub, false); in hub_activate()
1084 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); in hub_activate()
1086 &hub->init_work, in hub_activate()
1091 to_usb_interface(hub->intfdev)); in hub_activate()
1094 /* The internal host controller state for the hub device in hub_activate()
1096 * Update the device's info so the HW knows it's a hub. in hub_activate()
1101 &hub->tt, GFP_NOIO); in hub_activate()
1103 dev_err(hub->intfdev, in hub_activate()
1104 "Host not accepting hub info update\n"); in hub_activate()
1105 dev_err(hub->intfdev, in hub_activate()
1106 "LS/FS devices and hubs may not work under this hub\n"); in hub_activate()
1109 hub_power_on(hub, true); in hub_activate()
1111 hub_power_on(hub, true); in hub_activate()
1117 * Check each port and set hub->change_bits to let hub_wq know in hub_activate()
1121 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_activate()
1126 status = hub_port_status(hub, port1, &portstatus, &portchange); in hub_activate()
1159 hub_port_warm_reset_required(hub, port1, portstatus)) in hub_activate()
1160 set_bit(port1, hub->event_bits); in hub_activate()
1175 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1180 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1185 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1189 hub_is_superspeed(hub->hdev)) { in hub_activate()
1191 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1199 clear_bit(port1, hub->removed_bits); in hub_activate()
1212 set_bit(port1, hub->change_bits); in hub_activate()
1226 if (portchange || (hub_is_superspeed(hub->hdev) && in hub_activate()
1228 set_bit(port1, hub->change_bits); in hub_activate()
1237 if (test_bit(port1, hub->power_bits)) in hub_activate()
1238 set_bit(port1, hub->change_bits); in hub_activate()
1243 set_bit(port1, hub->change_bits); in hub_activate()
1260 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); in hub_activate()
1262 &hub->init_work, in hub_activate()
1271 hub->quiescing = 0; in hub_activate()
1273 status = usb_submit_urb(hub->urb, GFP_NOIO); in hub_activate()
1275 dev_err(hub->intfdev, "activate --> %d\n", status); in hub_activate()
1276 if (hub->has_indicators && blinkenlights) in hub_activate()
1278 &hub->leds, LED_CYCLE_PERIOD); in hub_activate()
1281 kick_hub_wq(hub); in hub_activate()
1286 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); in hub_activate()
1290 kref_put(&hub->kref, hub_release); in hub_activate()
1296 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func2() local
1298 hub_activate(hub, HUB_INIT2); in hub_init_func2()
1303 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func3() local
1305 hub_activate(hub, HUB_INIT3); in hub_init_func3()
1312 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) in hub_quiesce() argument
1314 struct usb_device *hdev = hub->hdev; in hub_quiesce()
1319 spin_lock_irqsave(&hub->irq_urb_lock, flags); in hub_quiesce()
1320 hub->quiescing = 1; in hub_quiesce()
1321 spin_unlock_irqrestore(&hub->irq_urb_lock, flags); in hub_quiesce()
1326 if (hub->ports[i]->child) in hub_quiesce()
1327 usb_disconnect(&hub->ports[i]->child); in hub_quiesce()
1332 del_timer_sync(&hub->irq_urb_retry); in hub_quiesce()
1333 usb_kill_urb(hub->urb); in hub_quiesce()
1334 if (hub->has_indicators) in hub_quiesce()
1335 cancel_delayed_work_sync(&hub->leds); in hub_quiesce()
1336 if (hub->tt.hub) in hub_quiesce()
1337 flush_work(&hub->tt.clear_work); in hub_quiesce()
1340 static void hub_pm_barrier_for_all_ports(struct usb_hub *hub) in hub_pm_barrier_for_all_ports() argument
1344 for (i = 0; i < hub->hdev->maxchild; ++i) in hub_pm_barrier_for_all_ports()
1345 pm_runtime_barrier(&hub->ports[i]->dev); in hub_pm_barrier_for_all_ports()
1348 /* caller has locked the hub device */
1351 struct usb_hub *hub = usb_get_intfdata(intf); in hub_pre_reset() local
1353 hub_quiesce(hub, HUB_PRE_RESET); in hub_pre_reset()
1354 hub->in_reset = 1; in hub_pre_reset()
1355 hub_pm_barrier_for_all_ports(hub); in hub_pre_reset()
1359 /* caller has locked the hub device */
1362 struct usb_hub *hub = usb_get_intfdata(intf); in hub_post_reset() local
1364 hub->in_reset = 0; in hub_post_reset()
1365 hub_pm_barrier_for_all_ports(hub); in hub_post_reset()
1366 hub_activate(hub, HUB_POST_RESET); in hub_post_reset()
1370 static int hub_configure(struct usb_hub *hub, in hub_configure() argument
1374 struct usb_device *hdev = hub->hdev; in hub_configure()
1375 struct device *hub_dev = hub->intfdev; in hub_configure()
1385 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); in hub_configure()
1386 if (!hub->buffer) { in hub_configure()
1391 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); in hub_configure()
1392 if (!hub->status) { in hub_configure()
1396 mutex_init(&hub->status_mutex); in hub_configure()
1398 hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_KERNEL); in hub_configure()
1399 if (!hub->descriptor) { in hub_configure()
1404 /* Request the entire hub descriptor. in hub_configure()
1405 * hub->descriptor can handle USB_MAXCHILDREN ports, in hub_configure()
1406 * but a (non-SS) hub can/will return fewer bytes here. in hub_configure()
1408 ret = get_hub_descriptor(hdev, hub->descriptor); in hub_configure()
1410 message = "can't read hub descriptor"; in hub_configure()
1418 if (hub->descriptor->bNbrPorts > maxchild) { in hub_configure()
1419 message = "hub has too many ports!"; in hub_configure()
1422 } else if (hub->descriptor->bNbrPorts == 0) { in hub_configure()
1423 message = "hub doesn't have any ports!"; in hub_configure()
1429 * Accumulate wHubDelay + 40ns for every hub in the tree of devices. in hub_configure()
1433 u32 delay = __le16_to_cpu(hub->descriptor->u.ss.wHubDelay); in hub_configure()
1442 maxchild = hub->descriptor->bNbrPorts; in hub_configure()
1446 hub->ports = kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL); in hub_configure()
1447 if (!hub->ports) { in hub_configure()
1452 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in hub_configure()
1467 portstr[i] = hub->descriptor->u.hs.DeviceRemovable in hub_configure()
1473 dev_dbg(hub_dev, "standalone hub\n"); in hub_configure()
1501 spin_lock_init(&hub->tt.lock); in hub_configure()
1502 INIT_LIST_HEAD(&hub->tt.clear_list); in hub_configure()
1503 INIT_WORK(&hub->tt.clear_work, hub_tt_work); in hub_configure()
1509 hub->tt.hub = hdev; in hub_configure()
1515 hub->tt.multi = 1; in hub_configure()
1519 hub->tt.hub = hdev; in hub_configure()
1525 dev_dbg(hub_dev, "Unrecognized hub protocol %d\n", in hub_configure()
1534 hub->tt.think_time = 666; in hub_configure()
1537 8, hub->tt.think_time); in hub_configure()
1541 hub->tt.think_time = 666 * 2; in hub_configure()
1544 16, hub->tt.think_time); in hub_configure()
1547 hub->tt.think_time = 666 * 3; in hub_configure()
1550 24, hub->tt.think_time); in hub_configure()
1553 hub->tt.think_time = 666 * 4; in hub_configure()
1556 32, hub->tt.think_time); in hub_configure()
1560 /* probe() zeroes hub->indicator[] */ in hub_configure()
1562 hub->has_indicators = 1; in hub_configure()
1567 hub->descriptor->bPwrOn2PwrGood * 2); in hub_configure()
1574 message = "can't get hub status"; in hub_configure()
1584 hub->mA_per_port = full_load; in hub_configure()
1586 hub->mA_per_port = hdev->bus_mA; in hub_configure()
1587 hub->limited_power = 1; in hub_configure()
1591 hub->descriptor->bHubContrCurrent; in hub_configure()
1593 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", in hub_configure()
1594 hub->descriptor->bHubContrCurrent); in hub_configure()
1595 hub->limited_power = 1; in hub_configure()
1601 hub->mA_per_port = unit_load; /* 7.2.1 */ in hub_configure()
1603 } else { /* Self-powered external hub */ in hub_configure()
1606 hub->mA_per_port = full_load; in hub_configure()
1608 if (hub->mA_per_port < full_load) in hub_configure()
1610 hub->mA_per_port); in hub_configure()
1612 ret = hub_hub_status(hub, &hubstatus, &hubchange); in hub_configure()
1614 message = "can't get hub status"; in hub_configure()
1637 if (maxp > sizeof(*hub->buffer)) in hub_configure()
1638 maxp = sizeof(*hub->buffer); in hub_configure()
1640 hub->urb = usb_alloc_urb(0, GFP_KERNEL); in hub_configure()
1641 if (!hub->urb) { in hub_configure()
1646 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, in hub_configure()
1647 hub, endpoint->bInterval); in hub_configure()
1649 /* maybe cycle the hub leds */ in hub_configure()
1650 if (hub->has_indicators && blinkenlights) in hub_configure()
1651 hub->indicator[0] = INDICATOR_CYCLE; in hub_configure()
1655 ret = usb_hub_create_port_device(hub, i + 1); in hub_configure()
1657 dev_err(hub->intfdev, in hub_configure()
1664 struct usb_port *port_dev = hub->ports[i]; in hub_configure()
1673 /* Update the HCD's internal representation of this hub before hub_wq in hub_configure()
1674 * starts getting port status changes for devices under the hub. in hub_configure()
1678 &hub->tt, GFP_KERNEL); in hub_configure()
1680 message = "can't update HCD hub info"; in hub_configure()
1685 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); in hub_configure()
1687 hub_activate(hub, HUB_INIT); in hub_configure()
1699 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); in hub_release() local
1701 usb_put_dev(hub->hdev); in hub_release()
1702 usb_put_intf(to_usb_interface(hub->intfdev)); in hub_release()
1703 kfree(hub); in hub_release()
1710 struct usb_hub *hub = usb_get_intfdata(intf); in hub_disconnect() local
1715 * Stop adding new hub events. We do not want to block here and thus in hub_disconnect()
1718 hub->disconnected = 1; in hub_disconnect()
1720 /* Disconnect all children and quiesce the hub */ in hub_disconnect()
1721 hub->error = 0; in hub_disconnect()
1722 hub_quiesce(hub, HUB_DISCONNECT); in hub_disconnect()
1734 usb_hub_remove_port_device(hub, port1); in hub_disconnect()
1738 if (hub->hdev->speed == USB_SPEED_HIGH) in hub_disconnect()
1741 usb_free_urb(hub->urb); in hub_disconnect()
1742 kfree(hub->ports); in hub_disconnect()
1743 kfree(hub->descriptor); in hub_disconnect()
1744 kfree(hub->status); in hub_disconnect()
1745 kfree(hub->buffer); in hub_disconnect()
1749 if (hub->quirk_disable_autosuspend) in hub_disconnect()
1752 kref_put(&hub->kref, hub_release); in hub_disconnect()
1763 /* Multiple endpoints? What kind of mutant ninja-hub is this? */ in hub_descriptor_is_sane()
1778 struct usb_hub *hub; in hub_probe() local
1787 * - Unlike other drivers, the hub driver does not rely on the in hub_probe()
1790 * change on hub downstream ports, so it is safe to do it. in hub_probe()
1793 * below very rare devices when they are plugged into hub in hub_probe()
1804 * autosuspend delay of their parent hub in the probe() to one in hub_probe()
1809 * hub during running 'lsusb', but it is probably too in hub_probe()
1812 * - Change autosuspend delay of hub can avoid unnecessary auto in hub_probe()
1813 * suspend timer for hub, also may decrease power consumption in hub_probe()
1831 } else { /* root hub */ in hub_probe()
1840 "Unsupported bus topology: hub nested too deep\n"); in hub_probe()
1846 dev_warn(&intf->dev, "ignoring external hub\n"); in hub_probe()
1852 dev_err(&intf->dev, "bad descriptor, ignoring hub\n"); in hub_probe()
1856 /* We found a hub */ in hub_probe()
1857 dev_info(&intf->dev, "USB hub found\n"); in hub_probe()
1859 hub = kzalloc(sizeof(*hub), GFP_KERNEL); in hub_probe()
1860 if (!hub) in hub_probe()
1863 kref_init(&hub->kref); in hub_probe()
1864 hub->intfdev = &intf->dev; in hub_probe()
1865 hub->hdev = hdev; in hub_probe()
1866 INIT_DELAYED_WORK(&hub->leds, led_work); in hub_probe()
1867 INIT_DELAYED_WORK(&hub->init_work, NULL); in hub_probe()
1868 INIT_WORK(&hub->events, hub_event); in hub_probe()
1869 spin_lock_init(&hub->irq_urb_lock); in hub_probe()
1870 timer_setup(&hub->irq_urb_retry, hub_retry_irq_urb, 0); in hub_probe()
1874 usb_set_intfdata(intf, hub); in hub_probe()
1882 hub->quirk_check_port_auto_suspend = 1; in hub_probe()
1885 hub->quirk_disable_autosuspend = 1; in hub_probe()
1889 if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) in hub_probe()
1900 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in hub_ioctl() local
1902 /* assert ifno == 0 (part of hub spec) */ in hub_ioctl()
1914 if (hub->ports[i]->child == NULL) in hub_ioctl()
1918 hub->ports[i]->child->devnum; in hub_ioctl()
1932 * Allow user programs to claim ports on a hub. When a device is attached
1938 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in find_port_owner() local
1945 /* Devices not managed by the hub driver in find_port_owner()
1948 *ppowner = &(hub->ports[port1 - 1]->port_owner); in find_port_owner()
1987 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_release_all_ports() local
1991 if (hub->ports[n]->port_owner == owner) in usb_hub_release_all_ports()
1992 hub->ports[n]->port_owner = NULL; in usb_hub_release_all_ports()
2000 struct usb_hub *hub; in usb_device_is_owned() local
2004 hub = usb_hub_to_struct_hub(udev->parent); in usb_device_is_owned()
2005 return !!hub->ports[udev->portnum - 1]->port_owner; in usb_device_is_owned()
2010 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in recursively_mark_NOTATTACHED() local
2014 if (hub->ports[i]->child) in recursively_mark_NOTATTACHED()
2015 recursively_mark_NOTATTACHED(hub->ports[i]->child); in recursively_mark_NOTATTACHED()
2054 /* root hub wakeup capabilities are managed out-of-band in usb_set_device_state()
2105 * uses always #1 for the root hub of the controller. So USB stack's
2118 /* be safe when more hub events are proceed in parallel */ in choose_devnum()
2168 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in hub_disconnect_children() local
2173 if (hub->ports[i]->child) in hub_disconnect_children()
2174 usb_disconnect(&hub->ports[i]->child); in hub_disconnect_children()
2186 * If *pdev is a normal device then the parent hub must already be locked.
2187 * If *pdev is a root hub then the caller must hold the usb_bus_idr_lock,
2190 * Only hub drivers (including virtual root hub drivers for host
2199 struct usb_hub *hub = NULL; in usb_disconnect() local
2230 hub = usb_hub_to_struct_hub(udev->parent); in usb_disconnect()
2231 port_dev = hub->ports[port1 - 1]; in usb_disconnect()
2240 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2263 if (port_dev && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2436 struct usb_hub *hub; in set_usb_port_removable() local
2446 hub = usb_hub_to_struct_hub(udev->parent); in set_usb_port_removable()
2452 switch (hub->ports[udev->portnum - 1]->connect_type) { in set_usb_port_removable()
2465 * Otherwise, check whether the hub knows whether a port is removable in set_usb_port_removable()
2468 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in set_usb_port_removable()
2474 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) in set_usb_port_removable()
2478 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) in set_usb_port_removable()
2496 * the parent hub (if udev is a normal device) or else the
2497 * usb_bus_idr_lock (if udev is a root hub). The parent's pointer to
2503 * Only the hub driver or root-hub registrar should ever call this.
2515 /* Initialize non-root-hub device wakeup to disabled; in usb_new_device()
2556 /* check whether the hub or firmware marks this port as non-removable */ in usb_new_device()
2571 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_new_device() local
2573 struct usb_port *port_dev = hub->ports[port1 - 1]; in usb_new_device()
2587 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_new_device()
2681 * @hdev: The hub device
2754 /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
2755 static unsigned hub_is_wusb(struct usb_hub *hub) in hub_is_wusb() argument
2758 if (hub->hdev->parent != NULL) /* not a root hub? */ in hub_is_wusb()
2760 hcd = bus_to_hcd(hub->hdev->bus); in hub_is_wusb()
2816 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, in hub_port_warm_reset_required() argument
2821 if (!hub_is_superspeed(hub->hdev)) in hub_port_warm_reset_required()
2824 if (test_bit(port1, hub->warm_reset_bits)) in hub_port_warm_reset_required()
2832 static int hub_port_wait_reset(struct usb_hub *hub, int port1, in hub_port_wait_reset() argument
2847 if (hub_is_superspeedplus(hub->hdev)) in hub_port_wait_reset()
2848 ret = hub_ext_port_status(hub, port1, in hub_port_wait_reset()
2853 ret = hub_port_status(hub, port1, &portstatus, in hub_port_wait_reset()
2873 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_port_wait_reset()
2881 if (hub_port_warm_reset_required(hub, port1, portstatus)) in hub_port_wait_reset()
2892 if (!hub_is_superspeed(hub->hdev) && in hub_port_wait_reset()
2894 usb_clear_port_feature(hub->hdev, port1, in hub_port_wait_reset()
2905 if (hub_is_superspeedplus(hub->hdev)) { in hub_port_wait_reset()
2909 udev->ssp_rate = get_port_ssp_rate(hub->hdev, ext_portstatus); in hub_port_wait_reset()
2915 if (hub_is_wusb(hub)) in hub_port_wait_reset()
2919 else if (hub_is_superspeed(hub->hdev)) in hub_port_wait_reset()
2931 static int hub_port_reset(struct usb_hub *hub, int port1, in hub_port_reset() argument
2936 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_reset()
2939 if (!hub_is_superspeed(hub->hdev)) { in hub_port_reset()
2941 dev_err(hub->intfdev, "only USB3 hub support " in hub_port_reset()
2954 if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) in hub_port_reset()
2955 if (hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2959 clear_bit(port1, hub->warm_reset_bits); in hub_port_reset()
2963 status = set_port_feature(hub->hdev, port1, (warm ? in hub_port_reset()
2967 ; /* The hub is gone */ in hub_port_reset()
2973 status = hub_port_wait_reset(hub, port1, udev, delay, in hub_port_reset()
2976 dev_dbg(hub->intfdev, in hub_port_reset()
2983 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2986 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2989 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2991 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2995 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
3002 if (hub_port_status(hub, port1, in hub_port_reset()
3006 if (!hub_port_warm_reset_required(hub, port1, in hub_port_reset()
3037 /* Hub needs extra delay after resetting its port. */ in hub_port_reset()
3038 if (hub->hdev->quirks & USB_QUIRK_HUB_SLOW_RESET) in hub_port_reset()
3061 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
3068 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) in port_is_power_on() argument
3072 if (hub_is_superspeed(hub->hdev)) { in port_is_power_on()
3100 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) in port_is_suspended() argument
3104 if (hub_is_superspeed(hub->hdev)) { in port_is_suspended()
3120 struct usb_hub *hub, int port1, in check_port_resume_type() argument
3123 struct usb_port *port_dev = hub->ports[port1 - 1]; in check_port_resume_type()
3129 && hub_port_warm_reset_required(hub, port1, portstatus)) { in check_port_resume_type()
3133 else if (status || port_is_suspended(hub, portstatus) || in check_port_resume_type()
3134 !port_is_power_on(hub, portstatus)) { in check_port_resume_type()
3140 status = hub_port_status(hub, port1, &portstatus, in check_port_resume_type()
3164 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3167 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3172 * turned on the port1 bit in hub->change_bits. But after in check_port_resume_type()
3177 clear_bit(port1, hub->change_bits); in check_port_resume_type()
3280 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in usb_wakeup_enabled_descendants() local
3283 (hub ? hub->wakeup_enabled_descendants : 0); in usb_wakeup_enabled_descendants()
3289 * @udev: device that's no longer in active use, not a root hub
3314 * Devices on USB hub ports have only one "suspend" state, corresponding
3323 * Other than re-initializing the hub (plug/unplug, except for root hubs),
3329 * hub is suspended). Nevertheless, we change @udev->state to
3337 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_suspend() local
3338 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_suspend()
3346 * wake up the upstream hub (including maybe the root hub). in usb_port_suspend()
3373 if (hub_is_superspeed(hub->hdev)) in usb_port_suspend()
3374 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); in usb_port_suspend()
3379 * into suspend a few ms after the root hub stops sending packets. in usb_port_suspend()
3388 status = set_port_feature(hub->hdev, port1, in usb_port_suspend()
3403 ret = hub_port_status(hub, port1, &portstatus, in usb_port_suspend()
3409 if (ret == 0 && port_is_suspended(hub, portstatus)) { in usb_port_suspend()
3445 && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_port_suspend()
3448 usb_mark_last_busy(hub->hdev); in usb_port_suspend()
3573 struct usb_hub *hub, int *port1, in wait_for_connected() argument
3581 if (!port_is_power_on(hub, *portstatus)) { in wait_for_connected()
3587 status = hub_port_status(hub, *port1, portstatus, portchange); in wait_for_connected()
3595 * @udev: device to re-activate, not a root hub
3629 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_resume() local
3630 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_resume()
3635 if (!test_and_set_bit(port1, hub->child_usage_bits)) { in usb_port_resume()
3647 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3648 if (status == 0 && !port_is_suspended(hub, portstatus)) { in usb_port_resume()
3655 if (hub_is_superspeed(hub->hdev)) in usb_port_resume()
3656 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); in usb_port_resume()
3658 status = usb_clear_port_feature(hub->hdev, in usb_port_resume()
3672 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3678 if (hub_is_superspeed(hub->hdev)) { in usb_port_resume()
3680 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3684 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3693 status = wait_for_connected(udev, hub, &port1, &portchange, in usb_port_resume()
3697 hub, port1, status, portchange, portstatus); in usb_port_resume()
3702 hub_port_logical_disconnect(hub, port1); in usb_port_resume()
3734 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3738 struct usb_port *port_dev = hub->ports[port - 1]; in hub_handle_remote_wakeup()
3745 hdev = hub->hdev; in hub_handle_remote_wakeup()
3771 hub_port_disable(hub, port, 1); in hub_handle_remote_wakeup()
3777 static int check_ports_changed(struct usb_hub *hub) in check_ports_changed() argument
3781 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { in check_ports_changed()
3785 status = hub_port_status(hub, port1, &portstatus, &portchange); in check_ports_changed()
3794 struct usb_hub *hub = usb_get_intfdata(intf); in hub_suspend() local
3795 struct usb_device *hdev = hub->hdev; in hub_suspend()
3802 hub->wakeup_enabled_descendants = 0; in hub_suspend()
3804 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_suspend()
3814 hub->wakeup_enabled_descendants += in hub_suspend()
3818 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { in hub_suspend()
3819 /* check if there are changes pending on hub ports */ in hub_suspend()
3820 if (check_ports_changed(hub)) { in hub_suspend()
3828 /* Enable hub to send remote wakeup for all ports. */ in hub_suspend()
3842 hub_quiesce(hub, HUB_SUSPEND); in hub_suspend()
3846 /* Report wakeup requests from the ports of a resuming root hub */
3847 static void report_wakeup_requests(struct usb_hub *hub) in report_wakeup_requests() argument
3849 struct usb_device *hdev = hub->hdev; in report_wakeup_requests()
3856 return; /* Not a root hub */ in report_wakeup_requests()
3872 udev = hub->ports[i]->child; in report_wakeup_requests()
3882 struct usb_hub *hub = usb_get_intfdata(intf); in hub_resume() local
3885 hub_activate(hub, HUB_RESUME); in hub_resume()
3893 report_wakeup_requests(hub); in hub_resume()
3899 struct usb_hub *hub = usb_get_intfdata(intf); in hub_reset_resume() local
3902 hub_activate(hub, HUB_RESET_RESUME); in hub_reset_resume()
3907 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
3908 * @rhdev: struct usb_device for the root hub
3910 * The USB host controller driver calls this function when its root hub
3913 * When the hub driver is resumed it will take notice and carry out
3919 dev_notice(&rhdev->dev, "root hub lost power or was reset\n"); in usb_root_hub_lost_power()
4161 * Enable the hub-initiated U1/U2 idle timeouts, and enable device-initiated
4165 * control transfers to set the hub timeout or enable device-initiated U1/U2
4169 * hub-initiated U1/U2 will be disabled.
4171 * If we cannot set the parent hub U1/U2 timeout, we attempt to let the xHCI
4220 /* If we can't set the parent hub U1/U2 timeout, in usb_enable_link_state()
4250 * Disable the hub-initiated U1/U2 idle timeouts, and disable device-initiated
4253 * If this function returns -EBUSY, the parent hub will still allow U1/U2 entry.
4257 * it won't have an effect on the bus link state because the parent hub will
4287 /* As soon as usb_set_lpm_timeout(0) return 0, hub initiated LPM in usb_disable_link_state()
4288 * is disabled. Hub will disallows link to enter U1/U2 as well, in usb_disable_link_state()
4289 * even device is initiating LPM. Hence LPM is disabled if hub LPM in usb_disable_link_state()
4302 * Disable hub-initiated and device-initiated U1 and U2 entry.
4358 * Attempt to enable device-initiated and hub-initiated U1 and U2 entry. The
4368 struct usb_hub *hub; in usb_enable_lpm() local
4389 hub = usb_hub_to_struct_hub(udev->parent); in usb_enable_lpm()
4390 if (!hub) in usb_enable_lpm()
4393 port_dev = hub->ports[udev->portnum - 1]; in usb_enable_lpm()
4418 static void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4425 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_usb3_port_prepare_disable()
4444 static inline void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4474 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
4487 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) in hub_port_disable() argument
4489 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_disable()
4490 struct usb_device *hdev = hub->hdev; in hub_port_disable()
4493 if (!hub->error) { in hub_port_disable()
4494 if (hub_is_superspeed(hub->hdev)) { in hub_port_disable()
4495 hub_usb3_port_prepare_disable(hub, port_dev); in hub_port_disable()
4496 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_port_disable()
4519 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_disable() local
4521 return hub_port_disable(hub, udev->portnum, 0); in usb_port_disable()
4539 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) in hub_port_debounce() argument
4545 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_debounce()
4548 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_debounce()
4565 usb_clear_port_feature(hub->hdev, port1, in hub_port_debounce()
4634 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in hub_set_initial_usb2_lpm_policy() local
4640 if (hub) in hub_set_initial_usb2_lpm_policy()
4641 connect_type = hub->ports[udev->portnum - 1]->connect_type; in hub_set_initial_usb2_lpm_policy()
4675 hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, in hub_port_init() argument
4678 struct usb_device *hdev = hub->hdev; in hub_port_init()
4680 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_init()
4689 /* root hub ports have a slightly longer reset period in hub_port_init()
4707 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4779 if (!hub->tt.hub) { in hub_port_init()
4780 dev_err(&udev->dev, "parent hub has no TT\n"); in hub_port_init()
4784 udev->tt = &hub->tt; in hub_port_init()
4810 "hub failed to enable device, error %d\n", in hub_port_init()
4862 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4955 * and attached to a superspeed hub port, but the device descriptor in hub_port_init()
4963 hub_port_reset(hub, port1, udev, in hub_port_init()
5016 hub_port_disable(hub, port1, 0); in hub_port_init()
5024 check_highspeed(struct usb_hub *hub, struct usb_device *udev, int port1) in check_highspeed() argument
5040 "connect to a high speed hub\n"); in check_highspeed()
5041 /* hub LEDs are probably harder to miss than syslog */ in check_highspeed()
5042 if (hub->has_indicators) { in check_highspeed()
5043 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; in check_highspeed()
5045 &hub->leds, 0); in check_highspeed()
5052 hub_power_remaining(struct usb_hub *hub) in hub_power_remaining() argument
5054 struct usb_device *hdev = hub->hdev; in hub_power_remaining()
5058 if (!hub->limited_power) in hub_power_remaining()
5061 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; in hub_power_remaining()
5063 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_power_remaining()
5085 if (delta > hub->mA_per_port) in hub_power_remaining()
5087 delta, hub->mA_per_port); in hub_power_remaining()
5091 dev_warn(hub->intfdev, "%dmA over power budget!\n", in hub_power_remaining()
5183 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, in hub_port_connect() argument
5189 struct usb_device *hdev = hub->hdev; in hub_port_connect()
5191 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect()
5207 clear_bit(port1, hub->removed_bits); in hub_port_connect()
5211 status = hub_port_debounce_be_stable(hub, port1); in hub_port_connect()
5228 test_bit(port1, hub->removed_bits)) { in hub_port_connect()
5231 * maybe switch power back on (e.g. root hub was reset) in hub_port_connect()
5234 if (hub_is_port_power_switchable(hub) in hub_port_connect()
5235 && !port_is_power_on(hub, portstatus) in hub_port_connect()
5243 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
5262 udev->bus_mA = hub->mA_per_port; in hub_port_connect()
5264 udev->wusb = hub_is_wusb(hub); in hub_port_connect()
5267 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
5280 status = hub_port_init(hub, udev, port1, i); in hub_port_connect()
5306 "can't connect bus-powered hub " in hub_port_connect()
5308 if (hub->has_indicators) { in hub_port_connect()
5309 hub->indicator[port1-1] = in hub_port_connect()
5313 &hub->leds, 0); in hub_port_connect()
5324 check_highspeed(hub, udev, port1); in hub_port_connect()
5334 /* We mustn't add new devices if the parent hub has in hub_port_connect()
5365 status = hub_power_remaining(hub); in hub_port_connect()
5367 dev_dbg(hub->intfdev, "%dmA power budget left\n", status); in hub_port_connect()
5372 hub_port_disable(hub, port1, 1); in hub_port_connect()
5384 usb_hub_set_port_power(hdev, hub, port1, false); in hub_port_connect()
5385 msleep(2 * hub_power_on_good_delay(hub)); in hub_port_connect()
5386 usb_hub_set_port_power(hdev, hub, port1, true); in hub_port_connect()
5387 msleep(hub_power_on_good_delay(hub)); in hub_port_connect()
5390 if (hub->hdev->parent || in hub_port_connect()
5399 hub_port_disable(hub, port1, 1); in hub_port_connect()
5400 if (hcd->driver->relinquish_port && !hub->hdev->parent) { in hub_port_connect()
5412 * caller already locked the hub
5414 static void hub_port_connect_change(struct usb_hub *hub, int port1, in hub_port_connect_change() argument
5418 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect_change()
5425 portchange, portspeed(hub, portstatus)); in hub_port_connect_change()
5427 if (hub->has_indicators) { in hub_port_connect_change()
5428 set_port_led(hub, port1, HUB_LED_AUTO); in hub_port_connect_change()
5429 hub->indicator[port1-1] = INDICATOR_AUTO; in hub_port_connect_change()
5434 if (hub->hdev->bus->is_b_host) in hub_port_connect_change()
5481 clear_bit(port1, hub->change_bits); in hub_port_connect_change()
5488 hub_port_connect(hub, port1, portstatus, portchange); in hub_port_connect_change()
5492 /* Handle notifying userspace about hub over-current events */
5529 static void port_event(struct usb_hub *hub, int port1) in port_event() argument
5533 struct usb_port *port_dev = hub->ports[port1 - 1]; in port_event()
5535 struct usb_device *hdev = hub->hdev; in port_event()
5538 connect_change = test_bit(port1, hub->change_bits); in port_event()
5539 clear_bit(port1, hub->event_bits); in port_event()
5540 clear_bit(port1, hub->wakeup_bits); in port_event()
5542 if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) in port_event()
5558 * to be shutdown by the hub, this hack enables them again. in port_event()
5563 dev_err(&port_dev->dev, "disabled by hub (EMI?), re-enabling...\n"); in port_event()
5578 hub_power_on(hub, true); in port_event()
5579 hub_port_status(hub, port1, &status, &unused); in port_event()
5609 if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange)) in port_event()
5616 if (hub_port_warm_reset_required(hub, port1, portstatus)) { in port_event()
5620 if (hub_port_reset(hub, port1, NULL, in port_event()
5622 hub_port_disable(hub, port1, 1); in port_event()
5634 hub_port_connect_change(hub, port1, portstatus, portchange); in port_event()
5641 struct usb_hub *hub; in hub_event() local
5647 hub = container_of(work, struct usb_hub, events); in hub_event()
5648 hdev = hub->hdev; in hub_event()
5649 hub_dev = hub->intfdev; in hub_event()
5657 (u16) hub->change_bits[0], in hub_event()
5658 (u16) hub->event_bits[0]); in hub_event()
5663 if (unlikely(hub->disconnected)) in hub_event()
5666 /* If the hub has died, clean up after it */ in hub_event()
5668 hub->error = -ENODEV; in hub_event()
5669 hub_quiesce(hub, HUB_DISCONNECT); in hub_event()
5680 /* If this is an inactive hub, do nothing */ in hub_event()
5681 if (hub->quiescing) in hub_event()
5684 if (hub->error) { in hub_event()
5685 dev_dbg(hub_dev, "resetting for error %d\n", hub->error); in hub_event()
5689 dev_dbg(hub_dev, "error resetting hub: %d\n", ret); in hub_event()
5693 hub->nerrors = 0; in hub_event()
5694 hub->error = 0; in hub_event()
5699 struct usb_port *port_dev = hub->ports[i - 1]; in hub_event()
5701 if (test_bit(i, hub->event_bits) in hub_event()
5702 || test_bit(i, hub->change_bits) in hub_event()
5703 || test_bit(i, hub->wakeup_bits)) { in hub_event()
5716 port_event(hub, i); in hub_event()
5722 /* deal with hub status changes */ in hub_event()
5723 if (test_and_clear_bit(0, hub->event_bits) == 0) in hub_event()
5725 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) in hub_event()
5733 hub->limited_power = 1; in hub_event()
5735 hub->limited_power = 0; in hub_event()
5744 hub_power_on(hub, true); in hub_event()
5745 hub_hub_status(hub, &status, &unused); in hub_event()
5759 kref_put(&hub->kref, hub_release); in hub_event()
5792 .name = "hub",
5808 printk(KERN_ERR "%s: can't register hub driver\n", in usb_hub_init()
5825 pr_err("%s: can't allocate workqueue for usb hub\n", usbcore_name); in usb_hub_init()
5835 * Hub resources are freed for us by usb_deregister. It calls in usb_hub_cleanup()
5839 * individual hub resources. -greg in usb_hub_cleanup()
6050 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_reset_device() local
6060 dev_dbg(&udev->dev, "%s for root hub!\n", __func__); in usb_reset_device()
6064 port_dev = hub->ports[udev->portnum - 1]; in usb_reset_device()
6171 * @hdev: USB device belonging to the usb hub
6175 * USB drivers call this function to get hub's child device
6184 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_find_child() local
6188 return hub->ports[port1 - 1]->child; in usb_hub_find_child()
6195 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_adjust_deviceremovable() local
6199 if (!hub) in usb_hub_adjust_deviceremovable()
6204 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
6220 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
6240 * @hdev: USB device belonging to the usb hub
6249 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_get_hub_port_acpi_handle() local
6251 if (!hub) in usb_get_hub_port_acpi_handle()
6254 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); in usb_get_hub_port_acpi_handle()