devm_work_autocancel(9)
π devm_work_autocancel π
okay so bestie, this is a page from the Kernel API Manual and it's literally about not leaking your workqueue stuff when your driver dips out. no cap, it's a glow-up for cleanup code.
β¨ NAME β¨
devm_work_autocancel β resource-managed work allocation π
π¦ SYNOPSIS π¦
int devm_work_autocancel (struct device *dev , struct work_struct *w ,
work_func_t worker );
like, that's the whole vibe. three args, one int back. slay.
πΈ ARGUMENTS πΈ
devβ the Device your work's whole lifetime is bound to π«Ά like it's literally tethered to this thing's existence.wβ the Work to be added (and, key detail, automatically cancelled π ). yes bestie, the auto-cancel is the whole point.workerβ the Worker function, aka the main character that actually does the thing π₯
π DESCRIPTION π
okay so here's the tea π: this initializes work that gets automatically cancelled when the driver is detached. iconic behavior, honestly.
a few drivers need to queue work which must be cancelled before the driver is detached β otherwise you're out here accessing removed resources and it's giving π undefined chaos, we don't want that.
devm_work_autocancel can be used to omit the explicit cancellation when the driver is detached. so instead of you manually writing the cleanup, you just... don't. the devm machinery handles it. periodt. π§
no cap: the whole point is that you skip the explicit cancel-on-detach step. don't reinvent it, bestie, just let it cook.
π SEE ALSO π
- Kernel file
./include/linux/devm-helpers.hβ go read it, iykyk π devm_delayed_work_autocancel(9)β the delayed cousin, also iconic β¨
and that's the whole page, bestie π this one lives in ./include/linux, it's dated October 2026, and it comes to you courtesy of the Kernel API Manual. go forth and let the kernel clean up after you π«Άπ
π¦ 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