From: deraadt Date: Thu, 5 Aug 2010 17:26:57 +0000 (+0000) Subject: PM1 power button events were generating 'fake events' to acpibtn PWRB, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ae37d65765e853c15873e03390a389798614694;p=openbsd PM1 power button events were generating 'fake events' to acpibtn PWRB, but if there is no such device these were being tossed. Instead, arrange for all power button handlers to flag a softc variable which is processed by the thread; so that one place will know to request a powerdown (psignal to init) ok marco mlarkin --- diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index b2a30b6bc13..b460ffd402b 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.202 2010/08/05 17:00:50 deraadt Exp $ */ +/* $OpenBSD: acpi.c,v 1.203 2010/08/05 17:26:57 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -2030,7 +2030,7 @@ acpi_thread(void *arg) sc->sc_powerbtn = 0; dnprintf(1,"power button pressed\n"); - aml_notify_dev(ACPI_DEV_PBD, 0x80); + sc->sc_powerdown = 1; /* Reset the latch and re-enable the GPE */ s = spltty(); @@ -2061,6 +2061,13 @@ acpi_thread(void *arg) acpi_poll_notify(); } + if (sc->sc_powerdown) { + sc->sc_powerdown = 0; + + /* XXX put a knob in front of this */ + psignal(initproc, SIGUSR2); + } + if (sc->sc_sleepmode) { int sleepmode = sc->sc_sleepmode; diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index cba0cafed74..9c9e66b40d7 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.27 2010/07/06 20:14:17 deraadt Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.28 2010/08/05 17:26:57 deraadt Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -164,7 +164,7 @@ acpibtn_notify(struct aml_node *node, int notify_type, void *arg) break; case ACPIBTN_POWER: if (notify_type == 0x80) - psignal(initproc, SIGUSR2); + sc->sc_acpi->sc_powerdown = 1; break; default: printf("%s: spurious acpi button interrupt %i\n", DEVNAME(sc), diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index 9f62bbcb9ea..9e2749b5ef5 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.63 2010/07/20 12:14:10 deraadt Exp $ */ +/* $OpenBSD: acpivar.h,v 1.64 2010/08/05 17:26:57 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -209,6 +209,7 @@ struct acpi_softc { int sc_sleepbtn; int sc_sleepmode; + int sc_powerdown; struct { int slp_typa;