From e1dfedf1ea5eb06a2beb4e8ea4dad499aece627b Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 5 Aug 2008 17:01:06 +0000 Subject: [PATCH] Fix spurious 0 values on batteries seen on laptopts that have an embedded controller. Found, diagnosed and patch from Stefan Sperling Minor KNF changes while here. Tested by many on a variaty of IBM laptops and others with and without acpiec. ok deraadt --- sys/dev/acpi/acpibat.c | 22 ++++++++++++---------- 1 file 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 * @@ -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); -- 2.20.1