acpi_pm_device_sleep_state(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’€ acpi_pm_device_sleep_state(9) β€” the Kernel API Manual tea β˜•βœ¨

okay so real talk, bestie: this is a page from the Kernel API Manual, and it's all about figuring out the preferred power state of an ACPI device. it's giving "nap time optimization" energy and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

acpi_pm_device_sleep_state β€” Get preferred power state of ACPI device. πŸ’…

like, it literally just tells you what power state the device would prefer to snooze in. no cap.


🌸 SYNOPSIS 🌸

int acpi_pm_device_sleep_state (struct device *dev , int *d_min_p , int d_max_in );

look at her. three args, one int coming back. she's simple, she's iconic, she's the main character of ./drivers/acpi/device_pm.c. πŸ¦‹


🫢 ARGUMENTS 🫢

  • dev β€” the Device whose preferred target power state to return. bestie in question. πŸ’–
  • d_min_p β€” Location to store the upper limit of the allowed states range. yeah, it's a pointer, so it gets to hold the ceiling of the allowed range. lowkey important.
  • d_max_in β€” Deepest low-power state to take into consideration. Return value: Preferred power state of the device on success, -ENODEV if there's no 'struct acpi_device' for dev, -EINVAL if d_max_in is incorrect, or -ENODATA on ACPI method failure. 😭 so yeah, that whole return-value situation lives here, don't skip it, iykyk.
ok but fr, peep the error codes: -ENODEV = no 'struct acpi_device' for dev, -EINVAL = d_max_in is incorrect, -ENODATA = ACPI method failure. memorize them, they WILL show up. πŸ’€

🌈 DESCRIPTION 🌈

The caller must ensure that dev is valid before using this function. 🚨

that's it. that's the whole description. but it's a big deal, so let me say it again with my whole chest: the caller has to make sure dev is valid before using this function. don't come crying to the kernel when you hand it a garbage pointer, because it will not be cute. πŸ™ˆ not me warning you twice πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/acpi/device_pm.c β€” and the whole squad, because this function does not roll alone:

thirty-eight entries. thirty-eight!! she said "bring the whole friend group" and honestly? respect. 🫢✨


and that's the page, bestie β€” sourced from ./drivers/acpi, out of the Kernel API Manual, dated October 2026. slay, go read some kernel source, and remember: validate your dev. πŸ’œπŸŽ€

πŸ“¦ where this page comes from