diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2008-08-05 17:01:07 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2008-08-05 17:01:07 +0000 |
commit | 38a890f6560545ec0fe1aef2f3af119a54bf3320 (patch) | |
tree | 83718ebdcb9a0b848430033c0de51bbd0efc6cef /sys/dev/acpi/acpibat.c | |
parent | 7c493c27a36c04a8d057feda92b134f5c6de7a49 (diff) |
Fix spurious 0 values on batteries seen on laptopts that have an embedded
controller.
Found, diagnosed and patch from Stefan Sperling <stsp@stsp.name>
Minor KNF changes while here.
Tested by many on a variaty of IBM laptops and others with and without
acpiec.
ok deraadt
Diffstat (limited to 'sys/dev/acpi/acpibat.c')
-rw-r--r-- | sys/dev/acpi/acpibat.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index fc8ac6bc03c..ee86f7c8693 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.50 2008/06/13 05:50:21 jordan Exp $ */ +/* $OpenBSD: acpibat.c,v 1.51 2008/08/05 17:01:06 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -292,9 +292,10 @@ acpibat_getbif(struct acpibat_softc *sc) struct aml_value res; int rv = EINVAL; - memset(&sc->sc_bif, 0, sizeof(sc->sc_bif)); - if (!sc->sc_bat_present) - return 0; + if (!sc->sc_bat_present) { + memset(&sc->sc_bif, 0, sizeof(sc->sc_bif)); + return (0); + } if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_BIF", 0, NULL, &res)) { dnprintf(10, "%s: no _BIF\n", DEVNAME(sc)); @@ -355,9 +356,10 @@ acpibat_getbst(struct acpibat_softc *sc) struct aml_value res; int rv = EINVAL; - memset(&sc->sc_bst, 0, sizeof(sc->sc_bst)); - if (!sc->sc_bat_present) - return 0; + if (!sc->sc_bat_present) { + memset(&sc->sc_bst, 0, sizeof(sc->sc_bst)); + return (0); + } if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_BST", 0, NULL, &res)) { dnprintf(10, "%s: no _BST\n", DEVNAME(sc)); @@ -400,7 +402,8 @@ int acpibat_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibat_softc *sc = arg; - struct aml_value res; + struct aml_value res; + int present dnprintf(10, "acpibat_notify: %.2x %s\n", notify_type, sc->sc_devnode->name); @@ -408,8 +411,7 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg) /* Check if installed state of battery has changed */ memset(&res, 0, sizeof(res)); if (aml_evalname(sc->sc_acpi, node, "_STA", 0, NULL, &res) == 0) { - int present = (res.v_integer & STA_BATTERY); - + present = res.v_integer & STA_BATTERY; if (!sc->sc_bat_present && present) { printf("%s: %s inserted\n", DEVNAME(sc), sc->sc_devnode->name); |