summaryrefslogtreecommitdiff
path: root/drivers/acpi/x86/s2idle.c
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2023-08-18 14:40:07 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-08-21 20:28:20 +0200
commit1c2a66d47de36608551d73562d01bb4afcf1d61a (patch)
tree0cd888ff33c59fef4d7af4473475f28317b6524b /drivers/acpi/x86/s2idle.c
parent41233988112f0f5fb015172a8db68a3c052aedda (diff)
ACPI: x86: s2idle: Add a function to get LPS0 constraint for a device
Other parts of the kernel may use LPS0 constraints information to make decisions on what power state to put a device into. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> [ rjw: Rewrite kerneldoc, rearrange if () statement, edit subject and changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/x86/s2idle.c')
-rw-r--r--drivers/acpi/x86/s2idle.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
index 1aa3cd5677bd..08f7c6708206 100644
--- a/drivers/acpi/x86/s2idle.c
+++ b/drivers/acpi/x86/s2idle.c
@@ -299,6 +299,30 @@ free_acpi_buffer:
ACPI_FREE(out_obj);
}
+/**
+ * acpi_get_lps0_constraint - Get the LPS0 constraint for a device.
+ * @adev: Device to get the constraint for.
+ *
+ * The LPS0 constraint is the shallowest (minimum) power state in which the
+ * device can be so as to allow the platform as a whole to achieve additional
+ * energy conservation by utilizing a system-wide low-power state.
+ *
+ * Returns:
+ * - ACPI power state value of the constraint for @adev on success.
+ * - Otherwise, ACPI_STATE_UNKNOWN.
+ */
+int acpi_get_lps0_constraint(struct acpi_device *adev)
+{
+ struct lpi_constraints *entry;
+
+ for_each_lpi_constraint(entry) {
+ if (adev->handle == entry->handle)
+ return entry->min_dstate;
+ }
+
+ return ACPI_STATE_UNKNOWN;
+}
+
static void lpi_check_constraints(void)
{
struct lpi_constraints *entry;