Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Sep 2025 09:50:00 GMT
From:      Aymeric Wibo <obiwac@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 506b36c4fdde - main - Revert "acpi: Use sleep types defined in sys/power.h"
Message-ID:  <202509180950.58I9o0rE017137@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by obiwac:

URL: https://cgit.FreeBSD.org/src/commit/?id=506b36c4fdde0b402cc730b41a9d9d20130e1bca

commit 506b36c4fdde0b402cc730b41a9d9d20130e1bca
Author:     Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2025-09-18 09:45:36 +0000
Commit:     Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2025-09-18 09:49:31 +0000

    Revert "acpi: Use sleep types defined in sys/power.h"
    
    This reverts commit ce5e22b28ef6caff3ffd228ac188114b08c0da02.
    
    PR:             289634
---
 sys/dev/acpica/acpi.c     | 368 +++++++++++++++++-----------------------------
 sys/dev/acpica/acpi_lid.c |   4 +-
 sys/dev/acpica/acpivar.h  |  15 +-
 sys/x86/acpica/acpi_apm.c |  25 ++--
 4 files changed, 158 insertions(+), 254 deletions(-)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 8dd879a573cc..574d3aacbcde 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -111,9 +111,8 @@ struct callout	acpi_sleep_timer;
 /* Bitmap of device quirks. */
 int		acpi_quirks;
 
-/* Supported sleep states and types. */
-static bool	acpi_supported_stypes[POWER_STYPE_COUNT];
-static bool	acpi_supported_sstates[ACPI_S_STATE_COUNT];
+/* Supported sleep states. */
+static BOOLEAN	acpi_sleep_states[ACPI_S_STATE_COUNT];
 
 static void	acpi_lookup(void *arg, const char *name, device_t *dev);
 static int	acpi_modevent(struct module *mod, int event, void *junk);
@@ -170,27 +169,21 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level,
 		    void *context, void **status);
 static void	acpi_sleep_enable(void *arg);
 static ACPI_STATUS acpi_sleep_disable(struct acpi_softc *sc);
-static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc,
-		    enum power_stype stype);
+static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state);
 static void	acpi_shutdown_final(void *arg, int howto);
 static void	acpi_enable_fixed_events(struct acpi_softc *sc);
 static void	acpi_resync_clock(struct acpi_softc *sc);
-static int	acpi_wake_sleep_prep(ACPI_HANDLE handle,
-		    enum power_stype stype);
-static int	acpi_wake_run_prep(ACPI_HANDLE handle, enum power_stype stype);
-static int	acpi_wake_prep_walk(enum power_stype stype);
+static int	acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate);
+static int	acpi_wake_run_prep(ACPI_HANDLE handle, int sstate);
+static int	acpi_wake_prep_walk(int sstate);
 static int	acpi_wake_sysctl_walk(device_t dev);
 static int	acpi_wake_set_sysctl(SYSCTL_HANDLER_ARGS);
+static void	acpi_system_eventhandler_sleep(void *arg, int state);
+static void	acpi_system_eventhandler_wakeup(void *arg, int state);
+static int	acpi_sname2sstate(const char *sname);
+static const char *acpi_sstate2sname(int sstate);
 static int	acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS);
-static void	acpi_system_eventhandler_sleep(void *arg,
-		    enum power_stype stype);
-static void	acpi_system_eventhandler_wakeup(void *arg,
-		    enum power_stype stype);
-static enum power_stype	acpi_sstate_to_stype(int sstate);
-static int	acpi_sname_to_sstate(const char *sname);
-static const char	*acpi_sstate_to_sname(int sstate);
 static int	acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS);
-static int	acpi_stype_sysctl(SYSCTL_HANDLER_ARGS);
 static int	acpi_debug_objects_sysctl(SYSCTL_HANDLER_ARGS);
 static int	acpi_stype_to_sstate(struct acpi_softc *sc, enum power_stype stype);
 static int	acpi_pm_func(u_long cmd, void *arg, enum power_stype stype);
@@ -484,7 +477,6 @@ acpi_attach(device_t dev)
     UINT32		flags;
     UINT8		TypeA, TypeB;
     char		*env;
-    enum power_stype	stype;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
@@ -597,30 +589,31 @@ acpi_attach(device_t dev)
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "power_button_state",
 	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	&sc->acpi_power_button_stype, 0, acpi_stype_sysctl, "A",
+	&sc->acpi_power_button_sx, 0, acpi_sleep_state_sysctl, "A",
 	"Power button ACPI sleep state.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "sleep_button_state",
 	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	&sc->acpi_sleep_button_stype, 0, acpi_stype_sysctl, "A",
+	&sc->acpi_sleep_button_sx, 0, acpi_sleep_state_sysctl, "A",
 	"Sleep button ACPI sleep state.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "lid_switch_state",
 	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	&sc->acpi_lid_switch_stype, 0, acpi_stype_sysctl, "A",
-	"Lid ACPI sleep state. Set to s2idle or s2mem if you want to suspend "
-	"your laptop when close the lid.");
+	&sc->acpi_lid_switch_sx, 0, acpi_sleep_state_sysctl, "A",
+	"Lid ACPI sleep state. Set to S3 if you want to suspend your laptop when close the Lid.");
     SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "standby_state",
 	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
-	&sc->acpi_standby_sx, 0, acpi_sleep_state_sysctl, "A",
-	"ACPI Sx state to use when going standby (S1 or S2).");
+	&sc->acpi_standby_sx, 0, acpi_sleep_state_sysctl, "A", "");
+    SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
+	OID_AUTO, "suspend_state",
+	CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE,
+	&sc->acpi_suspend_sx, 0, acpi_sleep_state_sysctl, "A", "");
     SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "sleep_delay", CTLFLAG_RW, &sc->acpi_sleep_delay, 0,
 	"sleep delay in seconds");
     SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
