Module Name:    src
Committed By:   drochner
Date:           Wed Jan 27 22:17:28 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi_bat.c

Log Message:
the "Battery Present Rate" is only required to be valid if the battery
is discharging; it might make sense when charging, but it doesn't
make sense if neither is the case -- remove a wrong assertion and
arrange the code to make this obvious
(actually, the ACPI spec says that the requirement is only for
rechargeable batteries)


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/acpi/acpi_bat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_bat.c
diff -u src/sys/dev/acpi/acpi_bat.c:1.78 src/sys/dev/acpi/acpi_bat.c:1.79
--- src/sys/dev/acpi/acpi_bat.c:1.78	Sun Jan 24 11:32:13 2010
+++ src/sys/dev/acpi/acpi_bat.c	Wed Jan 27 22:17:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_bat.c,v 1.78 2010/01/24 11:32:13 jruoho Exp $	*/
+/*	$NetBSD: acpi_bat.c,v 1.79 2010/01/27 22:17:28 drochner Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.78 2010/01/24 11:32:13 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.79 2010/01/27 22:17:28 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -462,20 +462,20 @@
 			rv = AE_TYPE;
 			goto out;
 		}
-
-		KDASSERT((uint64_t)elm[i].Integer.Value < INT_MAX);
 	}
 
-	rate = elm[ACPIBAT_BST_RATE].Integer.Value;
 	state = elm[ACPIBAT_BST_STATE].Integer.Value;
 
 	if ((state & ACPIBAT_ST_CHARGING) != 0) {
+		/* XXX rate can be invalid */
+		rate = elm[ACPIBAT_BST_RATE].Integer.Value;
 		sc->sc_sensor[ACPIBAT_CHARGERATE].state = ENVSYS_SVALID;
 		sc->sc_sensor[ACPIBAT_CHARGERATE].value_cur = rate * 1000;
 		sc->sc_sensor[ACPIBAT_DISCHARGERATE].state = ENVSYS_SINVALID;
 		sc->sc_sensor[ACPIBAT_CHARGING].state = ENVSYS_SVALID;
 		sc->sc_sensor[ACPIBAT_CHARGING].value_cur = 1;
 	} else if ((state & ACPIBAT_ST_DISCHARGING) != 0) {
+		rate = elm[ACPIBAT_BST_RATE].Integer.Value;
 		sc->sc_sensor[ACPIBAT_DISCHARGERATE].state = ENVSYS_SVALID;
 		sc->sc_sensor[ACPIBAT_DISCHARGERATE].value_cur = rate * 1000;
 		sc->sc_sensor[ACPIBAT_CHARGERATE].state = ENVSYS_SINVALID;

Reply via email to