dev_pm_domain_attach(9)
β¨ 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:
dev_pm_get_subsys_data(9)dev_pm_put_subsys_data(9)dev_pm_domain_attach_by_id(9)dev_pm_domain_attach_by_name(9)dev_pm_domain_attach_list(9)devm_pm_domain_detach_list(9)devm_pm_domain_attach_list(9)dev_pm_domain_detach(9)dev_pm_domain_detach_list(9)dev_pm_domain_start(9)dev_pm_domain_set(9)dev_pm_domain_set_performance_state(9)
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
- 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