-	OID_AUTO, "s4bios", CTLFLAG_RW, &sc->acpi_s4bios, 0,
-	"Use S4BIOS when hibernating.");
+	OID_AUTO, "s4bios", CTLFLAG_RW, &sc->acpi_s4bios, 0, "S4BIOS mode");
     SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
 	OID_AUTO, "verbose", CTLFLAG_RW, &sc->acpi_verbose, 0, "verbose mode");
     SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree),
@@ -666,38 +659,31 @@ acpi_attach(device_t dev)
 	sc->acpi_s4bios = 1;
 #endif
 
-    /*
-     * Probe all supported ACPI sleep states.  Awake (S0) is always supported.
-     */
-    acpi_supported_sstates[ACPI_STATE_S0] = TRUE;
-    acpi_supported_stypes[POWER_STYPE_AWAKE] = true;
-    for (state = ACPI_STATE_S1; state <= ACPI_STATE_S5; state++)
+    /* Probe all supported sleep states. */
+    acpi_sleep_states[ACPI_STATE_S0] = TRUE;
+    for (state = ACPI_STATE_S1; state < ACPI_S_STATE_COUNT; state++)
 	if (ACPI_SUCCESS(AcpiEvaluateObject(ACPI_ROOT_OBJECT,
 	    __DECONST(char *, AcpiGbl_SleepStateNames[state]), NULL, NULL)) &&
-	    ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) {
-	    acpi_supported_sstates[state] = TRUE;
-	    acpi_supported_stypes[acpi_sstate_to_stype(state)] = true;
-	}
+	    ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB)))
+	    acpi_sleep_states[state] = TRUE;
 
     /*
-     * Dispatch the default sleep type to devices.  The lid switch is set
+     * Dispatch the default sleep state to devices.  The lid switch is set
      * to UNKNOWN by default to avoid surprising users.
      */
-    sc->acpi_power_button_stype = acpi_supported_stypes[POWER_STYPE_POWEROFF] ?
-	POWER_STYPE_POWEROFF : POWER_STYPE_UNKNOWN;
-    sc->acpi_lid_switch_stype = POWER_STYPE_UNKNOWN;
-
-    sc->acpi_standby_sx = ACPI_STATE_UNKNOWN;
-    if (acpi_supported_sstates[ACPI_STATE_S1])
-	sc->acpi_standby_sx = ACPI_STATE_S1;
-    else if (acpi_supported_sstates[ACPI_STATE_S2])
-	sc->acpi_standby_sx = ACPI_STATE_S2;
-
-    /* Pick the first valid sleep type for the sleep button default. */
-    sc->acpi_sleep_button_stype = POWER_STYPE_UNKNOWN;
-    for (stype = POWER_STYPE_STANDBY; stype <= POWER_STYPE_HIBERNATE; stype++)
-	if (acpi_supported_stypes[stype]) {
-	    sc->acpi_sleep_button_stype = stype;
+    sc->acpi_power_button_sx = acpi_sleep_states[ACPI_STATE_S5] ?
+	ACPI_STATE_S5 : ACPI_STATE_UNKNOWN;
+    sc->acpi_lid_switch_sx = ACPI_STATE_UNKNOWN;
+    sc->acpi_standby_sx = acpi_sleep_states[ACPI_STATE_S1] ?
+	ACPI_STATE_S1 : ACPI_STATE_UNKNOWN;
+    sc->acpi_suspend_sx = acpi_sleep_states[ACPI_STATE_S3] ?
+	ACPI_STATE_S3 : ACPI_STATE_UNKNOWN;
+
+    /* Pick the first valid sleep state for the sleep button default. */
+    sc->acpi_sleep_button_sx = ACPI_STATE_UNKNOWN;
+    for (state = ACPI_STATE_S1; state <= ACPI_STATE_S4; state++)
+	if (acpi_sleep_states[state]) {
+	    sc->acpi_sleep_button_sx = state;
 	    break;
 	}
 
@@ -722,7 +708,7 @@ acpi_attach(device_t dev)
 
     /* Flag our initial states. */
     sc->acpi_enabled = TRUE;
-    sc->acpi_stype = POWER_STYPE_AWAKE;
+    sc->acpi_sstate = ACPI_STATE_S0;
     sc->acpi_sleep_disabled = TRUE;
 
     /* Create the control device */
@@ -782,36 +768,6 @@ acpi_stype_to_sstate(struct acpi_softc *sc, enum power_stype stype)
 	return (ACPI_STATE_UNKNOWN);
 }
 
-/*
- * XXX It would be nice if we didn't need this function, but we'd need
- * acpi_EnterSleepState and acpi_ReqSleepState to take in actual ACPI S-states,
- * which won't be possible at the moment because suspend-to-idle (which is not
- * an ACPI S-state nor maps to one) will be implemented here.
- *
- * In the future, we should make generic a lot of the logic in these functions
- * to enable suspend-to-idle on non-ACPI builds, and then make
- * acpi_EnterSleepState and acpi_ReqSleepState truly take in ACPI S-states
- * again.
- */
-static enum power_stype
-acpi_sstate_to_stype(int sstate)
-{
-	switch (sstate) {
-	case ACPI_STATE_S0:
-		return (POWER_STYPE_AWAKE);
-	case ACPI_STATE_S1:
-	case ACPI_STATE_S2:
-		return (POWER_STYPE_STANDBY);
-	case ACPI_STATE_S3:
-		return (POWER_STYPE_SUSPEND_TO_MEM);
-	case ACPI_STATE_S4:
-		return (POWER_STYPE_HIBERNATE);
-	case ACPI_STATE_S5:
-		return (POWER_STYPE_POWEROFF);
-	}
-	return (POWER_STYPE_UNKNOWN);
-}
-
 static void
 acpi_set_power_children(device_t dev, int state)
 {
@@ -2107,7 +2063,7 @@ acpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate)
      * Note illegal _S0D is evaluated because some systems expect this.
      */
     sc = device_get_softc(bus);
