mode_selection_work_fn(9)
π 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 thestruct 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->errorvalue 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
- 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