Lines Matching refs:hub
109 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
111 static inline char *portspeed(struct usb_hub *hub, int portstatus) in portspeed() argument
113 if (hub_is_superspeedplus(hub->hdev)) in portspeed()
115 if (hub_is_superspeed(hub->hdev)) in portspeed()
181 struct usb_hub *hub, in usb_set_lpm_mel() argument
199 (hub->descriptor->u.ss.bHubHdrDecLat * 100); in usb_set_lpm_mel()
226 struct usb_hub *hub, in usb_set_lpm_pel() argument
302 struct usb_hub *hub; in usb_set_lpm_parameters() local
312 hub = usb_hub_to_struct_hub(udev->parent); in usb_set_lpm_parameters()
316 if (!hub) in usb_set_lpm_parameters()
325 hub, &udev->parent->u1_params, hub_u1_del); in usb_set_lpm_parameters()
328 hub, &udev->parent->u2_params, hub_u2_del); in usb_set_lpm_parameters()
350 hub, &udev->parent->u1_params, hub_u1_del, in usb_set_lpm_parameters()
359 hub, &udev->parent->u2_params, hub_u2_del, in usb_set_lpm_parameters()
450 static void set_port_led(struct usb_hub *hub, int port1, int selector) in set_port_led() argument
452 struct usb_port *port_dev = hub->ports[port1 - 1]; in set_port_led()
455 status = set_port_feature(hub->hdev, (selector << 8) | port1, in set_port_led()
465 struct usb_hub *hub = in led_work() local
467 struct usb_device *hdev = hub->hdev; in led_work()
472 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) in led_work()
480 switch (hub->indicator[i]) { in led_work()
519 set_port_led(hub, i + 1, selector); in led_work()
520 hub->indicator[i] = mode; in led_work()
525 set_port_led(hub, cursor + 1, HUB_LED_GREEN); in led_work()
526 hub->indicator[cursor] = INDICATOR_CYCLE; in led_work()
531 &hub->leds, LED_CYCLE_PERIOD); in led_work()
573 static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, in hub_ext_port_status() argument
582 mutex_lock(&hub->status_mutex); in hub_ext_port_status()
583 ret = get_port_status(hub->hdev, port1, &hub->status->port, type, len); in hub_ext_port_status()
586 dev_err(hub->intfdev, in hub_ext_port_status()
591 *status = le16_to_cpu(hub->status->port.wPortStatus); in hub_ext_port_status()
592 *change = le16_to_cpu(hub->status->port.wPortChange); in hub_ext_port_status()
595 hub->status->port.dwExtPortStatus); in hub_ext_port_status()
598 mutex_unlock(&hub->status_mutex); in hub_ext_port_status()
602 static int hub_port_status(struct usb_hub *hub, int port1, in hub_port_status() argument
605 return hub_ext_port_status(hub, port1, HUB_PORT_STATUS, in hub_port_status()
609 static void kick_hub_wq(struct usb_hub *hub) in kick_hub_wq() argument
613 if (hub->disconnected || work_pending(&hub->events)) in kick_hub_wq()
624 intf = to_usb_interface(hub->intfdev); in kick_hub_wq()
626 kref_get(&hub->kref); in kick_hub_wq()
628 if (queue_work(hub_wq, &hub->events)) in kick_hub_wq()
633 kref_put(&hub->kref, hub_release); in kick_hub_wq()
638 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_kick_hub_wq() local
640 if (hub) in usb_kick_hub_wq()
641 kick_hub_wq(hub); in usb_kick_hub_wq()
655 struct usb_hub *hub; in usb_wakeup_notification() local
661 hub = usb_hub_to_struct_hub(hdev); in usb_wakeup_notification()
662 if (hub) { in usb_wakeup_notification()
663 port_dev = hub->ports[portnum - 1]; in usb_wakeup_notification()
667 set_bit(portnum, hub->wakeup_bits); in usb_wakeup_notification()
668 kick_hub_wq(hub); in usb_wakeup_notification()
676 struct usb_hub *hub = urb->context; in hub_irq() local
689 dev_dbg(hub->intfdev, "transfer --> %d\n", status); in hub_irq()
690 if ((++hub->nerrors < 10) || hub->error) in hub_irq()
692 hub->error = status; in hub_irq()
699 bits |= ((unsigned long) ((*hub->buffer)[i])) in hub_irq()
701 hub->event_bits[0] = bits; in hub_irq()
705 hub->nerrors = 0; in hub_irq()
708 kick_hub_wq(hub); in hub_irq()
711 if (hub->quiescing) in hub_irq()
714 status = usb_submit_urb(hub->urb, GFP_ATOMIC); in hub_irq()
716 dev_err(hub->intfdev, "resubmit --> %d\n", status); in hub_irq()
745 struct usb_hub *hub = in hub_tt_work() local
749 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
750 while (!list_empty(&hub->tt.clear_list)) { in hub_tt_work()
753 struct usb_device *hdev = hub->hdev; in hub_tt_work()
757 next = hub->tt.clear_list.next; in hub_tt_work()
762 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
775 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
777 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
792 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, in usb_hub_set_port_power() argument
806 set_bit(port1, hub->power_bits); in usb_hub_set_port_power()
808 clear_bit(port1, hub->power_bits); in usb_hub_set_port_power()
868 static void hub_power_on(struct usb_hub *hub, bool do_delay) in hub_power_on() argument
878 if (hub_is_port_power_switchable(hub)) in hub_power_on()
879 dev_dbg(hub->intfdev, "enabling power on all ports\n"); in hub_power_on()
881 dev_dbg(hub->intfdev, "trying to enable port power on " in hub_power_on()
883 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) in hub_power_on()
884 if (test_bit(port1, hub->power_bits)) in hub_power_on()
885 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); in hub_power_on()
887 usb_clear_port_feature(hub->hdev, port1, in hub_power_on()
890 msleep(hub_power_on_good_delay(hub)); in hub_power_on()
893 static int hub_hub_status(struct usb_hub *hub, in hub_hub_status() argument
898 mutex_lock(&hub->status_mutex); in hub_hub_status()
899 ret = get_hub_status(hub->hdev, &hub->status->hub); in hub_hub_status()
902 dev_err(hub->intfdev, in hub_hub_status()
905 *status = le16_to_cpu(hub->status->hub.wHubStatus); in hub_hub_status()
906 *change = le16_to_cpu(hub->status->hub.wHubChange); in hub_hub_status()
909 mutex_unlock(&hub->status_mutex); in hub_hub_status()
913 static int hub_set_port_link_state(struct usb_hub *hub, int port1, in hub_set_port_link_state() argument
916 return set_port_feature(hub->hdev, in hub_set_port_link_state()
926 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) in hub_port_logical_disconnect() argument
928 dev_dbg(&hub->ports[port1 - 1]->dev, "logical disconnect\n"); in hub_port_logical_disconnect()
929 hub_port_disable(hub, port1, 1); in hub_port_logical_disconnect()
940 set_bit(port1, hub->change_bits); in hub_port_logical_disconnect()
941 kick_hub_wq(hub); in hub_port_logical_disconnect()
958 struct usb_hub *hub; in usb_remove_device() local
963 hub = usb_hub_to_struct_hub(udev->parent); in usb_remove_device()
964 intf = to_usb_interface(hub->intfdev); in usb_remove_device()
967 set_bit(udev->portnum, hub->removed_bits); in usb_remove_device()
968 hub_port_logical_disconnect(hub, udev->portnum); in usb_remove_device()
981 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) in hub_activate() argument
983 struct usb_device *hdev = hub->hdev; in hub_activate()
996 if (hub->disconnected) in hub_activate()
1002 kref_get(&hub->kref); in hub_activate()
1021 dev_err(hub->intfdev, in hub_activate()
1038 delay = hub_power_on_good_delay(hub); in hub_activate()
1040 hub_power_on(hub, false); in hub_activate()
1041 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); in hub_activate()
1043 &hub->init_work, in hub_activate()
1048 to_usb_interface(hub->intfdev)); in hub_activate()
1058 &hub->tt, GFP_NOIO); in hub_activate()
1060 dev_err(hub->intfdev, in hub_activate()
1062 dev_err(hub->intfdev, in hub_activate()
1066 hub_power_on(hub, true); in hub_activate()
1068 hub_power_on(hub, true); in hub_activate()
1078 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_activate()
1083 status = hub_port_status(hub, port1, &portstatus, &portchange); in hub_activate()
1117 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1122 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1127 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1131 hub_is_superspeed(hub->hdev)) { in hub_activate()
1133 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1141 clear_bit(port1, hub->removed_bits); in hub_activate()
1153 set_bit(port1, hub->change_bits); in hub_activate()
1167 if (portchange || (hub_is_superspeed(hub->hdev) && in hub_activate()
1169 set_bit(port1, hub->change_bits); in hub_activate()
1178 if (test_bit(port1, hub->power_bits)) in hub_activate()
1179 set_bit(port1, hub->change_bits); in hub_activate()
1184 set_bit(port1, hub->change_bits); in hub_activate()
1201 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); in hub_activate()
1203 &hub->init_work, in hub_activate()
1212 hub->quiescing = 0; in hub_activate()
1214 status = usb_submit_urb(hub->urb, GFP_NOIO); in hub_activate()
1216 dev_err(hub->intfdev, "activate --> %d\n", status); in hub_activate()
1217 if (hub->has_indicators && blinkenlights) in hub_activate()
1219 &hub->leds, LED_CYCLE_PERIOD); in hub_activate()
1222 kick_hub_wq(hub); in hub_activate()
1227 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); in hub_activate()
1231 kref_put(&hub->kref, hub_release); in hub_activate()
1237 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func2() local
1239 hub_activate(hub, HUB_INIT2); in hub_init_func2()
1244 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func3() local
1246 hub_activate(hub, HUB_INIT3); in hub_init_func3()
1253 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) in hub_quiesce() argument
1255 struct usb_device *hdev = hub->hdev; in hub_quiesce()
1259 hub->quiescing = 1; in hub_quiesce()
1264 if (hub->ports[i]->child) in hub_quiesce()
1265 usb_disconnect(&hub->ports[i]->child); in hub_quiesce()
1270 usb_kill_urb(hub->urb); in hub_quiesce()
1271 if (hub->has_indicators) in hub_quiesce()
1272 cancel_delayed_work_sync(&hub->leds); in hub_quiesce()
1273 if (hub->tt.hub) in hub_quiesce()
1274 flush_work(&hub->tt.clear_work); in hub_quiesce()
1277 static void hub_pm_barrier_for_all_ports(struct usb_hub *hub) in hub_pm_barrier_for_all_ports() argument
1281 for (i = 0; i < hub->hdev->maxchild; ++i) in hub_pm_barrier_for_all_ports()
1282 pm_runtime_barrier(&hub->ports[i]->dev); in hub_pm_barrier_for_all_ports()
1288 struct usb_hub *hub = usb_get_intfdata(intf); in hub_pre_reset() local
1290 hub_quiesce(hub, HUB_PRE_RESET); in hub_pre_reset()
1291 hub->in_reset = 1; in hub_pre_reset()
1292 hub_pm_barrier_for_all_ports(hub); in hub_pre_reset()
1299 struct usb_hub *hub = usb_get_intfdata(intf); in hub_post_reset() local
1301 hub->in_reset = 0; in hub_post_reset()
1302 hub_pm_barrier_for_all_ports(hub); in hub_post_reset()
1303 hub_activate(hub, HUB_POST_RESET); in hub_post_reset()
1307 static int hub_configure(struct usb_hub *hub, in hub_configure() argument
1311 struct usb_device *hdev = hub->hdev; in hub_configure()
1312 struct device *hub_dev = hub->intfdev; in hub_configure()
1322 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); in hub_configure()
1323 if (!hub->buffer) { in hub_configure()
1328 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); in hub_configure()
1329 if (!hub->status) { in hub_configure()
1333 mutex_init(&hub->status_mutex); in hub_configure()
1335 hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_KERNEL); in hub_configure()
1336 if (!hub->descriptor) { in hub_configure()
1345 ret = get_hub_descriptor(hdev, hub->descriptor); in hub_configure()
1355 if (hub->descriptor->bNbrPorts > maxchild) { in hub_configure()
1359 } else if (hub->descriptor->bNbrPorts == 0) { in hub_configure()
1370 u32 delay = __le16_to_cpu(hub->descriptor->u.ss.wHubDelay); in hub_configure()
1379 maxchild = hub->descriptor->bNbrPorts; in hub_configure()
1383 hub->ports = kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL); in hub_configure()
1384 if (!hub->ports) { in hub_configure()
1389 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in hub_configure()
1404 portstr[i] = hub->descriptor->u.hs.DeviceRemovable in hub_configure()
1438 spin_lock_init(&hub->tt.lock); in hub_configure()
1439 INIT_LIST_HEAD(&hub->tt.clear_list); in hub_configure()
1440 INIT_WORK(&hub->tt.clear_work, hub_tt_work); in hub_configure()
1446 hub->tt.hub = hdev; in hub_configure()
1452 hub->tt.multi = 1; in hub_configure()
1456 hub->tt.hub = hdev; in hub_configure()
1471 hub->tt.think_time = 666; in hub_configure()
1474 8, hub->tt.think_time); in hub_configure()
1478 hub->tt.think_time = 666 * 2; in hub_configure()
1481 16, hub->tt.think_time); in hub_configure()
1484 hub->tt.think_time = 666 * 3; in hub_configure()
1487 24, hub->tt.think_time); in hub_configure()
1490 hub->tt.think_time = 666 * 4; in hub_configure()
1493 32, hub->tt.think_time); in hub_configure()
1499 hub->has_indicators = 1; in hub_configure()
1504 hub->descriptor->bPwrOn2PwrGood * 2); in hub_configure()
1521 hub->mA_per_port = full_load; in hub_configure()
1523 hub->mA_per_port = hdev->bus_mA; in hub_configure()
1524 hub->limited_power = 1; in hub_configure()
1528 hub->descriptor->bHubContrCurrent; in hub_configure()
1531 hub->descriptor->bHubContrCurrent); in hub_configure()
1532 hub->limited_power = 1; in hub_configure()
1538 hub->mA_per_port = unit_load; /* 7.2.1 */ in hub_configure()
1543 hub->mA_per_port = full_load; in hub_configure()
1545 if (hub->mA_per_port < full_load) in hub_configure()
1547 hub->mA_per_port); in hub_configure()
1549 ret = hub_hub_status(hub, &hubstatus, &hubchange); in hub_configure()
1574 if (maxp > sizeof(*hub->buffer)) in hub_configure()
1575 maxp = sizeof(*hub->buffer); in hub_configure()
1577 hub->urb = usb_alloc_urb(0, GFP_KERNEL); in hub_configure()
1578 if (!hub->urb) { in hub_configure()
1583 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, in hub_configure()
1584 hub, endpoint->bInterval); in hub_configure()
1587 if (hub->has_indicators && blinkenlights) in hub_configure()
1588 hub->indicator[0] = INDICATOR_CYCLE; in hub_configure()
1592 ret = usb_hub_create_port_device(hub, i + 1); in hub_configure()
1594 dev_err(hub->intfdev, in hub_configure()
1601 struct usb_port *port_dev = hub->ports[i]; in hub_configure()
1615 &hub->tt, GFP_KERNEL); in hub_configure()
1622 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); in hub_configure()
1624 hub_activate(hub, HUB_INIT); in hub_configure()
1636 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); in hub_release() local
1638 usb_put_dev(hub->hdev); in hub_release()
1639 usb_put_intf(to_usb_interface(hub->intfdev)); in hub_release()
1640 kfree(hub); in hub_release()
1647 struct usb_hub *hub = usb_get_intfdata(intf); in hub_disconnect() local
1655 hub->disconnected = 1; in hub_disconnect()
1658 hub->error = 0; in hub_disconnect()
1659 hub_quiesce(hub, HUB_DISCONNECT); in hub_disconnect()
1671 usb_hub_remove_port_device(hub, port1); in hub_disconnect()
1675 if (hub->hdev->speed == USB_SPEED_HIGH) in hub_disconnect()
1678 usb_free_urb(hub->urb); in hub_disconnect()
1679 kfree(hub->ports); in hub_disconnect()
1680 kfree(hub->descriptor); in hub_disconnect()
1681 kfree(hub->status); in hub_disconnect()
1682 kfree(hub->buffer); in hub_disconnect()
1685 kref_put(&hub->kref, hub_release); in hub_disconnect()
1711 struct usb_hub *hub; in hub_probe() local
1792 hub = kzalloc(sizeof(*hub), GFP_KERNEL); in hub_probe()
1793 if (!hub) in hub_probe()
1796 kref_init(&hub->kref); in hub_probe()
1797 hub->intfdev = &intf->dev; in hub_probe()
1798 hub->hdev = hdev; in hub_probe()
1799 INIT_DELAYED_WORK(&hub->leds, led_work); in hub_probe()
1800 INIT_DELAYED_WORK(&hub->init_work, NULL); in hub_probe()
1801 INIT_WORK(&hub->events, hub_event); in hub_probe()
1805 usb_set_intfdata(intf, hub); in hub_probe()
1813 hub->quirk_check_port_auto_suspend = 1; in hub_probe()
1815 if (hub_configure(hub, &desc->endpoint[0].desc) >= 0) in hub_probe()
1826 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in hub_ioctl() local
1840 if (hub->ports[i]->child == NULL) in hub_ioctl()
1844 hub->ports[i]->child->devnum; in hub_ioctl()
1864 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in find_port_owner() local
1874 *ppowner = &(hub->ports[port1 - 1]->port_owner); in find_port_owner()
1913 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_release_all_ports() local
1917 if (hub->ports[n]->port_owner == owner) in usb_hub_release_all_ports()
1918 hub->ports[n]->port_owner = NULL; in usb_hub_release_all_ports()
1926 struct usb_hub *hub; in usb_device_is_owned() local
1930 hub = usb_hub_to_struct_hub(udev->parent); in usb_device_is_owned()
1931 return !!hub->ports[udev->portnum - 1]->port_owner; in usb_device_is_owned()
1936 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in recursively_mark_NOTATTACHED() local
1940 if (hub->ports[i]->child) in recursively_mark_NOTATTACHED()
1941 recursively_mark_NOTATTACHED(hub->ports[i]->child); in recursively_mark_NOTATTACHED()
2092 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in hub_disconnect_children() local
2097 if (hub->ports[i]->child) in hub_disconnect_children()
2098 usb_disconnect(&hub->ports[i]->child); in hub_disconnect_children()
2122 struct usb_hub *hub = NULL; in usb_disconnect() local
2153 hub = usb_hub_to_struct_hub(udev->parent); in usb_disconnect()
2154 port_dev = hub->ports[port1 - 1]; in usb_disconnect()
2163 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2186 if (port_dev && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2359 struct usb_hub *hub; in set_usb_port_removable() local
2367 hub = usb_hub_to_struct_hub(udev->parent); in set_usb_port_removable()
2373 switch (hub->ports[udev->portnum - 1]->connect_type) { in set_usb_port_removable()
2389 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in set_usb_port_removable()
2395 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) in set_usb_port_removable()
2399 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) in set_usb_port_removable()
2493 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_new_device() local
2495 struct usb_port *port_dev = hub->ports[port1 - 1]; in usb_new_device()
2509 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_new_device()
2629 static unsigned hub_is_wusb(struct usb_hub *hub) in hub_is_wusb() argument
2632 if (hub->hdev->parent != NULL) /* not a root hub? */ in hub_is_wusb()
2634 hcd = bus_to_hcd(hub->hdev->bus); in hub_is_wusb()
2673 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, in hub_port_warm_reset_required() argument
2678 if (!hub_is_superspeed(hub->hdev)) in hub_port_warm_reset_required()
2681 if (test_bit(port1, hub->warm_reset_bits)) in hub_port_warm_reset_required()
2689 static int hub_port_wait_reset(struct usb_hub *hub, int port1, in hub_port_wait_reset() argument
2704 if (hub_is_superspeedplus(hub->hdev)) in hub_port_wait_reset()
2705 ret = hub_ext_port_status(hub, port1, in hub_port_wait_reset()
2710 ret = hub_port_status(hub, port1, &portstatus, in hub_port_wait_reset()
2730 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_port_wait_reset()
2738 if (hub_port_warm_reset_required(hub, port1, portstatus)) in hub_port_wait_reset()
2749 if (!hub_is_superspeed(hub->hdev) && in hub_port_wait_reset()
2751 usb_clear_port_feature(hub->hdev, port1, in hub_port_wait_reset()
2762 if (hub_is_superspeedplus(hub->hdev)) { in hub_port_wait_reset()
2770 if (hub_is_wusb(hub)) in hub_port_wait_reset()
2772 else if (hub_is_superspeedplus(hub->hdev) && in hub_port_wait_reset()
2773 port_speed_is_ssp(hub->hdev, ext_portstatus & in hub_port_wait_reset()
2776 else if (hub_is_superspeed(hub->hdev)) in hub_port_wait_reset()
2788 static int hub_port_reset(struct usb_hub *hub, int port1, in hub_port_reset() argument
2793 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_reset()
2795 if (!hub_is_superspeed(hub->hdev)) { in hub_port_reset()
2797 dev_err(hub->intfdev, "only USB3 hub support " in hub_port_reset()
2810 if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) in hub_port_reset()
2811 if (hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2815 clear_bit(port1, hub->warm_reset_bits); in hub_port_reset()
2819 status = set_port_feature(hub->hdev, port1, (warm ? in hub_port_reset()
2829 status = hub_port_wait_reset(hub, port1, udev, delay, in hub_port_reset()
2832 dev_dbg(hub->intfdev, in hub_port_reset()
2839 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2842 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2845 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2847 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2849 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2856 if (hub_port_status(hub, port1, in hub_port_reset()
2860 if (!hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2908 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2915 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) in port_is_power_on() argument
2919 if (hub_is_superspeed(hub->hdev)) { in port_is_power_on()
2947 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) in port_is_suspended() argument
2951 if (hub_is_superspeed(hub->hdev)) { in port_is_suspended()
2967 struct usb_hub *hub, int port1, in check_port_resume_type() argument
2970 struct usb_port *port_dev = hub->ports[port1 - 1]; in check_port_resume_type()
2976 && hub_port_warm_reset_required(hub, port1, portstatus)) { in check_port_resume_type()
2980 else if (status || port_is_suspended(hub, portstatus) || in check_port_resume_type()
2981 !port_is_power_on(hub, portstatus)) { in check_port_resume_type()
2987 status = hub_port_status(hub, port1, &portstatus, in check_port_resume_type()
3011 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3014 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3118 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in wakeup_enabled_descendants() local
3121 (hub ? hub->wakeup_enabled_descendants : 0); in wakeup_enabled_descendants()
3174 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_suspend() local
3175 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_suspend()
3211 if (hub_is_superspeed(hub->hdev)) in usb_port_suspend()
3212 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); in usb_port_suspend()
3226 status = set_port_feature(hub->hdev, port1, in usb_port_suspend()
3263 && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_port_suspend()
3266 usb_mark_last_busy(hub->hdev); in usb_port_suspend()
3391 struct usb_hub *hub, int *port1, in wait_for_connected() argument
3399 if (!port_is_power_on(hub, *portstatus)) { in wait_for_connected()
3405 status = hub_port_status(hub, *port1, portstatus, portchange); in wait_for_connected()
3447 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_resume() local
3448 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_resume()
3453 if (!test_and_set_bit(port1, hub->child_usage_bits)) { in usb_port_resume()
3465 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3466 if (status == 0 && !port_is_suspended(hub, portstatus)) { in usb_port_resume()
3473 if (hub_is_superspeed(hub->hdev)) in usb_port_resume()
3474 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); in usb_port_resume()
3476 status = usb_clear_port_feature(hub->hdev, in usb_port_resume()
3490 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3499 if (hub_is_superspeed(hub->hdev)) { in usb_port_resume()
3501 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3505 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3511 status = wait_for_connected(udev, hub, &port1, &portchange, in usb_port_resume()
3515 hub, port1, status, portchange, portstatus); in usb_port_resume()
3520 hub_port_logical_disconnect(hub, port1); in usb_port_resume()
3553 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3557 struct usb_port *port_dev = hub->ports[port - 1]; in hub_handle_remote_wakeup()
3563 hdev = hub->hdev; in hub_handle_remote_wakeup()
3587 hub_port_disable(hub, port, 1); in hub_handle_remote_wakeup()
3593 static int check_ports_changed(struct usb_hub *hub) in check_ports_changed() argument
3597 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { in check_ports_changed()
3601 status = hub_port_status(hub, port1, &portstatus, &portchange); in check_ports_changed()
3610 struct usb_hub *hub = usb_get_intfdata(intf); in hub_suspend() local
3611 struct usb_device *hdev = hub->hdev; in hub_suspend()
3619 hub->wakeup_enabled_descendants = 0; in hub_suspend()
3621 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_suspend()
3631 hub->wakeup_enabled_descendants += in hub_suspend()
3635 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { in hub_suspend()
3637 if (check_ports_changed(hub)) { in hub_suspend()
3659 hub_quiesce(hub, HUB_SUSPEND); in hub_suspend()
3664 static void report_wakeup_requests(struct usb_hub *hub) in report_wakeup_requests() argument
3666 struct usb_device *hdev = hub->hdev; in report_wakeup_requests()
3689 udev = hub->ports[i]->child; in report_wakeup_requests()
3699 struct usb_hub *hub = usb_get_intfdata(intf); in hub_resume() local
3702 hub_activate(hub, HUB_RESUME); in hub_resume()
3710 report_wakeup_requests(hub); in hub_resume()
3716 struct usb_hub *hub = usb_get_intfdata(intf); in hub_reset_resume() local
3719 hub_activate(hub, HUB_RESET_RESUME); in hub_reset_resume()
4137 struct usb_hub *hub; in usb_enable_lpm() local
4158 hub = usb_hub_to_struct_hub(udev->parent); in usb_enable_lpm()
4159 if (!hub) in usb_enable_lpm()
4162 port_dev = hub->ports[udev->portnum - 1]; in usb_enable_lpm()
4187 static void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4194 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_usb3_port_prepare_disable()
4213 static inline void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4243 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
4256 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) in hub_port_disable() argument
4258 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_disable()
4259 struct usb_device *hdev = hub->hdev; in hub_port_disable()
4262 if (!hub->error) { in hub_port_disable()
4263 if (hub_is_superspeed(hub->hdev)) { in hub_port_disable()
4264 hub_usb3_port_prepare_disable(hub, port_dev); in hub_port_disable()
4265 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_port_disable()
4288 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_disable() local
4290 return hub_port_disable(hub, udev->portnum, 0); in usb_port_disable()
4308 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) in hub_port_debounce() argument
4314 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_debounce()
4317 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_debounce()
4334 usb_clear_port_feature(hub->hdev, port1, in hub_port_debounce()
4403 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in hub_set_initial_usb2_lpm_policy() local
4409 if (hub) in hub_set_initial_usb2_lpm_policy()
4410 connect_type = hub->ports[udev->portnum - 1]->connect_type; in hub_set_initial_usb2_lpm_policy()
4444 hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, in hub_port_init() argument
4447 struct usb_device *hdev = hub->hdev; in hub_port_init()
4449 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_init()
4475 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4547 if (!hub->tt.hub) { in hub_port_init()
4552 udev->tt = &hub->tt; in hub_port_init()
4630 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4731 hub_port_reset(hub, port1, udev, in hub_port_init()
4784 hub_port_disable(hub, port1, 0); in hub_port_init()
4792 check_highspeed(struct usb_hub *hub, struct usb_device *udev, int port1) in check_highspeed() argument
4810 if (hub->has_indicators) { in check_highspeed()
4811 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; in check_highspeed()
4813 &hub->leds, 0); in check_highspeed()
4820 hub_power_remaining(struct usb_hub *hub) in hub_power_remaining() argument
4822 struct usb_device *hdev = hub->hdev; in hub_power_remaining()
4826 if (!hub->limited_power) in hub_power_remaining()
4829 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; in hub_power_remaining()
4831 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_power_remaining()
4853 if (delta > hub->mA_per_port) in hub_power_remaining()
4855 delta, hub->mA_per_port); in hub_power_remaining()
4859 dev_warn(hub->intfdev, "%dmA over power budget!\n", in hub_power_remaining()
4866 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, in hub_port_connect() argument
4872 struct usb_device *hdev = hub->hdev; in hub_port_connect()
4874 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect()
4890 clear_bit(port1, hub->removed_bits); in hub_port_connect()
4894 status = hub_port_debounce_be_stable(hub, port1); in hub_port_connect()
4911 test_bit(port1, hub->removed_bits)) { in hub_port_connect()
4917 if (hub_is_port_power_switchable(hub) in hub_port_connect()
4918 && !port_is_power_on(hub, portstatus) in hub_port_connect()
4926 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4945 udev->bus_mA = hub->mA_per_port; in hub_port_connect()
4947 udev->wusb = hub_is_wusb(hub); in hub_port_connect()
4950 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4963 status = hub_port_init(hub, udev, port1, i); in hub_port_connect()
4991 if (hub->has_indicators) { in hub_port_connect()
4992 hub->indicator[port1-1] = in hub_port_connect()
4996 &hub->leds, 0); in hub_port_connect()
5007 check_highspeed(hub, udev, port1); in hub_port_connect()
5048 status = hub_power_remaining(hub); in hub_port_connect()
5050 dev_dbg(hub->intfdev, "%dmA power budget left\n", status); in hub_port_connect()
5055 hub_port_disable(hub, port1, 1); in hub_port_connect()
5067 usb_hub_set_port_power(hdev, hub, port1, false); in hub_port_connect()
5068 msleep(2 * hub_power_on_good_delay(hub)); in hub_port_connect()
5069 usb_hub_set_port_power(hdev, hub, port1, true); in hub_port_connect()
5070 msleep(hub_power_on_good_delay(hub)); in hub_port_connect()
5073 if (hub->hdev->parent || in hub_port_connect()
5082 hub_port_disable(hub, port1, 1); in hub_port_connect()
5083 if (hcd->driver->relinquish_port && !hub->hdev->parent) { in hub_port_connect()
5097 static void hub_port_connect_change(struct usb_hub *hub, int port1, in hub_port_connect_change() argument
5101 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect_change()
5106 portchange, portspeed(hub, portstatus)); in hub_port_connect_change()
5108 if (hub->has_indicators) { in hub_port_connect_change()
5109 set_port_led(hub, port1, HUB_LED_AUTO); in hub_port_connect_change()
5110 hub->indicator[port1-1] = INDICATOR_AUTO; in hub_port_connect_change()
5115 if (hub->hdev->bus->is_b_host) in hub_port_connect_change()
5139 clear_bit(port1, hub->change_bits); in hub_port_connect_change()
5146 hub_port_connect(hub, port1, portstatus, portchange); in hub_port_connect_change()
5150 static void port_event(struct usb_hub *hub, int port1) in port_event() argument
5154 struct usb_port *port_dev = hub->ports[port1 - 1]; in port_event()
5156 struct usb_device *hdev = hub->hdev; in port_event()
5159 connect_change = test_bit(port1, hub->change_bits); in port_event()
5160 clear_bit(port1, hub->event_bits); in port_event()
5161 clear_bit(port1, hub->wakeup_bits); in port_event()
5163 if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) in port_event()
5198 hub_power_on(hub, true); in port_event()
5199 hub_port_status(hub, port1, &status, &unused); in port_event()
5229 if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange)) in port_event()
5236 if (hub_port_warm_reset_required(hub, port1, portstatus)) { in port_event()
5240 if (hub_port_reset(hub, port1, NULL, in port_event()
5242 hub_port_disable(hub, port1, 1); in port_event()
5254 hub_port_connect_change(hub, port1, portstatus, portchange); in port_event()
5261 struct usb_hub *hub; in hub_event() local
5267 hub = container_of(work, struct usb_hub, events); in hub_event()
5268 hdev = hub->hdev; in hub_event()
5269 hub_dev = hub->intfdev; in hub_event()
5275 (u16) hub->change_bits[0], in hub_event()
5276 (u16) hub->event_bits[0]); in hub_event()
5281 if (unlikely(hub->disconnected)) in hub_event()
5286 hub->error = -ENODEV; in hub_event()
5287 hub_quiesce(hub, HUB_DISCONNECT); in hub_event()
5299 if (hub->quiescing) in hub_event()
5302 if (hub->error) { in hub_event()
5303 dev_dbg(hub_dev, "resetting for error %d\n", hub->error); in hub_event()
5311 hub->nerrors = 0; in hub_event()
5312 hub->error = 0; in hub_event()
5317 struct usb_port *port_dev = hub->ports[i - 1]; in hub_event()
5319 if (test_bit(i, hub->event_bits) in hub_event()
5320 || test_bit(i, hub->change_bits) in hub_event()
5321 || test_bit(i, hub->wakeup_bits)) { in hub_event()
5334 port_event(hub, i); in hub_event()
5341 if (test_and_clear_bit(0, hub->event_bits) == 0) in hub_event()
5343 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) in hub_event()
5351 hub->limited_power = 1; in hub_event()
5353 hub->limited_power = 0; in hub_event()
5362 hub_power_on(hub, true); in hub_event()
5363 hub_hub_status(hub, &status, &unused); in hub_event()
5377 kref_put(&hub->kref, hub_release); in hub_event()
5739 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_reset_device() local
5754 port_dev = hub->ports[udev->portnum - 1]; in usb_reset_device()
5871 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_find_child() local
5875 return hub->ports[port1 - 1]->child; in usb_hub_find_child()
5882 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_adjust_deviceremovable() local
5886 if (!hub) in usb_hub_adjust_deviceremovable()
5891 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5907 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5936 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_get_hub_port_acpi_handle() local
5938 if (!hub) in usb_get_hub_port_acpi_handle()
5941 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); in usb_get_hub_port_acpi_handle()