-    snprintf(sxd, sizeof(sxd), "_S%dD", acpi_stype_to_sstate(sc, sc->acpi_stype));
+    snprintf(sxd, sizeof(sxd), "_S%dD", sc->acpi_sstate);
     status = acpi_GetInteger(handle, sxd, dstate);
     if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
 	    device_printf(dev, "failed to get %s on %s: %s\n", sxd,
@@ -3205,9 +3161,9 @@ acpi_sleep_force_task(void *context)
 {
     struct acpi_softc *sc = (struct acpi_softc *)context;
 
-    if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_stype)))
-	device_printf(sc->acpi_dev, "force sleep state %s failed\n",
-	    power_stype_to_name(sc->acpi_next_stype));
+    if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate)))
+	device_printf(sc->acpi_dev, "force sleep state S%d failed\n",
+	    sc->acpi_next_sstate);
 }
 
 static void
@@ -3234,24 +3190,24 @@ acpi_sleep_force(void *arg)
  * acks are in.
  */
 int
-acpi_ReqSleepState(struct acpi_softc *sc, enum power_stype stype)
+acpi_ReqSleepState(struct acpi_softc *sc, int state)
 {
 #if defined(__amd64__) || defined(__i386__)
     struct apm_clone_data *clone;
     ACPI_STATUS status;
 
-    if (stype < POWER_STYPE_AWAKE || stype >= POWER_STYPE_COUNT)
+    if (state < ACPI_STATE_S1 || state > ACPI_S_STATES_MAX)
 	return (EINVAL);
-    if (!acpi_supported_stypes[stype])
+    if (!acpi_sleep_states[state])
 	return (EOPNOTSUPP);
 
     /*
      * If a reboot/shutdown/suspend request is already in progress or
      * suspend is blocked due to an upcoming shutdown, just return.
      */
-    if (rebooting || sc->acpi_next_stype != POWER_STYPE_AWAKE ||
-	suspend_blocked)
+    if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) {
 	return (0);
+    }
 
     /* Wait until sleep is enabled. */
     while (sc->acpi_sleep_disabled) {
@@ -3260,12 +3216,12 @@ acpi_ReqSleepState(struct acpi_softc *sc, enum power_stype stype)
 
     ACPI_LOCK(acpi);
 
-    sc->acpi_next_stype = stype;
+    sc->acpi_next_sstate = state;
 
     /* S5 (soft-off) should be entered directly with no waiting. */
-    if (stype == POWER_STYPE_POWEROFF) {
+    if (state == ACPI_STATE_S5) {
     	ACPI_UNLOCK(acpi);
-	status = acpi_EnterSleepState(sc, stype);
+	status = acpi_EnterSleepState(sc, state);
 	return (ACPI_SUCCESS(status) ? 0 : ENXIO);
     }
 
@@ -3281,7 +3237,7 @@ acpi_ReqSleepState(struct acpi_softc *sc, enum power_stype stype)
     /* If devd(8) is not running, immediately enter the sleep state. */
     if (!devctl_process_running()) {
 	ACPI_UNLOCK(acpi);
-	status = acpi_EnterSleepState(sc, stype);
+	status = acpi_EnterSleepState(sc, state);
 	return (ACPI_SUCCESS(status) ? 0 : ENXIO);
     }
 
@@ -3296,7 +3252,7 @@ acpi_ReqSleepState(struct acpi_softc *sc, enum power_stype stype)
     ACPI_UNLOCK(acpi);
 
     /* Now notify devd(8) also. */
-    acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, stype);
+    acpi_UserNotify("Suspend", ACPI_ROOT_OBJECT, state);
 
     return (0);
 #else
@@ -3319,17 +3275,17 @@ acpi_AckSleepState(struct apm_clone_data *clone, int error)
     struct acpi_softc *sc;
     int ret, sleeping;
 
-    /* If no pending sleep type, return an error. */
+    /* If no pending sleep state, return an error. */
     ACPI_LOCK(acpi);
     sc = clone->acpi_sc;
-    if (sc->acpi_next_stype == POWER_STYPE_AWAKE) {
+    if (sc->acpi_next_sstate == 0) {
     	ACPI_UNLOCK(acpi);
 	return (ENXIO);
     }
 
     /* Caller wants to abort suspend process. */
     if (error) {
-	sc->acpi_next_stype = POWER_STYPE_AWAKE;
+	sc->acpi_next_sstate = 0;
 	callout_stop(&sc->susp_force_to);
 	device_printf(sc->acpi_dev,
 	    "listener on %s cancelled the pending suspend\n",
@@ -3359,7 +3315,7 @@ acpi_AckSleepState(struct apm_clone_data *clone, int error)
     ACPI_UNLOCK(acpi);
     ret = 0;
     if (sleeping) {
-	if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_stype)))
+	if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate)))
 		ret = ENODEV;
     }
     return (ret);
