git: eeaa865edba6 - main - acpi: Fix setting sleep state sysctls to NONE
Date: Fri, 28 Nov 2025 14:44:45 UTC
The branch main has been updated by obiwac:
URL: https://cgit.FreeBSD.org/src/commit/?id=eeaa865edba685545ac22c378b35552e09bf1b41
commit eeaa865edba685545ac22c378b35552e09bf1b41
Author: Aymeric Wibo <obiwac@FreeBSD.org>
AuthorDate: 2025-11-25 19:34:34 +0000
Commit: Aymeric Wibo <obiwac@FreeBSD.org>
CommitDate: 2025-11-28 14:42:54 +0000
acpi: Fix setting sleep state sysctls to NONE
This restores the functionality as it was pre-97d152698f48.
A stopgap was committed by glebius@ in 34dfccc64f47 ("acpi: in
acpi_stype_sysctl() use same logic as in acpi_sleep_state_sysctl()").
PR: 290651
Reviewed by: thj, emaste
Approved by: thj
Fixes: 97d152698f48 ("acpi: Use sleep types defined in sys/power.h")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53909
---
sys/dev/acpica/acpi.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index e3ff4f6937d2..99dd817f9158 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -4318,13 +4318,15 @@ acpi_sname_to_sstate(const char *sname)
{
int sstate;
+ if (strcasecmp(sname, "NONE") == 0)
+ return (ACPI_STATE_UNKNOWN);
+
if (toupper(sname[0]) == 'S') {
sstate = sname[1] - '0';
if (sstate >= ACPI_STATE_S0 && sstate <= ACPI_STATE_S5 &&
sname[2] == '\0')
return (sstate);
- } else if (strcasecmp(sname, "NONE") == 0)
- return (ACPI_STATE_UNKNOWN);
+ }
return (-1);
}
@@ -4379,8 +4381,10 @@ acpi_suspend_state_sysctl(SYSCTL_HANDLER_ARGS)
if (new_sstate < 0)
return (EINVAL);
new_stype = acpi_sstate_to_stype(new_sstate);
- if (acpi_supported_stypes[new_stype] == false)
+ if (new_sstate != ACPI_STATE_UNKNOWN &&
+ acpi_supported_stypes[new_stype] == false)
return (EOPNOTSUPP);
+
if (new_stype != old_stype)
power_suspend_stype = new_stype;
return (err);
@@ -4423,21 +4427,26 @@ acpi_stype_sysctl(SYSCTL_HANDLER_ARGS)
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");
- if (sstate < ACPI_S_STATE_COUNT &&
- !acpi_supported_sstates[sstate])
+ if (strcasecmp(name, "NONE") == 0) {
+ new_stype = POWER_STYPE_UNKNOWN;
+ } else {
+ 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);
- 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);