devres_get(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… devres_get β€” the kernel API manual, but make it make sense

okay so bestie, welcome to devres_get(9), from the Kernel API Manual. This is the "find it or make it, and do it atomically" girlie of the devres world. Let's get into it ✨


🌸 SYNOPSIS 🌸

void * devres_get (struct device *dev , void *new_res , dr_match_t match
, void *match_data );

that's the whole signature, no cap. four args, one void * coming back at you 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the device you're looking up devres for (or adding one to, bestie, it's giving both)
  • new_res β€” pointer to a new, already-initialized devres that gets added if nothing matches πŸ’–
  • match β€” the match function. it's optional, so you can absolutely pass nothing here if that's your vibe
  • match_data β€” the data you hand off to that match function

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does it actually do? it goes looking for the latest devres of dev that has the same release function as new_res and for which match returns 1. that's the vibe check, okay? both boxes gotta be ticked.

and then the drama:

  • if it finds one β†’ new_res gets freed 😭 bye bestie
  • if it doesn't β†’ new_res gets added, and it's done atomically, which is the iconic part ngl

so it's find-or-add, and you never have to worry about a race sneaking in between the find and the add. main character energy fr fr πŸ‘‘


πŸ”₯ RETURN πŸ”₯

pointer to the found-or-added devres. that's it. that's the whole return value. ✨


🌈 SEE ALSO 🌈

okay this list is long and honestly kind of iconic, so let's give it the respect it deserves β€” go read the kernel file ./drivers/base/devres.c and also:

like I said. a list. but every single one of them is a baddie in her own right πŸ’…


mwah πŸ’‹ that's the page! this one comes to you straight out of ./drivers/base, dated October 2026 β€” so go forth, find your devres, add your devres, and do it atomically bestie πŸ§šβ€β™€οΈπŸ’œ

πŸ“¦ where this page comes from