Lines Matching refs:hub
104 static void hub_usb3_port_prepare_disable(struct usb_hub *hub,
107 static inline char *portspeed(struct usb_hub *hub, int portstatus) in portspeed() argument
109 if (hub_is_superspeed(hub->hdev)) in portspeed()
175 struct usb_hub *hub, in usb_set_lpm_mel() argument
193 (hub->descriptor->u.ss.bHubHdrDecLat * 100); in usb_set_lpm_mel()
220 struct usb_hub *hub, in usb_set_lpm_pel() argument
296 struct usb_hub *hub; in usb_set_lpm_parameters() local
306 hub = usb_hub_to_struct_hub(udev->parent); in usb_set_lpm_parameters()
310 if (!hub) in usb_set_lpm_parameters()
319 hub, &udev->parent->u1_params, hub_u1_del); in usb_set_lpm_parameters()
322 hub, &udev->parent->u2_params, hub_u2_del); in usb_set_lpm_parameters()
344 hub, &udev->parent->u1_params, hub_u1_del, in usb_set_lpm_parameters()
353 hub, &udev->parent->u2_params, hub_u2_del, in usb_set_lpm_parameters()
444 static void set_port_led(struct usb_hub *hub, int port1, int selector) in set_port_led() argument
446 struct usb_port *port_dev = hub->ports[port1 - 1]; in set_port_led()
449 status = set_port_feature(hub->hdev, (selector << 8) | port1, in set_port_led()
459 struct usb_hub *hub = in led_work() local
461 struct usb_device *hdev = hub->hdev; in led_work()
466 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) in led_work()
474 switch (hub->indicator[i]) { in led_work()
513 set_port_led(hub, i + 1, selector); in led_work()
514 hub->indicator[i] = mode; in led_work()
519 set_port_led(hub, cursor + 1, HUB_LED_GREEN); in led_work()
520 hub->indicator[cursor] = INDICATOR_CYCLE; in led_work()
525 &hub->leds, LED_CYCLE_PERIOD); in led_work()
566 static int hub_port_status(struct usb_hub *hub, int port1, in hub_port_status() argument
571 mutex_lock(&hub->status_mutex); in hub_port_status()
572 ret = get_port_status(hub->hdev, port1, &hub->status->port); in hub_port_status()
575 dev_err(hub->intfdev, in hub_port_status()
580 *status = le16_to_cpu(hub->status->port.wPortStatus); in hub_port_status()
581 *change = le16_to_cpu(hub->status->port.wPortChange); in hub_port_status()
585 mutex_unlock(&hub->status_mutex); in hub_port_status()
589 static void kick_hub_wq(struct usb_hub *hub) in kick_hub_wq() argument
593 if (hub->disconnected || work_pending(&hub->events)) in kick_hub_wq()
604 intf = to_usb_interface(hub->intfdev); in kick_hub_wq()
606 kref_get(&hub->kref); in kick_hub_wq()
608 if (queue_work(hub_wq, &hub->events)) in kick_hub_wq()
613 kref_put(&hub->kref, hub_release); in kick_hub_wq()
618 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_kick_hub_wq() local
620 if (hub) in usb_kick_hub_wq()
621 kick_hub_wq(hub); in usb_kick_hub_wq()
635 struct usb_hub *hub; in usb_wakeup_notification() local
640 hub = usb_hub_to_struct_hub(hdev); in usb_wakeup_notification()
641 if (hub) { in usb_wakeup_notification()
642 set_bit(portnum, hub->wakeup_bits); in usb_wakeup_notification()
643 kick_hub_wq(hub); in usb_wakeup_notification()
651 struct usb_hub *hub = urb->context; in hub_irq() local
664 dev_dbg (hub->intfdev, "transfer --> %d\n", status); in hub_irq()
665 if ((++hub->nerrors < 10) || hub->error) in hub_irq()
667 hub->error = status; in hub_irq()
674 bits |= ((unsigned long) ((*hub->buffer)[i])) in hub_irq()
676 hub->event_bits[0] = bits; in hub_irq()
680 hub->nerrors = 0; in hub_irq()
683 kick_hub_wq(hub); in hub_irq()
686 if (hub->quiescing) in hub_irq()
689 if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 in hub_irq()
691 dev_err (hub->intfdev, "resubmit --> %d\n", status); in hub_irq()
720 struct usb_hub *hub = in hub_tt_work() local
724 spin_lock_irqsave (&hub->tt.lock, flags); in hub_tt_work()
725 while (!list_empty(&hub->tt.clear_list)) { in hub_tt_work()
728 struct usb_device *hdev = hub->hdev; in hub_tt_work()
732 next = hub->tt.clear_list.next; in hub_tt_work()
737 spin_unlock_irqrestore (&hub->tt.lock, flags); in hub_tt_work()
750 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
752 spin_unlock_irqrestore (&hub->tt.lock, flags); in hub_tt_work()
767 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, in usb_hub_set_port_power() argument
781 set_bit(port1, hub->power_bits); in usb_hub_set_port_power()
783 clear_bit(port1, hub->power_bits); in usb_hub_set_port_power()
842 static void hub_power_on(struct usb_hub *hub, bool do_delay) in hub_power_on() argument
852 if (hub_is_port_power_switchable(hub)) in hub_power_on()
853 dev_dbg(hub->intfdev, "enabling power on all ports\n"); in hub_power_on()
855 dev_dbg(hub->intfdev, "trying to enable port power on " in hub_power_on()
857 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) in hub_power_on()
858 if (test_bit(port1, hub->power_bits)) in hub_power_on()
859 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); in hub_power_on()
861 usb_clear_port_feature(hub->hdev, port1, in hub_power_on()
864 msleep(hub_power_on_good_delay(hub)); in hub_power_on()
867 static int hub_hub_status(struct usb_hub *hub, in hub_hub_status() argument
872 mutex_lock(&hub->status_mutex); in hub_hub_status()
873 ret = get_hub_status(hub->hdev, &hub->status->hub); in hub_hub_status()
876 dev_err(hub->intfdev, in hub_hub_status()
879 *status = le16_to_cpu(hub->status->hub.wHubStatus); in hub_hub_status()
880 *change = le16_to_cpu(hub->status->hub.wHubChange); in hub_hub_status()
883 mutex_unlock(&hub->status_mutex); in hub_hub_status()
887 static int hub_set_port_link_state(struct usb_hub *hub, int port1, in hub_set_port_link_state() argument
890 return set_port_feature(hub->hdev, in hub_set_port_link_state()
900 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) in hub_port_disable() argument
902 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_disable()
903 struct usb_device *hdev = hub->hdev; in hub_port_disable()
906 if (!hub->error) { in hub_port_disable()
907 if (hub_is_superspeed(hub->hdev)) { in hub_port_disable()
908 hub_usb3_port_prepare_disable(hub, port_dev); in hub_port_disable()
909 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_port_disable()
928 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) in hub_port_logical_disconnect() argument
930 dev_dbg(&hub->ports[port1 - 1]->dev, "logical disconnect\n"); in hub_port_logical_disconnect()
931 hub_port_disable(hub, port1, 1); in hub_port_logical_disconnect()
942 set_bit(port1, hub->change_bits); in hub_port_logical_disconnect()
943 kick_hub_wq(hub); in hub_port_logical_disconnect()
960 struct usb_hub *hub; in usb_remove_device() local
965 hub = usb_hub_to_struct_hub(udev->parent); in usb_remove_device()
966 intf = to_usb_interface(hub->intfdev); in usb_remove_device()
969 set_bit(udev->portnum, hub->removed_bits); in usb_remove_device()
970 hub_port_logical_disconnect(hub, udev->portnum); in usb_remove_device()
983 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) in hub_activate() argument
985 struct usb_device *hdev = hub->hdev; in hub_activate()
995 device_lock(hub->intfdev); in hub_activate()
998 if (hub->disconnected) { in hub_activate()
999 device_unlock(hub->intfdev); in hub_activate()
1000 kref_put(&hub->kref, hub_release); in hub_activate()
1007 kref_get(&hub->kref); in hub_activate()
1026 dev_err(hub->intfdev, in hub_activate()
1043 unsigned delay = hub_power_on_good_delay(hub); in hub_activate()
1045 hub_power_on(hub, false); in hub_activate()
1046 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); in hub_activate()
1048 &hub->init_work, in hub_activate()
1053 to_usb_interface(hub->intfdev)); in hub_activate()
1063 &hub->tt, GFP_NOIO); in hub_activate()
1065 dev_err(hub->intfdev, "Host not " in hub_activate()
1068 dev_err(hub->intfdev, "LS/FS devices " in hub_activate()
1073 hub_power_on(hub, true); in hub_activate()
1075 hub_power_on(hub, true); in hub_activate()
1085 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_activate()
1090 status = hub_port_status(hub, port1, &portstatus, &portchange); in hub_activate()
1121 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1126 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1131 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1135 hub_is_superspeed(hub->hdev)) { in hub_activate()
1137 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1145 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()
1205 device_unlock(hub->intfdev); 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()
1226 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); in hub_activate()
1229 device_unlock(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()
1365 maxchild = hub->descriptor->bNbrPorts; in hub_configure()
1369 hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL); in hub_configure()
1370 if (!hub->ports) { in hub_configure()
1375 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in hub_configure()
1391 portstr[i] = hub->descriptor->u.hs.DeviceRemovable in hub_configure()
1425 spin_lock_init (&hub->tt.lock); in hub_configure()
1426 INIT_LIST_HEAD (&hub->tt.clear_list); in hub_configure()
1427 INIT_WORK(&hub->tt.clear_work, hub_tt_work); in hub_configure()
1433 hub->tt.hub = hdev; in hub_configure()
1439 hub->tt.multi = 1; in hub_configure()
1443 hub->tt.hub = hdev; in hub_configure()
1458 hub->tt.think_time = 666; in hub_configure()
1461 8, hub->tt.think_time); in hub_configure()
1465 hub->tt.think_time = 666 * 2; in hub_configure()
1468 16, hub->tt.think_time); in hub_configure()
1471 hub->tt.think_time = 666 * 3; in hub_configure()
1474 24, hub->tt.think_time); in hub_configure()
1477 hub->tt.think_time = 666 * 4; in hub_configure()
1480 32, hub->tt.think_time); in hub_configure()
1486 hub->has_indicators = 1; in hub_configure()
1491 hub->descriptor->bPwrOn2PwrGood * 2); in hub_configure()
1508 hub->mA_per_port = full_load; in hub_configure()
1510 hub->mA_per_port = hdev->bus_mA; in hub_configure()
1511 hub->limited_power = 1; in hub_configure()
1515 hub->descriptor->bHubContrCurrent; in hub_configure()
1518 hub->descriptor->bHubContrCurrent); in hub_configure()
1519 hub->limited_power = 1; in hub_configure()
1525 hub->mA_per_port = unit_load; /* 7.2.1 */ in hub_configure()
1530 hub->mA_per_port = full_load; in hub_configure()
1532 if (hub->mA_per_port < full_load) in hub_configure()
1534 hub->mA_per_port); in hub_configure()
1536 ret = hub_hub_status(hub, &hubstatus, &hubchange); in hub_configure()
1561 if (maxp > sizeof(*hub->buffer)) in hub_configure()
1562 maxp = sizeof(*hub->buffer); in hub_configure()
1564 hub->urb = usb_alloc_urb(0, GFP_KERNEL); in hub_configure()
1565 if (!hub->urb) { in hub_configure()
1570 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, in hub_configure()
1571 hub, endpoint->bInterval); in hub_configure()
1574 if (hub->has_indicators && blinkenlights) in hub_configure()
1575 hub->indicator[0] = INDICATOR_CYCLE; in hub_configure()
1579 ret = usb_hub_create_port_device(hub, i + 1); in hub_configure()
1581 dev_err(hub->intfdev, in hub_configure()
1588 struct usb_port *port_dev = hub->ports[i]; in hub_configure()
1602 &hub->tt, GFP_KERNEL); in hub_configure()
1609 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); in hub_configure()
1611 hub_activate(hub, HUB_INIT); in hub_configure()
1623 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); in hub_release() local
1625 usb_put_dev(hub->hdev); in hub_release()
1626 usb_put_intf(to_usb_interface(hub->intfdev)); in hub_release()
1627 kfree(hub); in hub_release()
1634 struct usb_hub *hub = usb_get_intfdata(intf); in hub_disconnect() local
1642 hub->disconnected = 1; in hub_disconnect()
1645 hub->error = 0; in hub_disconnect()
1646 hub_quiesce(hub, HUB_DISCONNECT); in hub_disconnect()
1658 usb_hub_remove_port_device(hub, port1); in hub_disconnect()
1662 if (hub->hdev->speed == USB_SPEED_HIGH) in hub_disconnect()
1665 usb_free_urb(hub->urb); in hub_disconnect()
1666 kfree(hub->ports); in hub_disconnect()
1667 kfree(hub->descriptor); in hub_disconnect()
1668 kfree(hub->status); in hub_disconnect()
1669 kfree(hub->buffer); in hub_disconnect()
1672 kref_put(&hub->kref, hub_release); in hub_disconnect()
1680 struct usb_hub *hub; in hub_probe() local
1775 hub = kzalloc(sizeof(*hub), GFP_KERNEL); in hub_probe()
1776 if (!hub) { in hub_probe()
1781 kref_init(&hub->kref); in hub_probe()
1782 hub->intfdev = &intf->dev; in hub_probe()
1783 hub->hdev = hdev; in hub_probe()
1784 INIT_DELAYED_WORK(&hub->leds, led_work); in hub_probe()
1785 INIT_DELAYED_WORK(&hub->init_work, NULL); in hub_probe()
1786 INIT_WORK(&hub->events, hub_event); in hub_probe()
1790 usb_set_intfdata (intf, hub); in hub_probe()
1798 hub->quirk_check_port_auto_suspend = 1; in hub_probe()
1800 if (hub_configure(hub, endpoint) >= 0) in hub_probe()
1811 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in hub_ioctl() local
1825 if (hub->ports[i]->child == NULL) in hub_ioctl()
1829 hub->ports[i]->child->devnum; in hub_ioctl()
1849 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in find_port_owner() local
1859 *ppowner = &(hub->ports[port1 - 1]->port_owner); in find_port_owner()
1898 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_release_all_ports() local
1902 if (hub->ports[n]->port_owner == owner) in usb_hub_release_all_ports()
1903 hub->ports[n]->port_owner = NULL; in usb_hub_release_all_ports()
1911 struct usb_hub *hub; in usb_device_is_owned() local
1915 hub = usb_hub_to_struct_hub(udev->parent); in usb_device_is_owned()
1916 return !!hub->ports[udev->portnum - 1]->port_owner; in usb_device_is_owned()
1921 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in recursively_mark_NOTATTACHED() local
1925 if (hub->ports[i]->child) in recursively_mark_NOTATTACHED()
1926 recursively_mark_NOTATTACHED(hub->ports[i]->child); in recursively_mark_NOTATTACHED()
2077 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in hub_disconnect_children() local
2082 if (hub->ports[i]->child) in hub_disconnect_children()
2083 usb_disconnect(&hub->ports[i]->child); in hub_disconnect_children()
2107 struct usb_hub *hub = NULL; in usb_disconnect() local
2138 hub = usb_hub_to_struct_hub(udev->parent); in usb_disconnect()
2139 port_dev = hub->ports[port1 - 1]; in usb_disconnect()
2148 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2171 if (port_dev && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2330 struct usb_hub *hub; in set_usb_port_removable() local
2338 hub = usb_hub_to_struct_hub(udev->parent); in set_usb_port_removable()
2340 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in set_usb_port_removable()
2346 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) in set_usb_port_removable()
2350 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) in set_usb_port_removable()
2364 switch (hub->ports[udev->portnum - 1]->connect_type) { in set_usb_port_removable()
2459 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_new_device() local
2461 struct usb_port *port_dev = hub->ports[port1 - 1]; in usb_new_device()
2475 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_new_device()
2566 static unsigned hub_is_wusb(struct usb_hub *hub) in hub_is_wusb() argument
2569 if (hub->hdev->parent != NULL) /* not a root hub? */ in hub_is_wusb()
2571 hcd = container_of(hub->hdev->bus, struct usb_hcd, self); in hub_is_wusb()
2606 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, in hub_port_warm_reset_required() argument
2611 if (!hub_is_superspeed(hub->hdev)) in hub_port_warm_reset_required()
2614 if (test_bit(port1, hub->warm_reset_bits)) in hub_port_warm_reset_required()
2622 static int hub_port_wait_reset(struct usb_hub *hub, int port1, in hub_port_wait_reset() argument
2636 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_wait_reset()
2655 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_port_wait_reset()
2663 if (hub_port_warm_reset_required(hub, port1, portstatus)) in hub_port_wait_reset()
2674 if (!hub_is_superspeed(hub->hdev) && in hub_port_wait_reset()
2676 usb_clear_port_feature(hub->hdev, port1, in hub_port_wait_reset()
2687 if (hub_is_wusb(hub)) in hub_port_wait_reset()
2689 else if (hub_is_superspeed(hub->hdev)) in hub_port_wait_reset()
2701 static int hub_port_reset(struct usb_hub *hub, int port1, in hub_port_reset() argument
2706 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_reset()
2708 if (!hub_is_superspeed(hub->hdev)) { in hub_port_reset()
2710 dev_err(hub->intfdev, "only USB3 hub support " in hub_port_reset()
2723 if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) in hub_port_reset()
2724 if (hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2728 clear_bit(port1, hub->warm_reset_bits); in hub_port_reset()
2732 status = set_port_feature(hub->hdev, port1, (warm ? in hub_port_reset()
2742 status = hub_port_wait_reset(hub, port1, udev, delay, in hub_port_reset()
2745 dev_dbg(hub->intfdev, in hub_port_reset()
2752 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2755 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2758 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2760 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2762 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2769 if (hub_port_status(hub, port1, in hub_port_reset()
2773 if (!hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2817 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2824 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) in port_is_power_on() argument
2828 if (hub_is_superspeed(hub->hdev)) { in port_is_power_on()
2856 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) in port_is_suspended() argument
2860 if (hub_is_superspeed(hub->hdev)) { in port_is_suspended()
2876 struct usb_hub *hub, int port1, in check_port_resume_type() argument
2879 struct usb_port *port_dev = hub->ports[port1 - 1]; in check_port_resume_type()
2883 && hub_port_warm_reset_required(hub, port1, portstatus)) { in check_port_resume_type()
2887 else if (status || port_is_suspended(hub, portstatus) || in check_port_resume_type()
2888 !port_is_power_on(hub, portstatus) || in check_port_resume_type()
2911 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
2914 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3018 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in wakeup_enabled_descendants() local
3021 (hub ? hub->wakeup_enabled_descendants : 0); in wakeup_enabled_descendants()
3074 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_suspend() local
3075 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_suspend()
3117 if (hub_is_superspeed(hub->hdev)) in usb_port_suspend()
3118 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); in usb_port_suspend()
3132 status = set_port_feature(hub->hdev, port1, in usb_port_suspend()
3171 && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_port_suspend()
3174 usb_mark_last_busy(hub->hdev); in usb_port_suspend()
3296 struct usb_hub *hub, int *port1, in wait_for_ss_port_enable() argument
3306 status = hub_port_status(hub, *port1, portstatus, portchange); in wait_for_ss_port_enable()
3347 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_resume() local
3348 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_resume()
3353 if (!test_and_set_bit(port1, hub->child_usage_bits)) { in usb_port_resume()
3365 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3366 if (status == 0 && !port_is_suspended(hub, portstatus)) in usb_port_resume()
3370 if (hub_is_superspeed(hub->hdev)) in usb_port_resume()
3371 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); in usb_port_resume()
3373 status = usb_clear_port_feature(hub->hdev, in usb_port_resume()
3387 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3396 if (hub_is_superspeed(hub->hdev)) { in usb_port_resume()
3398 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3402 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3407 if (udev->persist_enabled && hub_is_superspeed(hub->hdev)) in usb_port_resume()
3408 status = wait_for_ss_port_enable(udev, hub, &port1, &portchange, in usb_port_resume()
3412 hub, port1, status, portchange, portstatus); in usb_port_resume()
3417 hub_port_logical_disconnect(hub, port1); in usb_port_resume()
3453 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3457 struct usb_port *port_dev = hub->ports[port - 1]; in hub_handle_remote_wakeup()
3463 hdev = hub->hdev; in hub_handle_remote_wakeup()
3487 hub_port_disable(hub, port, 1); in hub_handle_remote_wakeup()
3495 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3503 static int check_ports_changed(struct usb_hub *hub) in check_ports_changed() argument
3507 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { in check_ports_changed()
3511 status = hub_port_status(hub, port1, &portstatus, &portchange); in check_ports_changed()
3520 struct usb_hub *hub = usb_get_intfdata (intf); in hub_suspend() local
3521 struct usb_device *hdev = hub->hdev; in hub_suspend()
3529 hub->wakeup_enabled_descendants = 0; in hub_suspend()
3531 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_suspend()
3541 hub->wakeup_enabled_descendants += in hub_suspend()
3545 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { in hub_suspend()
3547 if (check_ports_changed(hub)) { in hub_suspend()
3569 hub_quiesce(hub, HUB_SUSPEND); in hub_suspend()
3575 struct usb_hub *hub = usb_get_intfdata(intf); in hub_resume() local
3578 hub_activate(hub, HUB_RESUME); in hub_resume()
3584 struct usb_hub *hub = usb_get_intfdata(intf); in hub_reset_resume() local
3587 hub_activate(hub, HUB_RESET_RESUME); in hub_reset_resume()
4024 static void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4031 ret = hub_set_port_link_state(hub, port_dev->portnum, in hub_usb3_port_prepare_disable()
4050 static inline void hub_usb3_port_prepare_disable(struct usb_hub *hub, in hub_usb3_port_prepare_disable() argument
4080 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
4104 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) in hub_port_debounce() argument
4110 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_debounce()
4113 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_debounce()
4130 usb_clear_port_feature(hub->hdev, port1, in hub_port_debounce()
4199 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in hub_set_initial_usb2_lpm_policy() local
4205 if (hub) in hub_set_initial_usb2_lpm_policy()
4206 connect_type = hub->ports[udev->portnum - 1]->connect_type; in hub_set_initial_usb2_lpm_policy()
4240 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, in hub_port_init() argument
4243 struct usb_device *hdev = hub->hdev; in hub_port_init()
4269 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4326 if (!hub->tt.hub) { in hub_port_init()
4331 udev->tt = &hub->tt; in hub_port_init()
4407 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4491 hub_port_reset(hub, port1, udev, in hub_port_init()
4544 hub_port_disable(hub, port1, 0); in hub_port_init()
4552 check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1) in check_highspeed() argument
4570 if (hub->has_indicators) { in check_highspeed()
4571 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; in check_highspeed()
4573 &hub->leds, 0); in check_highspeed()
4580 hub_power_remaining (struct usb_hub *hub) in hub_power_remaining() argument
4582 struct usb_device *hdev = hub->hdev; in hub_power_remaining()
4586 if (!hub->limited_power) in hub_power_remaining()
4589 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; in hub_power_remaining()
4591 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_power_remaining()
4613 if (delta > hub->mA_per_port) in hub_power_remaining()
4615 delta, hub->mA_per_port); in hub_power_remaining()
4619 dev_warn(hub->intfdev, "%dmA over power budget!\n", in hub_power_remaining()
4626 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, in hub_port_connect() argument
4632 struct usb_device *hdev = hub->hdev; in hub_port_connect()
4634 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect()
4650 clear_bit(port1, hub->removed_bits); in hub_port_connect()
4654 status = hub_port_debounce_be_stable(hub, port1); in hub_port_connect()
4671 test_bit(port1, hub->removed_bits)) { in hub_port_connect()
4674 if (hub_is_port_power_switchable(hub) in hub_port_connect()
4675 && !port_is_power_on(hub, portstatus)) in hub_port_connect()
4682 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4701 udev->bus_mA = hub->mA_per_port; in hub_port_connect()
4703 udev->wusb = hub_is_wusb(hub); in hub_port_connect()
4706 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4719 status = hub_port_init(hub, udev, port1, i); in hub_port_connect()
4747 if (hub->has_indicators) { in hub_port_connect()
4748 hub->indicator[port1-1] = in hub_port_connect()
4752 &hub->leds, 0); in hub_port_connect()
4763 check_highspeed (hub, udev, port1); in hub_port_connect()
4804 status = hub_power_remaining(hub); in hub_port_connect()
4806 dev_dbg(hub->intfdev, "%dmA power budget left\n", status); in hub_port_connect()
4811 hub_port_disable(hub, port1, 1); in hub_port_connect()
4823 usb_hub_set_port_power(hdev, hub, port1, false); in hub_port_connect()
4824 msleep(2 * hub_power_on_good_delay(hub)); in hub_port_connect()
4825 usb_hub_set_port_power(hdev, hub, port1, true); in hub_port_connect()
4826 msleep(hub_power_on_good_delay(hub)); in hub_port_connect()
4829 if (hub->hdev->parent || in hub_port_connect()
4838 hub_port_disable(hub, port1, 1); in hub_port_connect()
4839 if (hcd->driver->relinquish_port && !hub->hdev->parent) { in hub_port_connect()
4853 static void hub_port_connect_change(struct usb_hub *hub, int port1, in hub_port_connect_change() argument
4857 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect_change()
4862 portchange, portspeed(hub, portstatus)); in hub_port_connect_change()
4864 if (hub->has_indicators) { in hub_port_connect_change()
4865 set_port_led(hub, port1, HUB_LED_AUTO); in hub_port_connect_change()
4866 hub->indicator[port1-1] = INDICATOR_AUTO; in hub_port_connect_change()
4871 if (hub->hdev->bus->is_b_host) in hub_port_connect_change()
4895 clear_bit(port1, hub->change_bits); in hub_port_connect_change()
4902 hub_port_connect(hub, port1, portstatus, portchange); in hub_port_connect_change()
4906 static void port_event(struct usb_hub *hub, int port1) in port_event() argument
4910 struct usb_port *port_dev = hub->ports[port1 - 1]; in port_event()
4912 struct usb_device *hdev = hub->hdev; in port_event()
4915 connect_change = test_bit(port1, hub->change_bits); in port_event()
4916 clear_bit(port1, hub->event_bits); in port_event()
4917 clear_bit(port1, hub->wakeup_bits); in port_event()
4919 if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) in port_event()
4952 hub_power_on(hub, true); in port_event()
4953 hub_port_status(hub, port1, &status, &unused); in port_event()
4983 if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange)) in port_event()
4990 if (hub_port_warm_reset_required(hub, port1, portstatus)) { in port_event()
4994 if (hub_port_reset(hub, port1, NULL, in port_event()
4996 hub_port_disable(hub, port1, 1); in port_event()
5012 if (reset_device || (udev && hub_is_superspeed(hub->hdev) in port_event()
5024 hub_port_connect_change(hub, port1, portstatus, portchange); in port_event()
5031 struct usb_hub *hub; in hub_event() local
5037 hub = container_of(work, struct usb_hub, events); in hub_event()
5038 hdev = hub->hdev; in hub_event()
5039 hub_dev = hub->intfdev; in hub_event()
5045 (u16) hub->change_bits[0], in hub_event()
5046 (u16) hub->event_bits[0]); in hub_event()
5051 if (unlikely(hub->disconnected)) in hub_event()
5056 hub->error = -ENODEV; in hub_event()
5057 hub_quiesce(hub, HUB_DISCONNECT); in hub_event()
5069 if (hub->quiescing) in hub_event()
5072 if (hub->error) { in hub_event()
5073 dev_dbg(hub_dev, "resetting for error %d\n", hub->error); in hub_event()
5081 hub->nerrors = 0; in hub_event()
5082 hub->error = 0; in hub_event()
5087 struct usb_port *port_dev = hub->ports[i - 1]; in hub_event()
5089 if (test_bit(i, hub->event_bits) in hub_event()
5090 || test_bit(i, hub->change_bits) in hub_event()
5091 || test_bit(i, hub->wakeup_bits)) { in hub_event()
5104 port_event(hub, i); in hub_event()
5111 if (test_and_clear_bit(0, hub->event_bits) == 0) in hub_event()
5113 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) in hub_event()
5121 hub->limited_power = 1; in hub_event()
5123 hub->limited_power = 0; in hub_event()
5132 hub_power_on(hub, true); in hub_event()
5133 hub_hub_status(hub, &status, &unused); in hub_event()
5147 kref_put(&hub->kref, hub_release); in hub_event()
5517 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_reset_device() local
5532 port_dev = hub->ports[udev->portnum - 1]; in usb_reset_device()
5649 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_find_child() local
5653 return hub->ports[port1 - 1]->child; in usb_hub_find_child()
5660 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_adjust_deviceremovable() local
5664 if (!hub) in usb_hub_adjust_deviceremovable()
5669 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5685 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5714 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_get_hub_port_acpi_handle() local
5716 if (!hub) in usb_get_hub_port_acpi_handle()
5719 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); in usb_get_hub_port_acpi_handle()