Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi handle unknown values. Also BIF_UNIT is an enum...
details: https://anonhg.NetBSD.org/src/rev/c42c42916afc
branches: trunk
changeset: 335269:c42c42916afc
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Wed Dec 31 22:01:01 2014 +0000
description:
handle unknown values. Also BIF_UNIT is an enum, not a bitmask.
diffstat:
sys/dev/acpi/acpi_bat.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diffs (61 lines):
diff -r 57f142bd976d -r c42c42916afc sys/dev/acpi/acpi_bat.c
--- a/sys/dev/acpi/acpi_bat.c Wed Dec 31 21:21:41 2014 +0000
+++ b/sys/dev/acpi/acpi_bat.c Wed Dec 31 22:01:01 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_bat.c,v 1.113 2014/10/02 12:42:12 riastradh Exp $ */
+/* $NetBSD: acpi_bat.c,v 1.114 2014/12/31 22:01:01 mlelstv 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.113 2014/10/02 12:42:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.114 2014/12/31 22:01:01 mlelstv Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -381,18 +381,22 @@
goto out;
}
- if (elm[i].Integer.Value >= INT_MAX) {
+ if (elm[i].Integer.Value != ACPIBAT_VAL_UNKNOWN &&
+ elm[i].Integer.Value >= INT_MAX) {
rv = AE_LIMIT;
goto out;
}
}
- if ((elm[ACPIBAT_BIF_UNIT].Integer.Value & ACPIBAT_PWRUNIT_MA) != 0) {
+ switch (elm[ACPIBAT_BIF_UNIT].Integer.Value) {
+ case ACPIBAT_PWRUNIT_MA:
capunit = ENVSYS_SAMPHOUR;
rateunit = ENVSYS_SAMPS;
- } else {
+ break;
+ default:
capunit = ENVSYS_SWATTHOUR;
rateunit = ENVSYS_SWATTS;
+ break;
}
sc->sc_sensor[ACPIBAT_DCAPACITY].units = capunit;
@@ -500,10 +504,14 @@
* Granularity 2. "Battery capacity granularity between warning
* and full in [mAh] or [mWh]. [...]"
*/
- if ((elm[ACPIBAT_BIF_UNIT].Integer.Value & ACPIBAT_PWRUNIT_MA) != 0)
+ switch (elm[ACPIBAT_BIF_UNIT].Integer.Value) {
+ case ACPIBAT_PWRUNIT_MA:
unit = "Ah";
- else
+ break;
+ default:
unit = "Wh";
+ break;
+ }
aprint_verbose_dev(dv, "granularity: "
"low->warn %d.%03d %s, warn->full %d.%03d %s\n",
Home |
Main Index |
Thread Index |
Old Index