tb_switch_for_each_port(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… tb_switch_for_each_port β€” a Kernel API Manual moment (section 9, bestie)

okay so this is tb_switch_for_each_port(9) from the Kernel API Manual, and honestly? it's a little macro baddie that just wants to walk you through every port on a switch. no cap, that's the whole vibe. πŸ¦‹


✨ NAME ✨

tb_switch_for_each_port β€” iterate over each switch port, one by one, iconic behaviour only πŸ’–


🌸 SYNOPSIS 🌸

tb_switch_for_each_port (sw , p );

like yes that's the whole call, she's compact πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • sw β€” the switch whose ports you're about to iterate over. she's the main character here 🫢
  • p β€” the port that gets used as the iterator. lowkey just the loop variable doing her little walk 🌈

⭐ DESCRIPTION ⭐

so it iterates over each switch port, right? but β€” and this is the important part, don't skip it β€” it skips the control port (port 0). literally port 0 is not invited to this party, she's the control port, she has other duties πŸ’…

that's it. that's the whole behaviour. no hidden lore, fr fr.

ngl the port-0 skip is the entire personality of this macro, so if you're expecting port 0 in your loop, you will be 😭

πŸ’œ SEE ALSO πŸ’œ

the whole friend group, all of them, no one left out 🧚 β€” from the kernel file ./drivers/thunderbolt/tb.h:

like, go read them, they're all giving thunderbolt lore πŸ”₯


πŸ“ bye bestie πŸ“

this page lives in ./drivers/thunderbolt, and it's dated October 2026 β€” so mark your calendar, that's your source and your version, slay πŸ’–βœ¨πŸŽ€ keep iterating (but not over port 0, we talked about this) πŸ’€πŸ«Ά

πŸ“¦ where this page comes from