mode_selection_work_fn(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– mode_selection_work_fn(9) β€” the Kernel API Manual glow-up ✨

okay bestie, welcome to mode_selection_work_fn(9) from the Kernel API Manual, and no cap this one is the alternate mode activation task πŸ’… she's the little work-queue icon who actually makes the Alternate Mode switch happen, and we're gonna read her together like a group chat at 2am 🫢


✨ NAME ✨

mode_selection_work_fn β€” Alternate mode activation task 🌈

like literally, that's her whole job title and she ate


🌸 SYNOPSIS 🌸

void mode_selection_work_fn (struct work_struct *work );

that's it. that's the signature. she takes one thing and returns nothing (void), main character energy fr fr πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • work β€” work structure πŸ’Ό (yes queen, it's the struct work_struct * from the synopsis, that's the whole vibe)

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's what happens inside, step by step, and honestly she's methodical about it:

  • πŸ’… If the Alternate Mode that's currently prioritized at the top of the list is already active, then the entire selection process is considered finished. like, nothing to do, we're done here, slay.
  • 😭 If a different Alternate Mode is currently active, the system must exit that active mode first before attempting any new entry. can't wear two fits at once bestie, the old one has to come off first.

then the function checks the result of the attempt to enter the current mode, which is stored in the ms->error field, and the vibe check goesss:

  • πŸ’€ if the attempt FAILED, the mode is deactivated and removed from the list. goodbye, gone, we don't know her anymore.
  • 🧚 an ms->error value of 0 signifies that the mode has not yet been activated.

and once she's successfully activated? the task is scheduled for subsequent entry after a timeout period ⏰ (patience is a virtue, we wait). the alternate mode driver is expected to call back with the actual mode entry result via typec_altmode_state_update β€” that's the receipts, that's how we know it worked πŸ”₯

🫢 lowkey important: this function doesn't just assume the entry worked, it waits for the driver to report back through typec_altmode_state_update. no assuming, only evidence πŸ’œ

πŸ“ SEE ALSO πŸ“

  • Kernel file ./drivers/usb/typec/mode_selection.c β€” where the magic lives ✨
  • struct mode_state(9)
  • struct mode_selection(9)
  • struct mode_order(9)

like go read the whole friend group, iykyk πŸ’…


⭐ and that's the page!! brought to you by the fine folks at ./drivers/usb/typec, dated October 2026, page mode_selection_work_fn(9) β€” stan her, she switches modes so you don't have to πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from