summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2014-11-08 07:45:11 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2014-11-08 07:45:11 +0000
commitb60f405a3994974108399b09445517538e1c7db6 (patch)
treec2d45ae363cfc2988eba27188505772aa3d2ef6e /sys/dev
parent2de2beef57b808598a2c8f7d01edbc88f4c05453 (diff)
If resuming from sleep (zzz/ZZZ) and the lid is still closed, go back to
sleep. This prevents accidental lid flex or slight opening in a backpack from waking the machine up and leaving it resumed (powered on). ok deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi.c8
-rw-r--r--sys/dev/acpi/acpibtn.c21
-rw-r--r--sys/dev/acpi/acpidev.h3
3 files changed, 29 insertions, 3 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index a0488db29a1..7015c2ce7e5 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.272 2014/09/26 09:25:38 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.273 2014/11/08 07:45:10 mlarkin Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -2252,6 +2252,12 @@ 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())
+ acpi_addtask(sc, acpi_sleep_task, sc, state);
+
fail_tts:
return (error);
}
diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c
index 94f18638537..4cc98402600 100644
--- a/sys/dev/acpi/acpibtn.c
+++ b/sys/dev/acpi/acpibtn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibtn.c,v 1.37 2014/10/16 17:46:06 mlarkin Exp $ */
+/* $OpenBSD: acpibtn.c,v 1.38 2014/11/08 07:45:10 mlarkin Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -76,6 +76,25 @@ struct cfdriver acpibtn_cd = {
const char *acpibtn_hids[] = { ACPI_DEV_LD, ACPI_DEV_PBD, ACPI_DEV_SBD, 0 };
int
+acpibtn_checklidopen(void)
+{
+ int64_t val, status;
+ struct acpi_lid *lid;
+
+ status = 0;
+
+ /* Check if any of the lid(s) are open */
+ 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);
+
+ return (status);
+}
+
+int
acpibtn_setpsw(struct acpibtn_softc *sc, int psw)
{
struct aml_value val;
diff --git a/sys/dev/acpi/acpidev.h b/sys/dev/acpi/acpidev.h
index 4109d131d87..c007aa94eae 100644
--- a/sys/dev/acpi/acpidev.h
+++ b/sys/dev/acpi/acpidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpidev.h,v 1.34 2014/05/23 19:17:39 landry Exp $ */
+/* $OpenBSD: acpidev.h,v 1.35 2014/11/08 07:45:10 mlarkin Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
@@ -337,4 +337,5 @@ struct acpiec_softc {
void acpibtn_disable_psw(void);
void acpibtn_enable_psw(void);
+int acpibtn_checklidopen(void);
#endif /* __DEV_ACPI_ACPIDEV_H__ */