diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2026-01-28 16:06:30 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2026-02-19 10:29:07 +0000 |
| commit | 781c9b0a595f9af501ad836a120aedba91c13a0b (patch) | |
| tree | 89495fa1f0d01257ba61d05ce507efd2bd1a9f5f | |
| parent | d18aaeff8fd314e79642062d95110ad174bd1882 (diff) | |
acpi: Factor out message printing on failure of AcpiEnterSleepStatePrep()
To this end, create a small wrapper, acpi_EnterSleepStatePrep(), which
itself prints the failure message.
While here, when trying to power down (acpi_shutdown_final()), and
AcpiEnterSleepStatePrep() failed, print an additional message more
explicit about the power down request having failed.
Reviewed by: obiwac
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55225
| -rw-r--r-- | sys/dev/acpica/acpi.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 59ae4624f407..bbcf6ba34666 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2593,6 +2593,23 @@ acpi_fake_objhandler(ACPI_HANDLE h, void *data) { } +/* + * Simple wrapper around AcpiEnterSleepStatePrep() printing diagnostic on error. + */ +static ACPI_STATUS +acpi_EnterSleepStatePrep(device_t acpi_dev, UINT8 SleepState) +{ + ACPI_STATUS status; + + status = AcpiEnterSleepStatePrep(SleepState); + if (ACPI_FAILURE(status)) + device_printf(acpi_dev, + "AcpiEnterSleepStatePrep(%u) failed - %s\n", + SleepState, + AcpiFormatException(status)); + return (status); +} + static void acpi_shutdown_final(void *arg, int howto) { @@ -2606,9 +2623,9 @@ acpi_shutdown_final(void *arg, int howto) * an AP. */ if ((howto & RB_POWEROFF) != 0) { - status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); + status = acpi_EnterSleepStatePrep(sc->acpi_dev, ACPI_STATE_S5); if (ACPI_FAILURE(status)) { - device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", + device_printf(sc->acpi_dev, "Power-off preparation failed! - %s\n", AcpiFormatException(status)); return; } @@ -3659,12 +3676,9 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype) slp_state |= ACPI_SS_DEV_SUSPEND; if (stype != POWER_STYPE_SUSPEND_TO_IDLE) { - status = AcpiEnterSleepStatePrep(acpi_sstate); - if (ACPI_FAILURE(status)) { - device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", - AcpiFormatException(status)); + status = acpi_EnterSleepStatePrep(sc->acpi_dev, acpi_sstate); + if (ACPI_FAILURE(status)) goto backout; - } slp_state |= ACPI_SS_SLP_PREP; } |
