Lines Matching refs:hub

105 static inline char *portspeed(struct usb_hub *hub, int portstatus)  in portspeed()  argument
107 if (hub_is_superspeed(hub->hdev)) in portspeed()
173 struct usb_hub *hub, in usb_set_lpm_mel() argument
191 (hub->descriptor->u.ss.bHubHdrDecLat * 100); in usb_set_lpm_mel()
218 struct usb_hub *hub, in usb_set_lpm_pel() argument
294 struct usb_hub *hub; in usb_set_lpm_parameters() local
304 hub = usb_hub_to_struct_hub(udev->parent); in usb_set_lpm_parameters()
308 if (!hub) in usb_set_lpm_parameters()
317 hub, &udev->parent->u1_params, hub_u1_del); in usb_set_lpm_parameters()
320 hub, &udev->parent->u2_params, hub_u2_del); in usb_set_lpm_parameters()
342 hub, &udev->parent->u1_params, hub_u1_del, in usb_set_lpm_parameters()
351 hub, &udev->parent->u2_params, hub_u2_del, in usb_set_lpm_parameters()
433 static void set_port_led(struct usb_hub *hub, int port1, int selector) in set_port_led() argument
435 struct usb_port *port_dev = hub->ports[port1 - 1]; in set_port_led()
438 status = set_port_feature(hub->hdev, (selector << 8) | port1, in set_port_led()
448 struct usb_hub *hub = in led_work() local
450 struct usb_device *hdev = hub->hdev; in led_work()
455 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing) in led_work()
463 switch (hub->indicator[i]) { in led_work()
502 set_port_led(hub, i + 1, selector); in led_work()
503 hub->indicator[i] = mode; in led_work()
508 set_port_led(hub, cursor + 1, HUB_LED_GREEN); in led_work()
509 hub->indicator[cursor] = INDICATOR_CYCLE; in led_work()
514 &hub->leds, LED_CYCLE_PERIOD); in led_work()
555 static int hub_port_status(struct usb_hub *hub, int port1, in hub_port_status() argument
560 mutex_lock(&hub->status_mutex); in hub_port_status()
561 ret = get_port_status(hub->hdev, port1, &hub->status->port); in hub_port_status()
564 dev_err(hub->intfdev, in hub_port_status()
569 *status = le16_to_cpu(hub->status->port.wPortStatus); in hub_port_status()
570 *change = le16_to_cpu(hub->status->port.wPortChange); in hub_port_status()
574 mutex_unlock(&hub->status_mutex); in hub_port_status()
578 static void kick_hub_wq(struct usb_hub *hub) in kick_hub_wq() argument
582 if (hub->disconnected || work_pending(&hub->events)) in kick_hub_wq()
593 intf = to_usb_interface(hub->intfdev); in kick_hub_wq()
595 kref_get(&hub->kref); in kick_hub_wq()
597 if (queue_work(hub_wq, &hub->events)) in kick_hub_wq()
602 kref_put(&hub->kref, hub_release); in kick_hub_wq()
607 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_kick_hub_wq() local
609 if (hub) in usb_kick_hub_wq()
610 kick_hub_wq(hub); in usb_kick_hub_wq()
624 struct usb_hub *hub; in usb_wakeup_notification() local
629 hub = usb_hub_to_struct_hub(hdev); in usb_wakeup_notification()
630 if (hub) { in usb_wakeup_notification()
631 set_bit(portnum, hub->wakeup_bits); in usb_wakeup_notification()
632 kick_hub_wq(hub); in usb_wakeup_notification()
640 struct usb_hub *hub = urb->context; in hub_irq() local
653 dev_dbg(hub->intfdev, "transfer --> %d\n", status); in hub_irq()
654 if ((++hub->nerrors < 10) || hub->error) in hub_irq()
656 hub->error = status; in hub_irq()
663 bits |= ((unsigned long) ((*hub->buffer)[i])) in hub_irq()
665 hub->event_bits[0] = bits; in hub_irq()
669 hub->nerrors = 0; in hub_irq()
672 kick_hub_wq(hub); in hub_irq()
675 if (hub->quiescing) in hub_irq()
678 status = usb_submit_urb(hub->urb, GFP_ATOMIC); in hub_irq()
680 dev_err(hub->intfdev, "resubmit --> %d\n", status); in hub_irq()
709 struct usb_hub *hub = in hub_tt_work() local
713 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
714 while (!list_empty(&hub->tt.clear_list)) { in hub_tt_work()
717 struct usb_device *hdev = hub->hdev; in hub_tt_work()
721 next = hub->tt.clear_list.next; in hub_tt_work()
726 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
739 spin_lock_irqsave(&hub->tt.lock, flags); in hub_tt_work()
741 spin_unlock_irqrestore(&hub->tt.lock, flags); in hub_tt_work()
756 int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub, in usb_hub_set_port_power() argument
770 set_bit(port1, hub->power_bits); in usb_hub_set_port_power()
772 clear_bit(port1, hub->power_bits); in usb_hub_set_port_power()
832 static void hub_power_on(struct usb_hub *hub, bool do_delay) in hub_power_on() argument
842 if (hub_is_port_power_switchable(hub)) in hub_power_on()
843 dev_dbg(hub->intfdev, "enabling power on all ports\n"); in hub_power_on()
845 dev_dbg(hub->intfdev, "trying to enable port power on " in hub_power_on()
847 for (port1 = 1; port1 <= hub->hdev->maxchild; port1++) in hub_power_on()
848 if (test_bit(port1, hub->power_bits)) in hub_power_on()
849 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER); in hub_power_on()
851 usb_clear_port_feature(hub->hdev, port1, in hub_power_on()
854 msleep(hub_power_on_good_delay(hub)); in hub_power_on()
857 static int hub_hub_status(struct usb_hub *hub, in hub_hub_status() argument
862 mutex_lock(&hub->status_mutex); in hub_hub_status()
863 ret = get_hub_status(hub->hdev, &hub->status->hub); in hub_hub_status()
866 dev_err(hub->intfdev, in hub_hub_status()
869 *status = le16_to_cpu(hub->status->hub.wHubStatus); in hub_hub_status()
870 *change = le16_to_cpu(hub->status->hub.wHubChange); in hub_hub_status()
873 mutex_unlock(&hub->status_mutex); in hub_hub_status()
877 static int hub_set_port_link_state(struct usb_hub *hub, int port1, in hub_set_port_link_state() argument
880 return set_port_feature(hub->hdev, in hub_set_port_link_state()
895 static int hub_usb3_port_disable(struct usb_hub *hub, int port1) in hub_usb3_port_disable() argument
901 if (!hub_is_superspeed(hub->hdev)) in hub_usb3_port_disable()
904 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_usb3_port_disable()
918 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_usb3_port_disable()
923 ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); in hub_usb3_port_disable()
929 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_usb3_port_disable()
941 dev_warn(&hub->ports[port1 - 1]->dev, in hub_usb3_port_disable()
944 return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT); in hub_usb3_port_disable()
947 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) in hub_port_disable() argument
949 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_disable()
950 struct usb_device *hdev = hub->hdev; in hub_port_disable()
955 if (!hub->error) { in hub_port_disable()
956 if (hub_is_superspeed(hub->hdev)) in hub_port_disable()
957 ret = hub_usb3_port_disable(hub, port1); in hub_port_disable()
972 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1) in hub_port_logical_disconnect() argument
974 dev_dbg(&hub->ports[port1 - 1]->dev, "logical disconnect\n"); in hub_port_logical_disconnect()
975 hub_port_disable(hub, port1, 1); in hub_port_logical_disconnect()
986 set_bit(port1, hub->change_bits); in hub_port_logical_disconnect()
987 kick_hub_wq(hub); in hub_port_logical_disconnect()
1004 struct usb_hub *hub; in usb_remove_device() local
1009 hub = usb_hub_to_struct_hub(udev->parent); in usb_remove_device()
1010 intf = to_usb_interface(hub->intfdev); in usb_remove_device()
1013 set_bit(udev->portnum, hub->removed_bits); in usb_remove_device()
1014 hub_port_logical_disconnect(hub, udev->portnum); in usb_remove_device()
1027 static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) in hub_activate() argument
1029 struct usb_device *hdev = hub->hdev; in hub_activate()
1039 device_lock(hub->intfdev); in hub_activate()
1042 if (hub->disconnected) { in hub_activate()
1043 device_unlock(hub->intfdev); in hub_activate()
1044 kref_put(&hub->kref, hub_release); in hub_activate()
1051 kref_get(&hub->kref); in hub_activate()
1070 dev_err(hub->intfdev, in hub_activate()
1087 delay = hub_power_on_good_delay(hub); in hub_activate()
1089 hub_power_on(hub, false); in hub_activate()
1090 INIT_DELAYED_WORK(&hub->init_work, hub_init_func2); in hub_activate()
1092 &hub->init_work, in hub_activate()
1097 to_usb_interface(hub->intfdev)); in hub_activate()
1107 &hub->tt, GFP_NOIO); in hub_activate()
1109 dev_err(hub->intfdev, "Host not " in hub_activate()
1112 dev_err(hub->intfdev, "LS/FS devices " in hub_activate()
1117 hub_power_on(hub, true); in hub_activate()
1119 hub_power_on(hub, true); in hub_activate()
1129 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_activate()
1134 status = hub_port_status(hub, port1, &portstatus, &portchange); in hub_activate()
1165 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1170 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1175 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1179 hub_is_superspeed(hub->hdev)) { in hub_activate()
1181 usb_clear_port_feature(hub->hdev, port1, in hub_activate()
1189 clear_bit(port1, hub->removed_bits); in hub_activate()
1197 set_bit(port1, hub->change_bits); in hub_activate()
1211 if (portchange || (hub_is_superspeed(hub->hdev) && in hub_activate()
1213 set_bit(port1, hub->change_bits); in hub_activate()
1222 if (test_bit(port1, hub->power_bits)) in hub_activate()
1223 set_bit(port1, hub->change_bits); in hub_activate()
1228 set_bit(port1, hub->change_bits); in hub_activate()
1245 INIT_DELAYED_WORK(&hub->init_work, hub_init_func3); in hub_activate()
1247 &hub->init_work, in hub_activate()
1249 device_unlock(hub->intfdev); in hub_activate()
1256 hub->quiescing = 0; in hub_activate()
1258 status = usb_submit_urb(hub->urb, GFP_NOIO); in hub_activate()
1260 dev_err(hub->intfdev, "activate --> %d\n", status); in hub_activate()
1261 if (hub->has_indicators && blinkenlights) in hub_activate()
1263 &hub->leds, LED_CYCLE_PERIOD); in hub_activate()
1266 kick_hub_wq(hub); in hub_activate()
1270 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); in hub_activate()
1273 device_unlock(hub->intfdev); in hub_activate()
1275 kref_put(&hub->kref, hub_release); in hub_activate()
1281 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func2() local
1283 hub_activate(hub, HUB_INIT2); in hub_init_func2()
1288 struct usb_hub *hub = container_of(ws, struct usb_hub, init_work.work); in hub_init_func3() local
1290 hub_activate(hub, HUB_INIT3); in hub_init_func3()
1297 static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type) in hub_quiesce() argument
1299 struct usb_device *hdev = hub->hdev; in hub_quiesce()
1302 cancel_delayed_work_sync(&hub->init_work); in hub_quiesce()
1305 hub->quiescing = 1; in hub_quiesce()
1310 if (hub->ports[i]->child) in hub_quiesce()
1311 usb_disconnect(&hub->ports[i]->child); in hub_quiesce()
1316 usb_kill_urb(hub->urb); in hub_quiesce()
1317 if (hub->has_indicators) in hub_quiesce()
1318 cancel_delayed_work_sync(&hub->leds); in hub_quiesce()
1319 if (hub->tt.hub) in hub_quiesce()
1320 flush_work(&hub->tt.clear_work); in hub_quiesce()
1323 static void hub_pm_barrier_for_all_ports(struct usb_hub *hub) in hub_pm_barrier_for_all_ports() argument
1327 for (i = 0; i < hub->hdev->maxchild; ++i) in hub_pm_barrier_for_all_ports()
1328 pm_runtime_barrier(&hub->ports[i]->dev); in hub_pm_barrier_for_all_ports()
1334 struct usb_hub *hub = usb_get_intfdata(intf); in hub_pre_reset() local
1336 hub_quiesce(hub, HUB_PRE_RESET); in hub_pre_reset()
1337 hub->in_reset = 1; in hub_pre_reset()
1338 hub_pm_barrier_for_all_ports(hub); in hub_pre_reset()
1345 struct usb_hub *hub = usb_get_intfdata(intf); in hub_post_reset() local
1347 hub->in_reset = 0; in hub_post_reset()
1348 hub_pm_barrier_for_all_ports(hub); in hub_post_reset()
1349 hub_activate(hub, HUB_POST_RESET); in hub_post_reset()
1353 static int hub_configure(struct usb_hub *hub, in hub_configure() argument
1357 struct usb_device *hdev = hub->hdev; in hub_configure()
1358 struct device *hub_dev = hub->intfdev; in hub_configure()
1368 hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL); in hub_configure()
1369 if (!hub->buffer) { in hub_configure()
1374 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL); in hub_configure()
1375 if (!hub->status) { in hub_configure()
1379 mutex_init(&hub->status_mutex); in hub_configure()
1381 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); in hub_configure()
1382 if (!hub->descriptor) { in hub_configure()
1391 ret = get_hub_descriptor(hdev, hub->descriptor); in hub_configure()
1395 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { in hub_configure()
1399 } else if (hub->descriptor->bNbrPorts == 0) { in hub_configure()
1405 maxchild = hub->descriptor->bNbrPorts; in hub_configure()
1409 hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL); in hub_configure()
1410 if (!hub->ports) { in hub_configure()
1415 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in hub_configure()
1430 portstr[i] = hub->descriptor->u.hs.DeviceRemovable in hub_configure()
1464 spin_lock_init(&hub->tt.lock); in hub_configure()
1465 INIT_LIST_HEAD(&hub->tt.clear_list); in hub_configure()
1466 INIT_WORK(&hub->tt.clear_work, hub_tt_work); in hub_configure()
1472 hub->tt.hub = hdev; in hub_configure()
1478 hub->tt.multi = 1; in hub_configure()
1482 hub->tt.hub = hdev; in hub_configure()
1497 hub->tt.think_time = 666; in hub_configure()
1500 8, hub->tt.think_time); in hub_configure()
1504 hub->tt.think_time = 666 * 2; in hub_configure()
1507 16, hub->tt.think_time); in hub_configure()
1510 hub->tt.think_time = 666 * 3; in hub_configure()
1513 24, hub->tt.think_time); in hub_configure()
1516 hub->tt.think_time = 666 * 4; in hub_configure()
1519 32, hub->tt.think_time); in hub_configure()
1525 hub->has_indicators = 1; in hub_configure()
1530 hub->descriptor->bPwrOn2PwrGood * 2); in hub_configure()
1547 hub->mA_per_port = full_load; in hub_configure()
1549 hub->mA_per_port = hdev->bus_mA; in hub_configure()
1550 hub->limited_power = 1; in hub_configure()
1554 hub->descriptor->bHubContrCurrent; in hub_configure()
1557 hub->descriptor->bHubContrCurrent); in hub_configure()
1558 hub->limited_power = 1; in hub_configure()
1564 hub->mA_per_port = unit_load; /* 7.2.1 */ in hub_configure()
1569 hub->mA_per_port = full_load; in hub_configure()
1571 if (hub->mA_per_port < full_load) in hub_configure()
1573 hub->mA_per_port); in hub_configure()
1575 ret = hub_hub_status(hub, &hubstatus, &hubchange); in hub_configure()
1600 if (maxp > sizeof(*hub->buffer)) in hub_configure()
1601 maxp = sizeof(*hub->buffer); in hub_configure()
1603 hub->urb = usb_alloc_urb(0, GFP_KERNEL); in hub_configure()
1604 if (!hub->urb) { in hub_configure()
1609 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq, in hub_configure()
1610 hub, endpoint->bInterval); in hub_configure()
1613 if (hub->has_indicators && blinkenlights) in hub_configure()
1614 hub->indicator[0] = INDICATOR_CYCLE; in hub_configure()
1618 ret = usb_hub_create_port_device(hub, i + 1); in hub_configure()
1620 dev_err(hub->intfdev, in hub_configure()
1627 struct usb_port *port_dev = hub->ports[i]; in hub_configure()
1641 &hub->tt, GFP_KERNEL); in hub_configure()
1648 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); in hub_configure()
1650 hub_activate(hub, HUB_INIT); in hub_configure()
1662 struct usb_hub *hub = container_of(kref, struct usb_hub, kref); in hub_release() local
1664 usb_put_dev(hub->hdev); in hub_release()
1665 usb_put_intf(to_usb_interface(hub->intfdev)); in hub_release()
1666 kfree(hub); in hub_release()
1673 struct usb_hub *hub = usb_get_intfdata(intf); in hub_disconnect() local
1681 hub->disconnected = 1; in hub_disconnect()
1684 hub->error = 0; in hub_disconnect()
1685 hub_quiesce(hub, HUB_DISCONNECT); in hub_disconnect()
1697 usb_hub_remove_port_device(hub, port1); in hub_disconnect()
1701 if (hub->hdev->speed == USB_SPEED_HIGH) in hub_disconnect()
1704 usb_free_urb(hub->urb); in hub_disconnect()
1705 kfree(hub->ports); in hub_disconnect()
1706 kfree(hub->descriptor); in hub_disconnect()
1707 kfree(hub->status); in hub_disconnect()
1708 kfree(hub->buffer); in hub_disconnect()
1711 kref_put(&hub->kref, hub_release); in hub_disconnect()
1719 struct usb_hub *hub; in hub_probe() local
1814 hub = kzalloc(sizeof(*hub), GFP_KERNEL); in hub_probe()
1815 if (!hub) { in hub_probe()
1820 kref_init(&hub->kref); in hub_probe()
1821 hub->intfdev = &intf->dev; in hub_probe()
1822 hub->hdev = hdev; in hub_probe()
1823 INIT_DELAYED_WORK(&hub->leds, led_work); in hub_probe()
1824 INIT_DELAYED_WORK(&hub->init_work, NULL); in hub_probe()
1825 INIT_WORK(&hub->events, hub_event); in hub_probe()
1829 usb_set_intfdata(intf, hub); in hub_probe()
1837 hub->quirk_check_port_auto_suspend = 1; in hub_probe()
1839 if (hub_configure(hub, endpoint) >= 0) in hub_probe()
1850 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in hub_ioctl() local
1864 if (hub->ports[i]->child == NULL) in hub_ioctl()
1868 hub->ports[i]->child->devnum; in hub_ioctl()
1888 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in find_port_owner() local
1898 *ppowner = &(hub->ports[port1 - 1]->port_owner); in find_port_owner()
1937 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_release_all_ports() local
1941 if (hub->ports[n]->port_owner == owner) in usb_hub_release_all_ports()
1942 hub->ports[n]->port_owner = NULL; in usb_hub_release_all_ports()
1950 struct usb_hub *hub; in usb_device_is_owned() local
1954 hub = usb_hub_to_struct_hub(udev->parent); in usb_device_is_owned()
1955 return !!hub->ports[udev->portnum - 1]->port_owner; in usb_device_is_owned()
1960 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in recursively_mark_NOTATTACHED() local
1964 if (hub->ports[i]->child) in recursively_mark_NOTATTACHED()
1965 recursively_mark_NOTATTACHED(hub->ports[i]->child); in recursively_mark_NOTATTACHED()
2116 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in hub_disconnect_children() local
2121 if (hub->ports[i]->child) in hub_disconnect_children()
2122 usb_disconnect(&hub->ports[i]->child); in hub_disconnect_children()
2146 struct usb_hub *hub = NULL; in usb_disconnect() local
2171 hub = usb_hub_to_struct_hub(udev->parent); in usb_disconnect()
2172 port_dev = hub->ports[port1 - 1]; in usb_disconnect()
2181 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2204 if (port_dev && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_disconnect()
2373 struct usb_hub *hub; in set_usb_port_removable() local
2381 hub = usb_hub_to_struct_hub(udev->parent); in set_usb_port_removable()
2387 switch (hub->ports[udev->portnum - 1]->connect_type) { in set_usb_port_removable()
2403 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); in set_usb_port_removable()
2409 if (le16_to_cpu(hub->descriptor->u.ss.DeviceRemovable) in set_usb_port_removable()
2413 if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) in set_usb_port_removable()
2507 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_new_device() local
2509 struct usb_port *port_dev = hub->ports[port1 - 1]; in usb_new_device()
2523 if (!test_and_set_bit(port1, hub->child_usage_bits)) in usb_new_device()
2617 static unsigned hub_is_wusb(struct usb_hub *hub) in hub_is_wusb() argument
2620 if (hub->hdev->parent != NULL) /* not a root hub? */ in hub_is_wusb()
2622 hcd = container_of(hub->hdev->bus, struct usb_hcd, self); in hub_is_wusb()
2657 static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1, in hub_port_warm_reset_required() argument
2662 if (!hub_is_superspeed(hub->hdev)) in hub_port_warm_reset_required()
2665 if (test_bit(port1, hub->warm_reset_bits)) in hub_port_warm_reset_required()
2673 static int hub_port_wait_reset(struct usb_hub *hub, int port1, in hub_port_wait_reset() argument
2687 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_wait_reset()
2699 dev_dbg(&hub->ports[port1 - 1]->dev, in hub_port_wait_reset()
2707 if (hub_port_warm_reset_required(hub, port1, portstatus)) in hub_port_wait_reset()
2718 if (!hub_is_superspeed(hub->hdev) && in hub_port_wait_reset()
2728 if (hub_is_wusb(hub)) in hub_port_wait_reset()
2730 else if (hub_is_superspeed(hub->hdev)) in hub_port_wait_reset()
2742 static int hub_port_reset(struct usb_hub *hub, int port1, in hub_port_reset() argument
2747 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_reset()
2749 if (!hub_is_superspeed(hub->hdev)) { in hub_port_reset()
2751 dev_err(hub->intfdev, "only USB3 hub support " in hub_port_reset()
2764 if (hub_port_status(hub, port1, &portstatus, &portchange) == 0) in hub_port_reset()
2765 if (hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2769 clear_bit(port1, hub->warm_reset_bits); in hub_port_reset()
2773 status = set_port_feature(hub->hdev, port1, (warm ? in hub_port_reset()
2783 status = hub_port_wait_reset(hub, port1, udev, delay, in hub_port_reset()
2786 dev_dbg(hub->intfdev, in hub_port_reset()
2793 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2796 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2799 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2801 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2803 usb_clear_port_feature(hub->hdev, port1, in hub_port_reset()
2810 if (hub_port_status(hub, port1, in hub_port_reset()
2814 if (!hub_port_warm_reset_required(hub, port1, in hub_port_reset()
2858 if (!hub_is_superspeed(hub->hdev)) in hub_port_reset()
2865 static int port_is_power_on(struct usb_hub *hub, unsigned portstatus) in port_is_power_on() argument
2869 if (hub_is_superspeed(hub->hdev)) { in port_is_power_on()
2897 static int port_is_suspended(struct usb_hub *hub, unsigned portstatus) in port_is_suspended() argument
2901 if (hub_is_superspeed(hub->hdev)) { in port_is_suspended()
2917 struct usb_hub *hub, int port1, in check_port_resume_type() argument
2920 struct usb_port *port_dev = hub->ports[port1 - 1]; in check_port_resume_type()
2926 && hub_port_warm_reset_required(hub, port1, portstatus)) { in check_port_resume_type()
2930 else if (status || port_is_suspended(hub, portstatus) || in check_port_resume_type()
2931 !port_is_power_on(hub, portstatus)) { in check_port_resume_type()
2937 status = hub_port_status(hub, port1, &portstatus, in check_port_resume_type()
2961 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
2964 usb_clear_port_feature(hub->hdev, port1, in check_port_resume_type()
3068 struct usb_hub *hub = usb_hub_to_struct_hub(udev); in wakeup_enabled_descendants() local
3071 (hub ? hub->wakeup_enabled_descendants : 0); in wakeup_enabled_descendants()
3124 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_suspend() local
3125 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_suspend()
3167 if (hub_is_superspeed(hub->hdev)) in usb_port_suspend()
3168 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3); in usb_port_suspend()
3182 status = set_port_feature(hub->hdev, port1, in usb_port_suspend()
3221 && test_and_clear_bit(port1, hub->child_usage_bits)) in usb_port_suspend()
3224 usb_mark_last_busy(hub->hdev); in usb_port_suspend()
3346 struct usb_hub *hub, int *port1, in wait_for_ss_port_enable() argument
3356 status = hub_port_status(hub, *port1, portstatus, portchange); in wait_for_ss_port_enable()
3397 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_port_resume() local
3398 struct usb_port *port_dev = hub->ports[udev->portnum - 1]; in usb_port_resume()
3403 if (!test_and_set_bit(port1, hub->child_usage_bits)) { in usb_port_resume()
3415 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3416 if (status == 0 && !port_is_suspended(hub, portstatus)) in usb_port_resume()
3420 if (hub_is_superspeed(hub->hdev)) in usb_port_resume()
3421 status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U0); in usb_port_resume()
3423 status = usb_clear_port_feature(hub->hdev, in usb_port_resume()
3437 status = hub_port_status(hub, port1, &portstatus, &portchange); in usb_port_resume()
3446 if (hub_is_superspeed(hub->hdev)) { in usb_port_resume()
3448 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3452 usb_clear_port_feature(hub->hdev, port1, in usb_port_resume()
3457 if (udev->persist_enabled && hub_is_superspeed(hub->hdev)) in usb_port_resume()
3458 status = wait_for_ss_port_enable(udev, hub, &port1, &portchange, in usb_port_resume()
3462 hub, port1, status, portchange, portstatus); in usb_port_resume()
3467 hub_port_logical_disconnect(hub, port1); in usb_port_resume()
3501 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
3505 struct usb_port *port_dev = hub->ports[port - 1]; in hub_handle_remote_wakeup()
3511 hdev = hub->hdev; in hub_handle_remote_wakeup()
3535 hub_port_disable(hub, port, 1); in hub_handle_remote_wakeup()
3541 static int check_ports_changed(struct usb_hub *hub) in check_ports_changed() argument
3545 for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { in check_ports_changed()
3549 status = hub_port_status(hub, port1, &portstatus, &portchange); in check_ports_changed()
3558 struct usb_hub *hub = usb_get_intfdata(intf); in hub_suspend() local
3559 struct usb_device *hdev = hub->hdev; in hub_suspend()
3567 hub->wakeup_enabled_descendants = 0; in hub_suspend()
3569 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_suspend()
3579 hub->wakeup_enabled_descendants += in hub_suspend()
3583 if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { in hub_suspend()
3585 if (check_ports_changed(hub)) { in hub_suspend()
3607 hub_quiesce(hub, HUB_SUSPEND); in hub_suspend()
3613 struct usb_hub *hub = usb_get_intfdata(intf); in hub_resume() local
3616 hub_activate(hub, HUB_RESUME); in hub_resume()
3622 struct usb_hub *hub = usb_get_intfdata(intf); in hub_reset_resume() local
3625 hub_activate(hub, HUB_RESET_RESUME); in hub_reset_resume()
4115 static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, in hub_handle_remote_wakeup() argument
4139 int hub_port_debounce(struct usb_hub *hub, int port1, bool must_be_connected) in hub_port_debounce() argument
4145 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_debounce()
4148 ret = hub_port_status(hub, port1, &portstatus, &portchange); in hub_port_debounce()
4165 usb_clear_port_feature(hub->hdev, port1, in hub_port_debounce()
4234 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in hub_set_initial_usb2_lpm_policy() local
4240 if (hub) in hub_set_initial_usb2_lpm_policy()
4241 connect_type = hub->ports[udev->portnum - 1]->connect_type; in hub_set_initial_usb2_lpm_policy()
4275 hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, in hub_port_init() argument
4278 struct usb_device *hdev = hub->hdev; in hub_port_init()
4304 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4361 if (!hub->tt.hub) { in hub_port_init()
4366 udev->tt = &hub->tt; in hub_port_init()
4442 retval = hub_port_reset(hub, port1, udev, delay, false); in hub_port_init()
4526 hub_port_reset(hub, port1, udev, in hub_port_init()
4579 hub_port_disable(hub, port1, 0); in hub_port_init()
4587 check_highspeed(struct usb_hub *hub, struct usb_device *udev, int port1) in check_highspeed() argument
4605 if (hub->has_indicators) { in check_highspeed()
4606 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; in check_highspeed()
4608 &hub->leds, 0); in check_highspeed()
4615 hub_power_remaining(struct usb_hub *hub) in hub_power_remaining() argument
4617 struct usb_device *hdev = hub->hdev; in hub_power_remaining()
4621 if (!hub->limited_power) in hub_power_remaining()
4624 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; in hub_power_remaining()
4626 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_power_remaining()
4648 if (delta > hub->mA_per_port) in hub_power_remaining()
4650 delta, hub->mA_per_port); in hub_power_remaining()
4654 dev_warn(hub->intfdev, "%dmA over power budget!\n", in hub_power_remaining()
4661 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus, in hub_port_connect() argument
4666 struct usb_device *hdev = hub->hdev; in hub_port_connect()
4668 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect()
4684 clear_bit(port1, hub->removed_bits); in hub_port_connect()
4688 status = hub_port_debounce_be_stable(hub, port1); in hub_port_connect()
4705 test_bit(port1, hub->removed_bits)) { in hub_port_connect()
4711 if (hub_is_port_power_switchable(hub) in hub_port_connect()
4712 && !port_is_power_on(hub, portstatus) in hub_port_connect()
4720 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4739 udev->bus_mA = hub->mA_per_port; in hub_port_connect()
4741 udev->wusb = hub_is_wusb(hub); in hub_port_connect()
4744 if (hub_is_superspeed(hub->hdev)) in hub_port_connect()
4757 status = hub_port_init(hub, udev, port1, i); in hub_port_connect()
4785 if (hub->has_indicators) { in hub_port_connect()
4786 hub->indicator[port1-1] = in hub_port_connect()
4790 &hub->leds, 0); in hub_port_connect()
4801 check_highspeed(hub, udev, port1); in hub_port_connect()
4842 status = hub_power_remaining(hub); in hub_port_connect()
4844 dev_dbg(hub->intfdev, "%dmA power budget left\n", status); in hub_port_connect()
4849 hub_port_disable(hub, port1, 1); in hub_port_connect()
4858 if (hub->hdev->parent || in hub_port_connect()
4867 hub_port_disable(hub, port1, 1); in hub_port_connect()
4868 if (hcd->driver->relinquish_port && !hub->hdev->parent) in hub_port_connect()
4881 static void hub_port_connect_change(struct usb_hub *hub, int port1, in hub_port_connect_change() argument
4885 struct usb_port *port_dev = hub->ports[port1 - 1]; in hub_port_connect_change()
4890 portchange, portspeed(hub, portstatus)); in hub_port_connect_change()
4892 if (hub->has_indicators) { in hub_port_connect_change()
4893 set_port_led(hub, port1, HUB_LED_AUTO); in hub_port_connect_change()
4894 hub->indicator[port1-1] = INDICATOR_AUTO; in hub_port_connect_change()
4899 if (hub->hdev->bus->is_b_host) in hub_port_connect_change()
4923 clear_bit(port1, hub->change_bits); in hub_port_connect_change()
4930 hub_port_connect(hub, port1, portstatus, portchange); in hub_port_connect_change()
4934 static void port_event(struct usb_hub *hub, int port1) in port_event() argument
4938 struct usb_port *port_dev = hub->ports[port1 - 1]; in port_event()
4940 struct usb_device *hdev = hub->hdev; in port_event()
4943 connect_change = test_bit(port1, hub->change_bits); in port_event()
4944 clear_bit(port1, hub->event_bits); in port_event()
4945 clear_bit(port1, hub->wakeup_bits); in port_event()
4947 if (hub_port_status(hub, port1, &portstatus, &portchange) < 0) in port_event()
4980 hub_power_on(hub, true); in port_event()
4981 hub_port_status(hub, port1, &status, &unused); in port_event()
5011 if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange)) in port_event()
5018 if (hub_port_warm_reset_required(hub, port1, portstatus)) { in port_event()
5022 if (hub_port_reset(hub, port1, NULL, in port_event()
5024 hub_port_disable(hub, port1, 1); in port_event()
5036 hub_port_connect_change(hub, port1, portstatus, portchange); in port_event()
5043 struct usb_hub *hub; in hub_event() local
5049 hub = container_of(work, struct usb_hub, events); in hub_event()
5050 hdev = hub->hdev; in hub_event()
5051 hub_dev = hub->intfdev; in hub_event()
5057 (u16) hub->change_bits[0], in hub_event()
5058 (u16) hub->event_bits[0]); in hub_event()
5063 if (unlikely(hub->disconnected)) in hub_event()
5068 hub->error = -ENODEV; in hub_event()
5069 hub_quiesce(hub, HUB_DISCONNECT); in hub_event()
5081 if (hub->quiescing) in hub_event()
5084 if (hub->error) { in hub_event()
5085 dev_dbg(hub_dev, "resetting for error %d\n", hub->error); in hub_event()
5093 hub->nerrors = 0; in hub_event()
5094 hub->error = 0; in hub_event()
5099 struct usb_port *port_dev = hub->ports[i - 1]; in hub_event()
5101 if (test_bit(i, hub->event_bits) in hub_event()
5102 || test_bit(i, hub->change_bits) in hub_event()
5103 || test_bit(i, hub->wakeup_bits)) { in hub_event()
5116 port_event(hub, i); in hub_event()
5123 if (test_and_clear_bit(0, hub->event_bits) == 0) in hub_event()
5125 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0) in hub_event()
5133 hub->limited_power = 1; in hub_event()
5135 hub->limited_power = 0; in hub_event()
5144 hub_power_on(hub, true); in hub_event()
5145 hub_hub_status(hub, &status, &unused); in hub_event()
5159 kref_put(&hub->kref, hub_release); in hub_event()
5529 struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); in usb_reset_device() local
5544 port_dev = hub->ports[udev->portnum - 1]; in usb_reset_device()
5661 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_find_child() local
5665 return hub->ports[port1 - 1]->child; in usb_hub_find_child()
5672 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_hub_adjust_deviceremovable() local
5676 if (!hub) in usb_hub_adjust_deviceremovable()
5681 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5697 struct usb_port *port_dev = hub->ports[i - 1]; in usb_hub_adjust_deviceremovable()
5726 struct usb_hub *hub = usb_hub_to_struct_hub(hdev); in usb_get_hub_port_acpi_handle() local
5728 if (!hub) in usb_get_hub_port_acpi_handle()
5731 return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); in usb_get_hub_port_acpi_handle()