tb_wait_for_port(9)
π tb_wait_for_port β wait for a port to become ready
okay so bestie, this is the tb_wait_for_port page from the Kernel API Manual, section 9. it's short, it's sweet, and it's literally just "hey, is this port up yet?" energy. let's go π«Ά
β¨ SYNOPSIS β¨
int tb_wait_for_port (struct tb_port *port , bool wait_if_unplugged );
π ARGUMENTS π
portβ the port we're waiting on. main character of this whole function, no cap.wait_if_unpluggedβ the "should I also wait when the port is unplugged?" switch. if it's set, yes bestie, we wait for that too.
πΈ DESCRIPTION πΈ
so here's the vibe: this function waits up to 1 second for a port to reach state TB_PORT_UP. that's it, that's the whole job. β³
if wait_if_unplugged is set, then we also wait when the port is sitting in state TB_PORT_UNPLUGGED β and iykyk, that's because it takes a while for the device to be registered after switch resume. like, the device is showing up late to the party, we're just holding the door. π
otherwise (if wait_if_unplugged is not set) we only wait if a device is registered but the link has not yet been established. so: device is here, link is still loading. we chill. π
π₯ RETURN π₯
0β if the port is not connected, or it failed to reach stateTB_PORT_UPwithin one second. awkward but okay. π1β if the port is connected and in stateTB_PORT_UP. slay, we love to see it π- Negative errno β an error occurred. something went wrong, sending hugs. π«Ά
π¦ SEE ALSO π¦
kernel file ./drivers/thunderbolt/switch.c, plus literally the entire friend group:
tb_switch_nvm_read(9)tb_port_state(9)tb_port_add_nfc_credits(9)tb_port_clear_counter(9)tb_port_unlock(9)tb_port_enable(9)tb_port_disable(9)tb_port_reset(9)tb_port_alloc_in_hopid(9)tb_port_alloc_out_hopid(9)tb_port_release_in_hopid(9)tb_port_release_out_hopid(9)tb_next_port_on_path(9)tb_port_get_link_speed(9)tb_port_get_link_generation(9)tb_port_get_link_width(9)tb_port_width_supported(9)tb_port_set_link_width(9)tb_port_set_lane_bonding(9)tb_port_lane_bonding_enable(9)tb_port_lane_bonding_disable(9)tb_port_wait_for_link_width(9)tb_port_update_credits(9)tb_port_is_enabled(9)tb_usb3_port_is_enabled(9)tb_usb3_port_enable(9)tb_pci_port_is_enabled(9)tb_pci_port_enable(9)tb_dp_port_hpd_is_active(9)tb_dp_port_hpd_clear(9)tb_dp_port_set_hops(9)tb_dp_port_is_enabled(9)tb_dp_port_enable(9)tb_switch_reset(9)tb_switch_wait_for_bit(9)tb_switch_alloc(9)tb_switch_alloc_safe_mode(9)tb_switch_configure(9)tb_switch_configuration_valid(9)tb_switch_lane_bonding_enable(9)tb_switch_lane_bonding_disable(9)tb_switch_set_link_width(9)tb_switch_configure_link(9)tb_switch_unconfigure_link(9)tb_switch_add(9)tb_switch_remove(9)tb_sw_set_unplugged(9)tb_switch_resume(9)tb_switch_suspend(9)tb_switch_query_dp_resource(9)tb_switch_alloc_dp_resource(9)tb_switch_dealloc_dp_resource(9)tb_switch_find_by_link_depth(9)tb_switch_find_by_uuid(9)tb_switch_find_by_route(9)tb_switch_find_port(9)tb_switch_pcie_l1_enable(9)tb_switch_xhci_connect(9)tb_switch_xhci_disconnect(9)
that's the whole page bestie, go forth and wait for ports responsibly π
so yeah, that's a wrap! this one lives in ./drivers/thunderbolt and the version/date stamp is October 2026 β remember it fondly, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms