From ba27658807ea823622cfd6c4ddce7f48c4ce97fb Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 21 Mar 2022 13:38:34 +0000 Subject: [PATCH] Update hw.power whenever we refresh the AC state. This makes sure the state doesn't get out of sync with what apm(8) reports if power is plugged or unplugged when a machine is suspended. Which in turn makes sure the machine properly goes into a low CPU P-state when requested. ok deraadt@, florian@ --- sys/dev/acpi/acpiac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index acd932280b5..12e80b01b3e 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.34 2021/10/30 23:24:47 deraadt Exp $ */ +/* $OpenBSD: acpiac.c,v 1.35 2022/03/21 13:38:34 kettenis Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -118,9 +118,11 @@ void acpiac_refresh(void *arg) { struct acpiac_softc *sc = arg; + extern int hw_power; acpiac_getpsr(sc); sc->sc_sens[0].value = sc->sc_ac_stat; + hw_power = (sc->sc_ac_stat == PSR_ONLINE); } int @@ -142,7 +144,6 @@ int acpiac_notify(struct aml_node *node, int notify_type, void *arg) { struct acpiac_softc *sc = arg; - extern int hw_power; dnprintf(10, "acpiac_notify: %.2x %s\n", notify_type, DEVNAME(sc)); @@ -162,6 +163,5 @@ acpiac_notify(struct aml_node *node, int notify_type, void *arg) dnprintf(10, "A/C status: %d\n", sc->sc_ac_stat); break; } - hw_power = (sc->sc_ac_stat == PSR_ONLINE); return (0); } -- 2.20.1