dev_pm_domain_attach_by_id(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 πŸŽ‰
  • NULL in case dev don'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:


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