acpi_dev_pm_get_state(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… acpi_dev_pm_get_state(9) πŸ’…

okay so we're in the Kernel API Manual bestie, and today's main character is acpi_dev_pm_get_state. the way this function just knows what power state your ACPI device wants to be in? obsessed. let's get into it 🫢


✨ NAME ✨

acpi_dev_pm_get_state β€” Get preferred power state of ACPI device. that's it, that's the whole vibe check πŸ’–


🌸 SYNOPSIS 🌸

int acpi_dev_pm_get_state (struct device *dev , struct acpi_device *adev
, u32 target_state , int *d_min_p , int *d_max_p );

look at those parameters go. five of them. no notes 😭✨


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the device whose preferred target power state we're returning. it's giving "who am I really" energy. πŸ’…
  • adev β€” the ACPI device node that corresponds to dev. they're a matched set, iykyk. πŸ¦‹
  • target_state β€” the system state we're matching the resultant device state against. like, what state is the system in, because that changes everything ngl. 🌈
  • d_min_p β€” location to store the highest power state available to the device. yes, min pointer, highest state. it's confusing but that's the lore. 🀑
  • d_max_p β€” location to store the lowest power state available to the device. same deal, flipped. don't fight it, just respect it. πŸ™ˆ

πŸ’œ DESCRIPTION πŸ’œ

so the whole point: find the lowest power (highest number) and the highest power (lowest number) ACPI device power states that your device can be in while the system is sitting in the state represented by target_state. and then β€” slay β€” it stores the integer numbers representing those stats in the memory locations pointed to by d_max_p and d_min_p, respectively. note the swap, because of course 😭 the numbers are numbers, the pointers are pointers, it's fine, we're fine.

⚠️ bestie please listen to me on this one: callers must ensure that dev and adev are valid pointers, and that adev actually corresponds to dev before using this function. no cap. like, actually verify it. don't just assume. πŸ’€

Returns 0 on success, or -ENODATA when one of the ACPI methods fails or returns a value that doesn't make sense. and here's the important bit: the memory locations pointed to by d_max_p and d_min_p are only modified on success β€” so if it flops, your pointers stay exactly as they were. cute, respectful, boundaries. πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/acpi/device_pm.c, plus the whole friend group right here β€” go say hi:


and that's the whole page, bestie β€” go forth and get those power states πŸ’…βœ¨

sign-off time πŸŽ€ this one lives in ./drivers/acpi, dated October 2026, and it was a whole vibe. mwah πŸ’–

πŸ“¦ where this page comes from