diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-11-23 20:33:48 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-11-23 20:33:48 +0000 |
commit | 10d4c300477620e5aac8644b6b572f5154334686 (patch) | |
tree | 875bbfdcd0e480298731cef8372bf357c34cea53 /sys | |
parent | c3db7e4f19b4ef410c966f31d0a38eb63b9a741d (diff) |
If a machine has no _LIDs, then none can be open. This diff fixes a problem
where machines without any _LIDs were going back to sleep after hibernate
due to the recent suspend-if-lid-closed-on-resume diff. Noticed on qemu,
which doesn't have any _LIDs.
discussed with deraadt
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpi.c | 8 | ||||
-rw-r--r-- | sys/dev/acpi/acpibtn.c | 31 | ||||
-rw-r--r-- | sys/dev/acpi/acpidev.h | 4 |
3 files changed, 27 insertions, 16 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 37b092787de..67659c875cf 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.274 2014/11/18 23:55:01 krw Exp $ */ +/* $OpenBSD: acpi.c,v 1.275 2014/11/23 20:33:47 mlarkin Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2251,10 +2251,8 @@ fail_alloc: acpi_record_event(sc, APM_NORMAL_RESUME); acpi_indicator(sc, ACPI_SST_WORKING); - /* - * If we woke up but the lid is closed, go back to sleep - */ - if (!acpibtn_checklidopen()) + /* If we woke up but all the lids are closed, go back to sleep */ + if (acpibtn_numopenlids() == 0) acpi_addtask(sc, acpi_sleep_task, sc, state); fail_tts: diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index 4cc98402600..391558ded0d 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.38 2014/11/08 07:45:10 mlarkin Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.39 2014/11/23 20:33:47 mlarkin Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -75,23 +75,36 @@ struct cfdriver acpibtn_cd = { const char *acpibtn_hids[] = { ACPI_DEV_LD, ACPI_DEV_PBD, ACPI_DEV_SBD, 0 }; +/* + * acpibtn_numopenlids + * + * Return the number of _LID devices that are in the "open" state. Used to + * determine if we should go back to sleep/hibernate if we woke up with the all + * the lids still closed for some reason. If the machine has no lids, returns + * -1. + */ int -acpibtn_checklidopen(void) +acpibtn_numopenlids(void) { - int64_t val, status; + int64_t val, ct; struct acpi_lid *lid; - status = 0; + /* If we have no lids ... */ + if (SLIST_EMPTY(&acpibtn_lids)) + return (-1); - /* Check if any of the lid(s) are open */ + ct = 0; + + /* + * Determine how many lids are open. Assumes _LID evals to 1 or 0, for + * on / off (which is what the spec says). + */ SLIST_FOREACH(lid, &acpibtn_lids, abl_link) if (!aml_evalinteger(lid->abl_softc->sc_acpi, lid->abl_softc->sc_devnode, "_LID", 0, NULL, &val)) - status |= val; - else - return (0); + ct += val; - return (status); + return (ct); } int diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h index c007aa94eae..f8cdfbb4919 100644 --- a/sys/dev/acpi/acpidev.h +++ b/sys/dev/acpi/acpidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidev.h,v 1.35 2014/11/08 07:45:10 mlarkin Exp $ */ +/* $OpenBSD: acpidev.h,v 1.36 2014/11/23 20:33:47 mlarkin Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> @@ -337,5 +337,5 @@ struct acpiec_softc { void acpibtn_disable_psw(void); void acpibtn_enable_psw(void); -int acpibtn_checklidopen(void); +int acpibtn_numopenlids(void); #endif /* __DEV_ACPI_ACPIDEV_H__ */ |