@@ -3416,7 +3372,7 @@ enum acpi_sleep_state {
  * Currently we support S1-S5 but S4 is only S4BIOS
  */
 static ACPI_STATUS
-acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
+acpi_EnterSleepState(struct acpi_softc *sc, int state)
 {
     register_t intr;
     ACPI_STATUS status;
@@ -3426,11 +3382,11 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 
     ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state);
 
-    if (stype <= POWER_STYPE_AWAKE || stype >= POWER_STYPE_COUNT)
+    if (state < ACPI_STATE_S1 || state > ACPI_S_STATES_MAX)
 	return_ACPI_STATUS (AE_BAD_PARAMETER);
-    if (!acpi_supported_stypes[stype]) {
-	device_printf(sc->acpi_dev, "Sleep type %s not supported on this "
-	    "platform\n", power_stype_to_name(stype));
+    if (!acpi_sleep_states[state]) {
+	device_printf(sc->acpi_dev, "Sleep state S%d not supported by BIOS\n",
+	    state);
 	return (AE_SUPPORT);
     }
 
@@ -3442,7 +3398,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 	return (status);
     }
 
-    if (stype == POWER_STYPE_POWEROFF) {
+    if (state == ACPI_STATE_S5) {
 	/*
 	 * Shut down cleanly and power off.  This will call us back through the
 	 * shutdown handlers.
@@ -3470,16 +3426,16 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 #endif
 
     /*
-     * Be sure to hold bus topology lock across DEVICE_SUSPEND/RESUME.
+     * Be sure to hold Giant across DEVICE_SUSPEND/RESUME
      */
     bus_topo_lock();
 
     slp_state = ACPI_SS_NONE;
 
-    sc->acpi_stype = stype;
+    sc->acpi_sstate = state;
 
     /* Enable any GPEs as appropriate and requested by the user. */
-    acpi_wake_prep_walk(stype);
+    acpi_wake_prep_walk(state);
     slp_state = ACPI_SS_GPE_SET;
 
     /*
@@ -3496,7 +3452,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
     }
     slp_state = ACPI_SS_DEV_SUSPEND;
 
-    status = AcpiEnterSleepStatePrep(stype);
+    status = AcpiEnterSleepStatePrep(state);
     if (ACPI_FAILURE(status)) {
 	device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n",
 		      AcpiFormatException(status));
@@ -3509,9 +3465,9 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 
     suspendclock();
     intr = intr_disable();
-    if (stype != POWER_STYPE_STANDBY) {
-	sleep_result = acpi_sleep_machdep(sc, stype);
-	acpi_wakeup_machdep(sc, stype, sleep_result, 0);
+    if (state != ACPI_STATE_S1) {
+	sleep_result = acpi_sleep_machdep(sc, state);
+	acpi_wakeup_machdep(sc, state, sleep_result, 0);
 
 	/*
 	 * XXX According to ACPI specification SCI_EN bit should be restored
@@ -3522,10 +3478,10 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 	 * This hack is picked up from Linux, which claims that it follows
 	 * Windows behavior.
 	 */
-	if (sleep_result == 1 && stype != POWER_STYPE_HIBERNATE)
+	if (sleep_result == 1 && state != ACPI_STATE_S4)
 	    AcpiWriteBitRegister(ACPI_BITREG_SCI_ENABLE, ACPI_ENABLE_EVENT);
 
-	if (sleep_result == 1 && stype == POWER_STYPE_SUSPEND_TO_MEM) {
+	if (sleep_result == 1 && state == ACPI_STATE_S3) {
 	    /*
 	     * Prevent mis-interpretation of the wakeup by power button
 	     * as a request for power off.
@@ -3551,20 +3507,20 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype)
 	intr_restore(intr);
 
 	/* call acpi_wakeup_machdep() again with interrupt enabled */
-	acpi_wakeup_machdep(sc, stype, sleep_result, 1);
+	acpi_wakeup_machdep(sc, state, sleep_result, 1);
 
-	AcpiLeaveSleepStatePrep(stype);
+	AcpiLeaveSleepStatePrep(state);
 
 	if (sleep_result == -1)
 		goto backout;
 
-	/* Re-enable ACPI hardware on wakeup from hibernate. */
-	if (stype == POWER_STYPE_HIBERNATE)
+	/* Re-enable ACPI hardware on wakeup from sleep state 4. */
+	if (state == ACPI_STATE_S4)
 	    AcpiEnable();
     } else {
-	status = AcpiEnterSleepState(stype);
+	status = AcpiEnterSleepState(state);
 	intr_restore(intr);
-	AcpiLeaveSleepStatePrep(stype);
+	AcpiLeaveSleepStatePrep(state);
 	if (ACPI_FAILURE(status)) {
 	    device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n",
 			  AcpiFormatException(status));
@@ -3581,13 +3537,13 @@ backout:
     if (slp_state >= ACPI_SS_SLP_PREP)
 	resumeclock();
     if (slp_state >= ACPI_SS_GPE_SET) {
-	acpi_wake_prep_walk(stype);
-	sc->acpi_stype = POWER_STYPE_AWAKE;
+	acpi_wake_prep_walk(state);
+	sc->acpi_sstate = ACPI_STATE_S0;
     }
     if (slp_state >= ACPI_SS_DEV_SUSPEND)
 	DEVICE_RESUME(root_bus);
     if (slp_state >= ACPI_SS_SLP_PREP)
-	AcpiLeaveSleepState(stype);
+	AcpiLeaveSleepState(state);
     if (slp_state >= ACPI_SS_SLEPT) {
 #if defined(__i386__) || defined(__amd64__)
 	/* NB: we are still using ACPI timecounter at this point. */
@@ -3596,7 +3552,7 @@ backout:
 	acpi_resync_clock(sc);
 	acpi_enable_fixed_events(sc);
     }
-    sc->acpi_next_stype = POWER_STYPE_AWAKE;
+    sc->acpi_next_sstate = 0;
 
     bus_topo_unlock();
 
@@ -3622,7 +3578,7 @@ backout:
 
     /* Run /etc/rc.resume after we are back. */
     if (devctl_process_running())
-	acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, stype);
+	acpi_UserNotify("Resume", ACPI_ROOT_OBJECT, state);
 
     return_ACPI_STATUS (status);
 }
@@ -3673,21 +3629,16 @@ acpi_wake_set_enable(device_t dev, int enable)
 }
 
 static int
-acpi_wake_sleep_prep(ACPI_HANDLE handle, enum power_stype stype)
+acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate)
 {
-    int sstate;
     struct acpi_prw_data prw;
     device_t dev;
-    struct acpi_softc *sc;
 
     /* Check that this is a wake-capable device and get its GPE. */
     if (acpi_parse_prw(handle, &prw) != 0)
 	return (ENXIO);
     dev = acpi_get_device(handle);
 
-    sc = device_get_softc(dev);
-    sstate = acpi_stype_to_sstate(sc, stype);
-
     /*
      * The destination sleep state must be less than (i.e., higher power)
      * or equal to the value specified by _PRW.  If this GPE cannot be
@@ -3698,26 +3649,24 @@ acpi_wake_sleep_prep(ACPI_HANDLE handle, enum power_stype stype)
     if (sstate > prw.lowest_wake) {
 	AcpiSetGpeWakeMask(prw.gpe_handle, prw.gpe_bit, ACPI_GPE_DISABLE);
 	if (bootverbose)
-	    device_printf(dev, "wake_prep disabled wake for %s (%s)\n",
-		acpi_name(handle), power_stype_to_name(stype));
+	    device_printf(dev, "wake_prep disabled wake for %s (S%d)\n",
+		acpi_name(handle), sstate);
     } else if (dev && (acpi_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) != 0) {
 	acpi_pwr_wake_enable(handle, 1);
 	acpi_SetInteger(handle, "_PSW", 1);
 	if (bootverbose)
-	    device_printf(dev, "wake_prep enabled for %s (%s)\n",
-		acpi_name(handle), power_stype_to_name(stype));
+	    device_printf(dev, "wake_prep enabled for %s (S%d)\n",
+		acpi_name(handle), sstate);
     }
 
     return (0);
 }
 
 static int
-acpi_wake_run_prep(ACPI_HANDLE handle, enum power_stype stype)
+acpi_wake_run_prep(ACPI_HANDLE handle, int sstate)
 {
-    int sstate;
     struct acpi_prw_data prw;
     device_t dev;
-    struct acpi_softc *sc;
 
     /*
      * Check that this is a wake-capable device and get its GPE.  Return
@@ -3729,9 +3678,6 @@ acpi_wake_run_prep(ACPI_HANDLE handle, enum power_stype stype)
     if (dev == NULL || (acpi_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) == 0)
 	return (0);
 
-    sc = device_get_softc(dev);
-    sstate = acpi_stype_to_sstate(sc, stype);
-
     /*
      * If this GPE couldn't be enabled for the previous sleep state, it was
      * disabled before going to sleep so re-enable it.  If it was enabled,
@@ -3755,26 +3701,26 @@ acpi_wake_run_prep(ACPI_HANDLE handle, enum power_stype stype)
 static ACPI_STATUS
 acpi_wake_prep(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
 {
-    enum power_stype stype;
+    int sstate;
 
     /* If suspending, run the sleep prep function, otherwise wake. */
-    stype = *(enum power_stype *)context;
+    sstate = *(int *)context;
     if (AcpiGbl_SystemAwakeAndRunning)
-	acpi_wake_sleep_prep(handle, stype);
+	acpi_wake_sleep_prep(handle, sstate);
     else
-	acpi_wake_run_prep(handle, stype);
+	acpi_wake_run_prep(handle, sstate);
     return (AE_OK);
 }
 
 /* Walk the tree rooted at acpi0 to prep devices for suspend/resume. */
 static int
-acpi_wake_prep_walk(enum power_stype stype)
+acpi_wake_prep_walk(int sstate)
 {
     ACPI_HANDLE sb_handle;
 
     if (ACPI_SUCCESS(AcpiGetHandle(ACPI_ROOT_OBJECT, "\\_SB_", &sb_handle)))
 	AcpiWalkNamespace(ACPI_TYPE_DEVICE, sb_handle, 100,
-	    acpi_wake_prep, NULL, &stype, NULL);
+	    acpi_wake_prep, NULL, &sstate, NULL);
     return (0);
 }
 
