Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sysmon in sme_battery_check():
details: https://anonhg.NetBSD.org/src/rev/3da202a69aa0
branches: trunk
changeset: 782370:3da202a69aa0
user: macallan <macallan%NetBSD.org@localhost>
date: Wed Oct 31 05:42:47 2012 +0000
description:
in sme_battery_check():
- don't assume that all batteries have exactly one ENVSYS_INDICATOR
- check capacity and charge sensors for ENVSYS_SVALID before using them
now this works on macppc
diffstat:
sys/dev/sysmon/sysmon_envsys_events.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r d3e9422d0b6b -r 3da202a69aa0 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Tue Oct 30 23:03:02 2012 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Wed Oct 31 05:42:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.105 2012/09/06 12:21:40 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.106 2012/10/31 05:42:47 macallan Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.105 2012/09/06 12:21:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.106 2012/10/31 05:42:47 macallan Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1027,6 +1027,7 @@
sensor = true;
/* refresh current sensor */
sysmon_envsys_refresh_sensor(sme, edata);
+
if (edata->value_cur)
return false;
}
@@ -1061,10 +1062,16 @@
continue;
present = true;
+
+ /*
+ * XXX
+ * this assumes that the first valid ENVSYS_INDICATOR is the
+ * presence indicator
+ */
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
- if (edata->units == ENVSYS_INDICATOR &&
- !edata->value_cur) {
- present = false;
+ if ((edata->units == ENVSYS_INDICATOR) &&
+ (edata->state == ENVSYS_SVALID)) {
+ present = edata->value_cur;
break;
}
}
@@ -1076,6 +1083,9 @@
batteriesfound++;
batterycap = batterycharge = false;
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
+ /* no need to even look at sensors that aren't valid */
+ if (edata->state != ENVSYS_SVALID)
+ continue;
if (edata->units == ENVSYS_BATTERY_CAPACITY) {
batterycap = true;
if (!sme_battery_critical(edata))
Home |
Main Index |
Thread Index |
Old Index