The branch main has been updated by obiwac:

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

commit d35e369d0a7f37c580b89485a148d007faf05b52
Author:     Aymeric Wibo <[email protected]>
AuthorDate: 2026-02-05 14:55:17 +0000
Commit:     Aymeric Wibo <[email protected]>
CommitDate: 2026-02-05 15:10:30 +0000

    sys/power.h: enum power_sstate_transition
    
    Turn POWER_SLEEP_STATE_* defines into enum power_sstate_transition.
    
    Reviewed by:    markj
    Approved by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52497
---
 sys/dev/acpi_support/acpi_ibm.c |  7 ++++++-
 sys/dev/syscons/syscons.c       |  4 ++--
 sys/dev/vt/vt_core.c            |  4 ++--
 sys/kern/subr_power.c           | 13 +++++++------
 sys/sys/power.h                 | 18 ++++++++++--------
 5 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c
index f895d48bb6d0..1221384e7d8a 100644
--- a/sys/dev/acpi_support/acpi_ibm.c
+++ b/sys/dev/acpi_support/acpi_ibm.c
@@ -1447,8 +1447,13 @@ acpi_ibm_eventhandler(struct acpi_ibm_softc *sc, int arg)
 
        ACPI_SERIAL_BEGIN(ibm);
        switch (arg) {
+       /*
+        * XXX "Suspend-to-RAM" here is as opposed to suspend-to-disk, but it is
+        * fine if our suspend sleep state transition request puts us in s2idle
+        * instead of suspend-to-RAM.
+        */
        case IBM_EVENT_SUSPEND_TO_RAM:
-               power_pm_suspend(POWER_SLEEP_STATE_SUSPEND);
+               power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND);
                break;
 
        case IBM_EVENT_BLUETOOTH:
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index e9d664f51a1f..1a2969d6f2d8 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -3987,10 +3987,10 @@ next_code:
                                break;
 
                        case SUSP:
-                               power_pm_suspend(POWER_SLEEP_STATE_SUSPEND);
+                               
power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND);
                                break;
                        case STBY:
-                               power_pm_suspend(POWER_SLEEP_STATE_STANDBY);
+                               
power_pm_suspend(POWER_SSTATE_TRANSITION_STANDBY);
                                break;
 
                        case DBG:
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index a6a5f0eeff9d..fd18e85092db 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -804,11 +804,11 @@ vt_machine_kbdevent(struct vt_device *vd, int c)
                return (1);
        case SPCLKEY | STBY: /* XXX Not present in kbdcontrol parser. */
                /* Put machine into Stand-By mode. */
-               power_pm_suspend(POWER_SLEEP_STATE_STANDBY);
+               power_pm_suspend(POWER_SSTATE_TRANSITION_STANDBY);
                return (1);
        case SPCLKEY | SUSP: /* kbdmap(5) keyword `susp`. */
                /* Suspend machine. */
-               power_pm_suspend(POWER_SLEEP_STATE_SUSPEND);
+               power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND);
                return (1);
        }
 
diff --git a/sys/kern/subr_power.c b/sys/kern/subr_power.c
index f5a581e42bf3..13448cfa4d1e 100644
--- a/sys/kern/subr_power.c
+++ b/sys/kern/subr_power.c
@@ -176,25 +176,26 @@ power_pm_get_type(void)
 }
 
 void
-power_pm_suspend(int state)
+power_pm_suspend(enum power_sstate_transition trans)
 {
        enum power_stype        stype;
 
        if (power_pm_fn == NULL)
                return;
 
-       switch (state) {
-       case POWER_SLEEP_STATE_STANDBY:
+       switch (trans) {
+       case POWER_SSTATE_TRANSITION_STANDBY:
                stype = power_standby_stype;
                break;
-       case POWER_SLEEP_STATE_SUSPEND:
+       case POWER_SSTATE_TRANSITION_SUSPEND:
                stype = power_suspend_stype;
                break;
-       case POWER_SLEEP_STATE_HIBERNATE:
+       case POWER_SSTATE_TRANSITION_HIBERNATE:
                stype = power_hibernate_stype;
                break;
        default:
-               printf("%s: unknown sleep state %d\n", __func__, state);
+               printf("%s: unknown sleep state transition %d\n", __func__,
+                   trans);
                return;
        }
 
diff --git a/sys/sys/power.h b/sys/sys/power.h
index 33ace400bfd2..d34af0ddb86a 100644
--- a/sys/sys/power.h
+++ b/sys/sys/power.h
@@ -45,22 +45,24 @@
 #define POWER_CMD_SUSPEND              0x00
 
 /*
- * Sleep state.
+ * Sleep state transition requests.
  *
  * These are high-level sleep states that the system can enter.  They map to
  * a specific generic sleep type (enum power_stype).
  */
-#define POWER_SLEEP_STATE_STANDBY      0x00
-#define POWER_SLEEP_STATE_SUSPEND      0x01
-#define POWER_SLEEP_STATE_HIBERNATE    0x02
+enum power_sstate_transition {
+       POWER_SSTATE_TRANSITION_STANDBY,
+       POWER_SSTATE_TRANSITION_SUSPEND,
+       POWER_SSTATE_TRANSITION_HIBERNATE,
+};
 
 /*
  * Sleep type.
  *
  * These are the specific generic methods of entering a sleep state.  E.g.
- * POWER_SLEEP_STATE_SUSPEND could be set to enter either suspend-to-RAM (which
- * is S3 on ACPI systems), or suspend-to-idle (S0ix on ACPI systems).  This
- * would be done through the kern.power.suspend sysctl.
+ * POWER_SSTATE_TRANSITION_SUSPEND could be set to enter either suspend-to-RAM
+ * (which is S3 on ACPI systems), or suspend-to-idle (S0ix on ACPI systems).
+ * This would be done through the kern.power.suspend sysctl.
  */
 enum power_stype {
        POWER_STYPE_AWAKE,
@@ -94,7 +96,7 @@ extern int     power_pm_register(u_int _pm_type, 
power_pm_fn_t _pm_fn,
                        void *_pm_arg,
                        bool _pm_supported[static POWER_STYPE_COUNT]);
 extern u_int    power_pm_get_type(void);
-extern void     power_pm_suspend(int);
+extern void     power_pm_suspend(enum power_sstate_transition _trans);
 
 /*
  * System power API.

Reply via email to