@@ -3933,7 +3879,7 @@ out:
 /* System Event Handlers (registered by EVENTHANDLER_REGISTER) */
 
 static void
-acpi_system_eventhandler_sleep(void *arg, enum power_stype stype)
+acpi_system_eventhandler_sleep(void *arg, int state)
 {
     struct acpi_softc *sc = (struct acpi_softc *)arg;
     int ret;
@@ -3941,27 +3887,23 @@ acpi_system_eventhandler_sleep(void *arg, enum power_stype stype)
     ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state);
 
     /* Check if button action is disabled or unknown. */
-    if (stype == ACPI_STATE_UNKNOWN)
+    if (state == ACPI_STATE_UNKNOWN)
 	return;
 
-    /*
-     * Request that the system prepare to enter the given suspend state. We can
-     * totally pass an ACPI S-state to an enum power_stype.
-     */
-    ret = acpi_ReqSleepState(sc, stype);
+    /* Request that the system prepare to enter the given suspend state. */
+    ret = acpi_ReqSleepState(sc, state);
     if (ret != 0)
 	device_printf(sc->acpi_dev,
-	    "request to enter state %s failed (err %d)\n",
-	    power_stype_to_name(stype), ret);
+	    "request to enter state S%d failed (err %d)\n", state, ret);
 
     return_VOID;
 }
 
 static void
