git: 526c09a48929 - main - acpi: Use only AcpiGetSleepTypeData() to determine Sx support

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Wed, 28 Jan 2026 11:31:32 UTC
The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=526c09a489295c96662d6c3d428f69672968ab80

commit 526c09a489295c96662d6c3d428f69672968ab80
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-01-07 13:34:44 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-01-28 11:26:37 +0000

    acpi: Use only AcpiGetSleepTypeData() to determine Sx support
    
    Previously, we would first call AcpiEvaluateObject() to execute \_Sx
    before calling AcpiGetSleepTypeData().  This was unnecessary, as
    AcpiGetSleepTypeData() performs the same call itself.  While doing so,
    the latter function logs any other error than AE_NOT_FOUND (which
    indicates that a particular sleep state is not supported), which most
    probably is an added benefit of this change.
    
    Reviewed by:    obiwac
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D54624
---
 sys/dev/acpica/acpi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index e43ef72ca9d2..6da406377d4b 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -490,7 +490,6 @@ acpi_attach(device_t dev)
     ACPI_STATUS		status;
     int			error, state;
     UINT32		flags;
-    UINT8		TypeA, TypeB;
     char		*env;
     enum power_stype	stype;
 
@@ -688,13 +687,14 @@ acpi_attach(device_t dev)
 #if defined(__i386__) || defined(__amd64__)
     acpi_supported_stypes[POWER_STYPE_SUSPEND_TO_IDLE] = true;
 #endif
-    for (state = ACPI_STATE_S1; state <= ACPI_STATE_S5; state++)
-	if (ACPI_SUCCESS(AcpiEvaluateObject(ACPI_ROOT_OBJECT,
-	    __DECONST(char *, AcpiGbl_SleepStateNames[state]), NULL, NULL)) &&
-	    ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) {
+    for (state = ACPI_STATE_S1; state <= ACPI_STATE_S5; state++) {
+	UINT8 TypeA, TypeB;
+
+	if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) {
 	    acpi_supported_sstates[state] = true;
 	    acpi_supported_stypes[acpi_sstate_to_stype(state)] = true;
 	}
+    }
 
     /*
      * Dispatch the default sleep type to devices.  The lid switch is set