diff options
| author | macallan <macallan@NetBSD.org> | 2012-10-31 05:42:47 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2012-10-31 05:42:47 +0000 |
| commit | cc91eddfb9c1cec57b1dacdc117a2cb30b4f780c (patch) | |
| tree | 343827351187fd5848182d7f0d4ba73ed4ad3533 /sys/dev/sysmon | |
| parent | 22992414d88ab0acc22cbdce483b119a7e9186a4 (diff) | |
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 (limited to 'sys/dev/sysmon')
| -rw-r--r-- | sys/dev/sysmon/sysmon_envsys_events.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys_events.c b/sys/dev/sysmon/sysmon_envsys_events.c index dc440b31cf7..9668442fea0 100644 --- a/sys/dev/sysmon/sysmon_envsys_events.c +++ b/sys/dev/sysmon/sysmon_envsys_events.c @@ -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 @@ sme_acadapter_check(void) sensor = true; /* refresh current sensor */ sysmon_envsys_refresh_sensor(sme, edata); + if (edata->value_cur) return false; } @@ -1061,10 +1062,16 @@ sme_battery_check(void) 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 @@ sme_battery_check(void) 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)) |
