patch-2.4.19 linux-2.4.19/drivers/macintosh/apm_emu.c
Next file: linux-2.4.19/drivers/macintosh/mac_hid.c
Previous file: linux-2.4.19/drivers/macintosh/adbhid.c
Back to the patch index
Back to the overall index
- Lines: 45
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/macintosh/apm_emu.c
- Orig date:
Mon Feb 25 11:37:58 2002
diff -urN linux-2.4.18/drivers/macintosh/apm_emu.c linux-2.4.19/drivers/macintosh/apm_emu.c
@@ -436,15 +436,18 @@
int percentage = -1;
int time_units = -1;
int real_count = 0;
+ int charge = -1;
+ int current = 0;
int i;
char * p = buf;
+ char charging = 0;
ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
for (i=0; i<pmu_battery_count; i++) {
if (percentage < 0)
percentage = 0;
- if (time_units < 0)
- time_units = 0;
+ if (charge < 0)
+ charge = 0;
if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
percentage += (pmu_batteries[i].charge * 100) /
pmu_batteries[i].max_charge;
@@ -452,14 +455,19 @@
* time when AC is plugged ? If yes, just remove
* that test --BenH
*/
- if (!ac_line_status)
- time_units += pmu_batteries[i].time_remaining / 60;
+ if (!ac_line_status) {
+ charge += pmu_batteries[i].charge;
+ current += pmu_batteries[i].current;
+ }
real_count++;
- if (!(pmu_batteries[i].flags & PMU_BATT_CHARGING))
- battery_flag &= ~0x08;
+ if ((pmu_batteries[i].flags & PMU_BATT_CHARGING))
+ charging++;
}
}
if (real_count) {
+ time_units = (charge * 59) / (current * -1);
+ if(!charging)
+ battery_flag &= ~0x08;
percentage /= real_count;
if (battery_flag & 0x08) {
battery_status = 0x03;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)