-acpi_system_eventhandler_wakeup(void *arg, enum power_stype stype)
+acpi_system_eventhandler_wakeup(void *arg, int state)
 {
 
-    ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, stype);
+    ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, state);
 
     /* Currently, nothing to do for wakeup. */
 
@@ -3975,14 +3917,14 @@ static void
 acpi_invoke_sleep_eventhandler(void *context)
 {
 
-    EVENTHANDLER_INVOKE(acpi_sleep_event, *(enum power_stype *)context);
+    EVENTHANDLER_INVOKE(acpi_sleep_event, *(int *)context);
 }
 
 static void
 acpi_invoke_wake_eventhandler(void *context)
 {
 
-    EVENTHANDLER_INVOKE(acpi_wakeup_event, *(enum power_stype *)context);
+    EVENTHANDLER_INVOKE(acpi_wakeup_event, *(int *)context);
 }
 
 UINT32
@@ -3998,7 +3940,7 @@ acpi_event_power_button_sleep(void *context)
 
 #if defined(__amd64__) || defined(__i386__)
     if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER,
-	acpi_invoke_sleep_eventhandler, &sc->acpi_power_button_stype)))
+	acpi_invoke_sleep_eventhandler, &sc->acpi_power_button_sx)))
 	return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
 #else
     shutdown_nice(RB_POWEROFF);
@@ -4015,7 +3957,7 @@ acpi_event_power_button_wake(void *context)
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER,
-	acpi_invoke_wake_eventhandler, &sc->acpi_power_button_stype)))
+	acpi_invoke_wake_eventhandler, &sc->acpi_power_button_sx)))
 	return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
     return_VALUE (ACPI_INTERRUPT_HANDLED);
 }
@@ -4028,7 +3970,7 @@ acpi_event_sleep_button_sleep(void *context)
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER,
-	acpi_invoke_sleep_eventhandler, &sc->acpi_sleep_button_stype)))
+	acpi_invoke_sleep_eventhandler, &sc->acpi_sleep_button_sx)))
 	return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
     return_VALUE (ACPI_INTERRUPT_HANDLED);
 }
@@ -4041,7 +3983,7 @@ acpi_event_sleep_button_wake(void *context)
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER,
-	acpi_invoke_wake_eventhandler, &sc->acpi_sleep_button_stype)))
+	acpi_invoke_wake_eventhandler, &sc->acpi_sleep_button_sx)))
 	return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
     return_VALUE (ACPI_INTERRUPT_HANDLED);
 }
@@ -4237,8 +4179,7 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
 {
     struct acpi_softc		*sc;
     struct acpi_ioctl_hook	*hp;
-    int				error;
-    int				sstate;
+    int				error, state;
 
     error = 0;
     hp = NULL;
@@ -4268,9 +4209,9 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
     /* Core system ioctls. */
     switch (cmd) {
     case ACPIIO_REQSLPSTATE:
-	sstate = *(int *)addr;
-	if (sstate != ACPI_STATE_S5)
-	    return (acpi_ReqSleepState(sc, acpi_sstate_to_stype(sstate)));
+	state = *(int *)addr;
+	if (state != ACPI_STATE_S5)
+	    return (acpi_ReqSleepState(sc, state));
 	device_printf(sc->acpi_dev, "power off via acpi ioctl not supported\n");
 	error = EOPNOTSUPP;
 	break;
@@ -4279,12 +4220,12 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
 	error = acpi_AckSleepState(sc->acpi_clone, error);
 	break;
     case ACPIIO_SETSLPSTATE:	/* DEPRECATED */
-	sstate = *(int *)addr;
-	if (sstate < ACPI_STATE_S0 || sstate > ACPI_STATE_S5)
+	state = *(int *)addr;
+	if (state < ACPI_STATE_S0 || state > ACPI_S_STATES_MAX)
 	    return (EINVAL);
-	if (!acpi_supported_sstates[sstate])
+	if (!acpi_sleep_states[state])
 	    return (EOPNOTSUPP);
-	if (ACPI_FAILURE(acpi_SetSleepState(sc, acpi_sstate_to_stype(sstate))))
+	if (ACPI_FAILURE(acpi_SetSleepState(sc, state)))
 	    error = ENXIO;
 	break;
     default:
@@ -4296,7 +4237,7 @@ acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *t
 }
 
 static int
-acpi_sname_to_sstate(const char *sname)
+acpi_sname2sstate(const char *sname)
 {
     int sstate;
 
@@ -4311,15 +4252,14 @@ acpi_sname_to_sstate(const char *sname)
 }
 
 static const char *
-acpi_sstate_to_sname(int state)
+acpi_sstate2sname(int sstate)
 {
-    static const char *snames[ACPI_S_STATE_COUNT] = {"S0", "S1", "S2", "S3",
-	"S4", "S5"};
+    static const char *snames[] = { "S0", "S1", "S2", "S3", "S4", "S5" };
 
-    if (state == ACPI_STATE_UNKNOWN)
+    if (sstate >= ACPI_STATE_S0 && sstate <= ACPI_STATE_S5)
+	return (snames[sstate]);
+    else if (sstate == ACPI_STATE_UNKNOWN)
 	return ("NONE");
-    if (state >= ACPI_STATE_S0 && state < ACPI_S_STATE_COUNT)
-	return (snames[state]);
     return (NULL);
 }
 
@@ -4332,8 +4272,8 @@ acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)
 
     sbuf_new(&sb, NULL, 32, SBUF_AUTOEXTEND);
     for (state = ACPI_STATE_S1; state < ACPI_S_STATE_COUNT; state++)
