diff options
author | 2017-03-02 10:38:09 +0000 | |
---|---|---|
committer | 2017-03-02 10:38:09 +0000 | |
commit | 2d357aeded0106833319c29a54d2bb4b14c40d90 (patch) | |
tree | 65a308eef3237aa2a4cbc2d2c3e20c7e67104495 /sys/dev | |
parent | 8168 support jumbo frames; (diff) | |
download | wireguard-openbsd-2d357aeded0106833319c29a54d2bb4b14c40d90.tar.xz wireguard-openbsd-2d357aeded0106833319c29a54d2bb4b14c40d90.zip |
Add a new sysctl machdep.lidaction. The sysctl works as follows:
machdep.lidaction=0 # do nothing
machdep.lidaction=1 # suspend
machdep.lidaction=2 # hibernate
lidsuspend is just an alias for lidaction, so if you change one, the
other one will have the same value. The plan is to remove
machdep.lidsuspend eventually when people have upgraded their
/ets/sysctl.conf.
discussed with deraadt, who came up with the new MIB name
no objections mlarkin
ok stsp halex jcs
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpi/acpi.c | 6 | ||||
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 22 | ||||
-rw-r--r-- | sys/dev/isa/aps.c | 6 |
3 files changed, 24 insertions, 10 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 0b4cdcc9c8c..67c76c6d21a 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.322 2017/02/28 10:39:07 natano Exp $ */ +/* $OpenBSD: acpi.c,v 1.323 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2349,7 +2349,7 @@ int acpi_sleep_state(struct acpi_softc *sc, int sleepmode) { extern int perflevel; - extern int lid_suspend; + extern int lid_action; int error = ENXIO; size_t rndbuflen = 0; char *rndbuf = NULL; @@ -2506,7 +2506,7 @@ fail_alloc: acpi_indicator(sc, ACPI_SST_WORKING); /* If we woke up but all the lids are closed, go back to sleep */ - if (acpibtn_numopenlids() == 0 && lid_suspend != 0) + if (acpibtn_numopenlids() == 0 && lid_action != 0) acpi_addtask(sc, acpi_sleep_task, sc, sleepmode); fail_tts: diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index badfc8f23b3..8f9e2c20749 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.43 2017/02/28 10:39:07 natano Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.44 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -207,7 +207,7 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibtn_softc *sc = arg; #ifndef SMALL_KERNEL - extern int lid_suspend; + extern int lid_action; int64_t lid; #endif @@ -227,10 +227,24 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) "_LID", 0, NULL, &lid)) return (0); sc->sc_sens.value = lid; - if (lid_suspend == 0) + + if (lid != 0) break; - if (lid == 0) + + switch (lid_action) { + case 1: goto sleep; +#ifdef HIBERNATE + case 2: + /* Request to go to sleep */ + if (acpi_record_event(sc->sc_acpi, APM_USER_HIBERNATE_REQ)) + acpi_addtask(sc->sc_acpi, acpi_sleep_task, + sc->sc_acpi, ACPI_SLEEP_HIBERNATE); + break; +#endif + default: + break; + } #endif /* SMALL_KERNEL */ break; case ACPIBTN_SLEEP: diff --git a/sys/dev/isa/aps.c b/sys/dev/isa/aps.c index fa1f4662e9d..c1f93bcaa74 100644 --- a/sys/dev/isa/aps.c +++ b/sys/dev/isa/aps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aps.c,v 1.25 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: aps.c,v 1.26 2017/03/02 10:38:10 natano Exp $ */ /* * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> * Copyright (c) 2008 Can Erkin Acar <canacar@openbsd.org> @@ -434,7 +434,7 @@ aps_refresh_sensor_data(struct aps_softc *sc) int64_t temp; int i; #if NAPM > 0 - extern int lid_suspend; + extern int lid_action; extern int apm_lidclose; #endif @@ -467,7 +467,7 @@ aps_refresh_sensor_data(struct aps_softc *sc) sc->sensors[APS_SENSOR_MSACT].value = (sc->aps_data.input & APS_INPUT_MS) ? 1 : 0; #if NAPM > 0 - if (lid_suspend && + if (lid_action && (sc->sensors[APS_SENSOR_LIDOPEN].value == 1) && (sc->aps_data.input & APS_INPUT_LIDOPEN) == 0) /* Inform APM that the lid has closed */ |