__devm_add_action(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 __devm_add_action(9) 🌸

okay so bestie, we're in the Kernel API Manual today β€” yes, that manual, the big serious one β€” and the star of the show is __devm_add_action. lowkey a little legend. let's get into it πŸ’…


✨ NAME ✨

__devm_add_action β€” add a custom action to the list of managed resources πŸŽ€

like, you're literally registering a little side-quest that the kernel will handle for you later. no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

int __devm_add_action (struct device *dev , void (*action)(void *) ,
void *data , const char *name );

she returns an int, she takes four args, she's booked and busy ✨


πŸ’– ARGUMENTS πŸ’–

  • dev β€” the Device that owns the action πŸ‘‘ like, whose responsibility is this? hers.
  • action β€” the Function that should be called. this is the function. it gets called. that's the whole vibe πŸ”₯
  • data β€” Pointer to data passed to the action implementation πŸ“ handed straight to your callback, no detours.
  • name β€” Name of the resource (for debugging purposes) πŸ” so when things go sideways at 3am you know which resource ghosted you. iykyk.

🌈 DESCRIPTION 🌈

so what does she actually do? This adds a custom action to the list of managed resources so that it gets executed as part of standard resource unwinding. 🧚

translation for the group chat: you hand over your little cleanup function, the device takes custody of it, and when the standard unwinding happens, your action gets run β€” automatically. no manual cleanup arc, no forgotten free() trauma. main character energy, honestly. πŸ’œ


⭐ SEE ALSO ⭐

okay this list is long long, but every single one of these is invited to the party β€” not me listing them all and skipping zero of them πŸ™ˆ

Kernel file ./drivers/base/devres.c:


bestie bestie bestie β€” that SEE ALSO list is 28 entries long and i love her for it. go read a couple. or all of them. be the main character of your own devres journey πŸ’…

okay and finally the cute little sign-off because we do NOT skip the footer in this house 🫢: this page lives under ./drivers/base, and it's dated October 2026 β€” and yes, the title on the door is __devm_add_action(9), same as the one up top. slay, consistent queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from