summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-11-10 21:40:56 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-11-10 21:40:56 +0000
commitf1846fcdaf71ebc48c1896e2e5afdd7b097b6e4b (patch)
tree6df5f099a275e97af4adbed931054627e1fe278d /sys/dev
parenta0d05184f8535132e2f4d87e1cdbdfd4796008c4 (diff)
The acpibat(4) notify function should not unconditionally call both _BIF
and _BST. Some machines (like the Toshiba Satellite Pro U550 18F mentioned in PR 6508) have AML that does a Notify(0x81) from the _BST method, which leads to infinite recursion. Instead call _BIF when the argument is 0x81 and call _BST when the argument is 0x80 or 0x00 (the latter indicates we're polling). Simplify the battery detection logic while there. ok mikeb@, marco@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpibat.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c
index 882846b6c60..8d131487b98 100644
--- a/sys/dev/acpi/acpibat.c
+++ b/sys/dev/acpi/acpibat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpibat.c,v 1.57 2010/08/07 16:55:38 canacar Exp $ */
+/* $OpenBSD: acpibat.c,v 1.58 2010/11/10 21:40:55 kettenis Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -186,13 +186,6 @@ acpibat_refresh(void *arg)
return;
}
- /*
- * XXX don't really need _BIF but keep it here in case we
- * miss an insertion/removal event
- */
- acpibat_getbif(sc);
- acpibat_getbst(sc);
-
/* _BIF values are static, sensor 0..3 */
if (sc->sc_bif.bif_last_capacity == BIF_UNKNOWN) {
sc->sc_sens[0].value = 0;
@@ -386,7 +379,8 @@ out:
return (rv);
}
-/* XXX it has been observed that some systems do not propagate battery
+/*
+ * XXX it has been observed that some systems do not propagate battery
* insertion events up to the driver. What seems to happen is that DSDT
* does receive an interrupt however the originator bit is not set.
* This seems to happen when one inserts a 100% full battery. Removal
@@ -400,23 +394,25 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg)
{
struct acpibat_softc *sc = arg;
int64_t sta;
- int present;
dnprintf(10, "acpibat_notify: %.2x %s\n", notify_type,
sc->sc_devnode->name);
/* Check if installed state of battery has changed */
if (aml_evalinteger(sc->sc_acpi, node, "_STA", 0, NULL, &sta) == 0) {
- present = sta & STA_BATTERY;
- if (!sc->sc_bat_present && present)
+ if (sta & STA_BATTERY)
sc->sc_bat_present = 1;
- else if (sc->sc_bat_present && !present)
+ else
sc->sc_bat_present = 0;
}
+
switch (notify_type) {
+ case 0x00: /* Poll sensors */
case 0x80: /* _BST changed */
+ acpibat_getbst(sc);
break;
case 0x81: /* _BIF changed */
+ acpibat_getbif(sc);
break;
default:
break;