-	if (acpi_supported_sstates[state])
-	    sbuf_printf(&sb, "%s ", acpi_sstate_to_sname(state));
+	if (acpi_sleep_states[state])
+	    sbuf_printf(&sb, "%s ", acpi_sstate2sname(state));
     sbuf_trim(&sb);
     sbuf_finish(&sb);
     error = sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
@@ -4341,64 +4281,27 @@ acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)
     return (error);
 }
 
-
 static int
 acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)
 {
     char sleep_state[10];
-    int error;
-    int new_sstate, old_sstate;
+    int error, new_state, old_state;
 
-    old_sstate = *(int *)oidp->oid_arg1;
-    strlcpy(sleep_state, acpi_sstate_to_sname(old_sstate), sizeof(sleep_state));
+    old_state = *(int *)oidp->oid_arg1;
+    strlcpy(sleep_state, acpi_sstate2sname(old_state), sizeof(sleep_state));
     error = sysctl_handle_string(oidp, sleep_state, sizeof(sleep_state), req);
     if (error == 0 && req->newptr != NULL) {
-	new_sstate = acpi_sname_to_sstate(sleep_state);
-	if (new_sstate < 0)
+	new_state = acpi_sname2sstate(sleep_state);
+	if (new_state < ACPI_STATE_S1)
 	    return (EINVAL);
-	if (new_sstate < ACPI_S_STATE_COUNT &&
-	    !acpi_supported_sstates[new_sstate])
+	if (new_state < ACPI_S_STATE_COUNT && !acpi_sleep_states[new_state])
 	    return (EOPNOTSUPP);
-	if (new_sstate != old_sstate)
-	    *(int *)oidp->oid_arg1 = new_sstate;
+	if (new_state != old_state)
+	    *(int *)oidp->oid_arg1 = new_state;
     }
     return (error);
 }
 
-static int
-acpi_stype_sysctl(SYSCTL_HANDLER_ARGS)
-{
-    char name[10];
-    int err;
-    int sstate;
-    enum power_stype new_stype, old_stype;
-
-    old_stype = *(enum power_stype *)oidp->oid_arg1;
-    strlcpy(name, power_stype_to_name(old_stype), sizeof(name));
-    err = sysctl_handle_string(oidp, name, sizeof(name), req);
-    if (err != 0 || req->newptr == NULL)
-	return (err);
-
-    new_stype = power_name_to_stype(name);
-    if (new_stype == POWER_STYPE_UNKNOWN) {
-	sstate = acpi_sname_to_sstate(name);
-	if (sstate < 0)
-	    return (EINVAL);
-	printf("warning: this sysctl expects a sleep type, but an ACPI S-state has "
-	    "been passed to it. This functionality is deprecated; see acpi(4).\n");
-	MPASS(sstate < ACPI_S_STATE_COUNT);
-	if (acpi_supported_sstates[sstate] == false)
-	    return (EOPNOTSUPP);
-	new_stype = acpi_sstate_to_stype(sstate);
-    }
-
-    if (acpi_supported_stypes[new_stype] == false)
-	return (EOPNOTSUPP);
-    if (new_stype != old_stype)
-	*(enum power_stype *)oidp->oid_arg1 = new_stype;
-    return (0);
-}
-
 /* Inform devctl(4) when we receive a Notify. */
 void
 acpi_UserNotify(const char *subsystem, ACPI_HANDLE h, uint8_t notify)
@@ -4747,7 +4650,7 @@ acpi_reset_interfaces(device_t dev)
 static int
 acpi_pm_func(u_long cmd, void *arg, enum power_stype stype)
 {
-	int	error;
+	int	error, sstate;
 	struct	acpi_softc *sc;
 
 	error = 0;
@@ -4758,7 +4661,8 @@ acpi_pm_func(u_long cmd, void *arg, enum power_stype stype)
 			error = EINVAL;
 			goto out;
 		}
-		if (ACPI_FAILURE(acpi_EnterSleepState(sc, stype)))
+		sstate = acpi_stype_to_sstate(sc, stype);
+		if (ACPI_FAILURE(acpi_EnterSleepState(sc, sstate)))
 			error = ENXIO;
 		break;
 	default:
diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c
index fb8755d9f0fe..142791f7282a 100644
--- a/sys/dev/acpica/acpi_lid.c
+++ b/sys/dev/acpica/acpi_lid.c
@@ -235,9 +235,9 @@ acpi_lid_notify_status_changed(void *arg)
 		sc->lid_status ? "opened" : "closed");
 
     if (sc->lid_status == 0)
-	EVENTHANDLER_INVOKE(acpi_sleep_event, acpi_sc->acpi_lid_switch_stype);
+	EVENTHANDLER_INVOKE(acpi_sleep_event, acpi_sc->acpi_lid_switch_sx);
     else
