dev_pm_domain_attach_by_id(9)
π NAME π
dev_pm_domain_attach_by_id β the girlboss function that associates a device with one of its PM domains, bestie β¨
(also hi, this is from the Kernel API Manual, in case you were wondering where you are π«Ά)
β¨ SYNOPSIS β¨
struct device * dev_pm_domain_attach_by_id (struct device *dev ,
unsigned int index );
π ARGUMENTS π
devβ the device being used to look up the PM domain. main character of the lookup, honestly πindexβ the index of the PM domain. like which one of the domains we're picking out of the lineup π
π¦ DESCRIPTION π¦
Okay so here's the tea: dev can only be attached to a single PM domain, periodt. So instead of forcing it, the backend PM domain provider creates a virtual device to attach instead π iconic workaround fr fr.
If the attachment succeeds, the ->detach callback in the struct dev_pm_domain gets assigned by the corresponding backend attach function β like, that's how they deal with detaching the created virtual device later. no cap π§
This function should typically be invoked by a driver during the probe phase, in case its device requires power management through multiple PM domains. The driver may lowkey benefit from using the received device to configure device-links towards its original device π. Depending on the use-case and if needed, those links may be dynamically changed by the driver, which lets it control the power to the PM domains independently from each other β highkey powerful β¨
Callers must ensure proper synchronization of this function with power management callbacks. like, actually. don't skip this one bestie, this is not a vibe-check-you-can-fail π
Now the returns, listen up:
- Returns the virtual created device when successfully attached to its PM domain π
NULLin casedevdon't need a PM domain (it's giving "not my problem, I'm fine")- else an
ERR_PTRπ
Also important: to detach the returned virtual device, the driver shall call dev_pm_domain_detach on it β typically during the remove phase. don't leave the poor thing hanging πΈ
π₯ SEE ALSO π₯
Kernel file ./drivers/base/power/common.c plus this whole friend group:
dev_pm_get_subsys_data(9)dev_pm_put_subsys_data(9)dev_pm_domain_attach(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)
and that's the whole page, bestie!! π«Ά this lil masterpiece lives in ./drivers/base/power, and it's dated October 2026 β so yeah, it's from the future, 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