Module Name: src
Committed By: pgoyette
Date: Wed Mar 24 01:45:38 UTC 2010
Modified Files:
src/sys/dev/acpi: acpi_apm.c
Log Message:
Only set the APM_BATT_FLAG_NO_SYSTEM_BATTERY if _all_ batteries are
not_present.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/acpi/acpi_apm.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_apm.c
diff -u src/sys/dev/acpi/acpi_apm.c:1.15 src/sys/dev/acpi/acpi_apm.c:1.16
--- src/sys/dev/acpi/acpi_apm.c:1.15 Fri Mar 5 14:00:16 2010
+++ src/sys/dev/acpi/acpi_apm.c Wed Mar 24 01:45:37 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_apm.c,v 1.15 2010/03/05 14:00:16 jruoho Exp $ */
+/* $NetBSD: acpi_apm.c,v 1.16 2010/03/24 01:45:37 pgoyette Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.15 2010/03/05 14:00:16 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.16 2010/03/24 01:45:37 pgoyette Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -262,7 +262,7 @@
APM_BATT_FLAG_LOW | \
APM_BATT_FLAG_HIGH)
int i, curcap, lowcap, warncap, cap, descap, lastcap, discharge;
- int cap_valid, lastcap_valid, discharge_valid;
+ int cap_valid, lastcap_valid, discharge_valid, present;
envsys_tre_data_t etds;
envsys_basic_info_t ebis;
@@ -271,7 +271,7 @@
/* Prepare to aggregate these two variables over all batteries. */
cap = lastcap = discharge = 0;
- cap_valid = lastcap_valid = discharge_valid = 0;
+ cap_valid = lastcap_valid = discharge_valid = present = 0;
(void)memset(pinfo, 0, sizeof(*pinfo));
pinfo->ac_state = APM_AC_UNKNOWN;
@@ -307,8 +307,8 @@
continue;
if (strstr(desc, " connected")) {
pinfo->ac_state = data ? APM_AC_ON : APM_AC_OFF;
- } else if (strstr(desc, " present") && data == 0)
- pinfo->battery_flags |= APM_BATT_FLAG_NO_SYSTEM_BATTERY;
+ } else if (strstr(desc, " present") && data != 0)
+ present++;
else if (strstr(desc, " charging") && data)
pinfo->battery_flags |= APM_BATT_FLAG_CHARGING;
else if (strstr(desc, " charging") && !data)
@@ -337,6 +337,9 @@
}
sysmonclose_envsys(0, 0, 0, &lwp0);
+ if (present == 0)
+ pinfo->battery_flags |= APM_BATT_FLAG_NO_SYSTEM_BATTERY;
+
if (cap_valid > 0) {
if (warncap != -1 && cap < warncap)
pinfo->battery_flags |= APM_BATT_FLAG_CRITICAL;