-	EVENTHANDLER_INVOKE(acpi_wakeup_event, acpi_sc->acpi_lid_switch_stype);
+	EVENTHANDLER_INVOKE(acpi_wakeup_event, acpi_sc->acpi_lid_switch_sx);
 
 out:
     ACPI_SERIAL_END(lid);
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 4c789dd3e9f2..fac32d832598 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -54,19 +54,20 @@ struct acpi_softc {
     struct cdev		*acpi_dev_t;
 
     int			acpi_enabled;
-    enum power_stype	acpi_stype;
+    int			acpi_sstate;
     int			acpi_sleep_disabled;
 
     struct sysctl_ctx_list acpi_sysctl_ctx;
     struct sysctl_oid	*acpi_sysctl_tree;
-    enum power_stype	acpi_power_button_stype;
-    enum power_stype	acpi_sleep_button_stype;
-    enum power_stype	acpi_lid_switch_stype;
+    int			acpi_power_button_sx;
+    int			acpi_sleep_button_sx;
+    int			acpi_lid_switch_sx;
 
     int			acpi_standby_sx;
-    int			acpi_s4bios;
+    int			acpi_suspend_sx;
 
     int			acpi_sleep_delay;
+    int			acpi_s4bios;
     int			acpi_do_disable;
     int			acpi_verbose;
     int			acpi_handle_reboot;
@@ -74,7 +75,7 @@ struct acpi_softc {
     vm_offset_t		acpi_wakeaddr;
     vm_paddr_t		acpi_wakephys;
 
-    enum power_stype	acpi_next_stype;	/* Next suspend sleep type. */
+    int			acpi_next_sstate;	/* Next suspend Sx state. */
     struct apm_clone_data *acpi_clone;		/* Pseudo-dev for devd(8). */
     STAILQ_HEAD(,apm_clone_data) apm_cdevs;	/* All apm/apmctl/acpi cdevs. */
     struct callout	susp_force_to;		/* Force suspend if no acks. */
@@ -411,7 +412,7 @@ ACPI_STATUS	acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid,
 		    uint32_t *caps_out, bool query);
 ACPI_STATUS	acpi_OverrideInterruptLevel(UINT32 InterruptNumber);
 ACPI_STATUS	acpi_SetIntrModel(int model);
-int		acpi_ReqSleepState(struct acpi_softc *sc, enum power_stype stype);
+int		acpi_ReqSleepState(struct acpi_softc *sc, int state);
 int		acpi_AckSleepState(struct apm_clone_data *clone, int error);
 ACPI_STATUS	acpi_SetSleepState(struct acpi_softc *sc, int state);
 int		acpi_wake_set_enable(device_t dev, int enable);
diff --git a/sys/x86/acpica/acpi_apm.c b/sys/x86/acpica/acpi_apm.c
index 8e5785cf0ed6..be161cd6171b 100644
--- a/sys/x86/acpica/acpi_apm.c
+++ b/sys/x86/acpica/acpi_apm.c
@@ -235,7 +235,7 @@ apmdtor(void *data)
 	acpi_sc = clone->acpi_sc;
 
 	/* We are about to lose a reference so check if suspend should occur */
-	if (acpi_sc->acpi_next_stype != POWER_STYPE_AWAKE &&
+	if (acpi_sc->acpi_next_sstate != 0 &&
 	    clone->notify_status != APM_EV_ACKED)
 		acpi_AckSleepState(clone, 0);
 
@@ -283,10 +283,10 @@ apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
 	case APMIO_SUSPEND:
 		if ((flag & FWRITE) == 0)
 			return (EPERM);
-		if (acpi_sc->acpi_next_stype == POWER_STYPE_AWAKE) {
-			if (power_suspend_stype != POWER_STYPE_POWEROFF) {
+		if (acpi_sc->acpi_next_sstate == 0) {
+			if (acpi_sc->acpi_suspend_sx != ACPI_STATE_S5) {
 				error = acpi_ReqSleepState(acpi_sc,
-				    power_suspend_stype);
+				    acpi_sc->acpi_suspend_sx);
 			} else {
 				printf(
 			"power off via apm suspend not supported\n");
@@ -298,10 +298,10 @@ apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
 	case APMIO_STANDBY:
 		if ((flag & FWRITE) == 0)
 			return (EPERM);
-		if (acpi_sc->acpi_next_stype == POWER_STYPE_AWAKE) {
-			if (power_standby_stype != POWER_STYPE_POWEROFF) {
+		if (acpi_sc->acpi_next_sstate == 0) {
+			if (acpi_sc->acpi_standby_sx != ACPI_STATE_S5) {
 				error = acpi_ReqSleepState(acpi_sc,
-				    power_standby_stype);
+				    acpi_sc->acpi_standby_sx);
 			} else {
 				printf(
 			"power off via apm standby not supported\n");
@@ -313,11 +313,10 @@ apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
 	case APMIO_NEXTEVENT:
 		printf("apm nextevent start\n");
 		ACPI_LOCK(acpi);
-		if (acpi_sc->acpi_next_stype != POWER_STYPE_AWAKE &&
-		    clone->notify_status == APM_EV_NONE) {
+		if (acpi_sc->acpi_next_sstate != 0 && clone->notify_status ==
+		    APM_EV_NONE) {
 			ev_info = (struct apm_event_info *)addr;
-			/* XXX Check this. */
-			if (acpi_sc->acpi_next_stype == POWER_STYPE_STANDBY)
+			if (acpi_sc->acpi_next_sstate <= ACPI_STATE_S3)
 				ev_info->type = PMEV_STANDBYREQ;
 			else
 				ev_info->type = PMEV_SUSPENDREQ;
@@ -393,7 +392,7 @@ apmpoll(struct cdev *dev, int events, struct thread *td)
 	revents = 0;
 	devfs_get_cdevpriv((void **)&clone);
 	ACPI_LOCK(acpi);
-	if (clone->acpi_sc->acpi_next_stype != POWER_STYPE_AWAKE)
*** 13 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202509180950.58I9o0rE017137>