dev_pm_domain_attach(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ dev_pm_domain_attach πŸ’…

okay bestie, so this is a page from the Kernel API Manual β€” yeah, the kernel really said "let me explain myself" and honestly? iconic of it. we're talking about dev_pm_domain_attach, and no cap, it's the little function that gets your device hooked up to its power management domain. let's get into it πŸŽ€


🌸 SYNOPSIS 🌸

int dev_pm_domain_attach (struct device *dev , u32 flags );

that's it. that's the whole vibe. two args, one int coming back at you ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the device you're attaching. the main character, fr.
  • flags β€” these tell us whether we should power on/off the device on attach/detach. so like, do we flip the switch or not, that's the question 🫢

πŸ’– DESCRIPTION πŸ’–

so here's the tea: your dev may only be attached to a single PM domain. one. that's it. no polyamory for power domains πŸ’€

the way it works is by iterating through the available alternatives, we try to find a valid PM domain for the device. and when attachment succeeds, the ->detach callback in the struct dev_pm_domain should be assigned by the corresponding attach function. yes, that's a whole strung-together sentence but it matters, so keep it 🫑

this function should typically be invoked from subsystem level code during the probe phase β€” especially for those that holds devices which requires power management through PM domains. iykyk, that's exactly your situation or you wouldn't be here πŸ’…

lowkey important: callers must ensure proper synchronization of this function with power management callbacks. do not skip this. this is not a vibe-check-you-can-fail, bestie 😭

now the returns, because we love a clear exit strategy:

  • 0 β€” on successfully attached PM domain, or when it is found that the device doesn't need a PM domain. either way, zero is a win 🌈
  • negative error code β€” anything else. it's giving "something went wrong" but at least it's honest πŸ’€

⭐ SEE ALSO ⭐

the kernel file is ./drivers/base/power/common.c β€” that's where the magic lives, go look πŸ‘€

and then the whole friend group of related functions, all of them, not skipping a single one:

like a whole squad 🧚


πŸŽ€ sign-off πŸŽ€

this absolute banger of a page comes from ./drivers/base/power, dated October 2026, and it's the dev_pm_domain_attach(9) manual page. go attach something responsibly, bestie β€” slay πŸ’œπŸ‘‘

πŸ“¦ where this page comes from