Aggregate discharge rate over all batteries. Makes time remaining

reasonable when battery 0 is in use and battery 1 is fully discharged.
This commit is contained in:
gdt 2006-10-11 19:14:29 +00:00
parent cf2f8187a8
commit ac02696458

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_apm.c,v 1.5 2006/10/11 19:00:12 gdt Exp $ */
/* $NetBSD: acpi_apm.c,v 1.6 2006/10/11 19:14:29 gdt Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.5 2006/10/11 19:00:12 gdt Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.6 2006/10/11 19:14:29 gdt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -273,16 +273,16 @@ acpiapm_get_powstat(void *opaque, u_int batteryid, struct apm_power_info *pinfo)
APM_BATT_FLAG_LOW | \
APM_BATT_FLAG_HIGH)
int i, curcap, lowcap, warncap, cap, descap, lastcap, discharge;
int cap_valid, lastcap_valid;
int cap_valid, lastcap_valid, discharge_valid;
envsys_tre_data_t etds;
envsys_basic_info_t ebis;
/* Denote most variables as unitialized. */
curcap = lowcap = warncap = descap = discharge = -1;
curcap = lowcap = warncap = descap = -1;
/* Prepare to aggregate these two variables over all batteries. */
cap = lastcap = 0;
cap_valid = lastcap_valid = 0;
cap = lastcap = discharge = 0;
cap_valid = lastcap_valid = discharge_valid = 0;
(void)memset(pinfo, 0, sizeof(*pinfo));
pinfo->ac_state = APM_AC_UNKNOWN;
@ -338,8 +338,10 @@ acpiapm_get_powstat(void *opaque, u_int batteryid, struct apm_power_info *pinfo)
cap_valid = 1;
pinfo->nbattery++;
}
else if (strstr(desc, " discharge rate"))
discharge = data / 1000;
else if (strstr(desc, " discharge rate")) {
discharge += data / 1000;
discharge_valid = 1;
}
}
if (cap_valid > 0) {