[PATCH] Remove use of "current" identifier in via-pmu

Andrew spotted this one, here's the fix:

Remove usage of "current" as a variable name and structure member
in the battery management code of PowerMac via-pmu and apm-emu
drivers
parent e3475ce5
...@@ -440,7 +440,7 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -440,7 +440,7 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
char * p = buf; char * p = buf;
char charging = 0; char charging = 0;
long charge = -1; long charge = -1;
long current = 0; long amperage = 0;
unsigned long btype = 0; unsigned long btype = 0;
ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0); ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
...@@ -453,7 +453,7 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -453,7 +453,7 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
percentage += (pmu_batteries[i].charge * 100) / percentage += (pmu_batteries[i].charge * 100) /
pmu_batteries[i].max_charge; pmu_batteries[i].max_charge;
charge += pmu_batteries[i].charge; charge += pmu_batteries[i].charge;
current += pmu_batteries[i].current; amperage += pmu_batteries[i].amperage;
if (btype == 0) if (btype == 0)
btype = (pmu_batteries[i].flags & PMU_BATT_TYPE_MASK); btype = (pmu_batteries[i].flags & PMU_BATT_TYPE_MASK);
real_count++; real_count++;
...@@ -462,11 +462,11 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -462,11 +462,11 @@ static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
} }
} }
if (real_count) { if (real_count) {
if (current < 0) { if (amperage < 0) {
if (btype == PMU_BATT_TYPE_SMART) if (btype == PMU_BATT_TYPE_SMART)
time_units = (charge * 59) / (current * -1); time_units = (charge * 59) / (amperage * -1);
else else
time_units = (charge * 16440) / (current * -60); time_units = (charge * 16440) / (amperage * -60);
} }
percentage /= real_count; percentage /= real_count;
if (charging > 0) { if (charging > 0) {
......
...@@ -649,7 +649,7 @@ done_battery_state_ohare(struct adb_request* req) ...@@ -649,7 +649,7 @@ done_battery_state_ohare(struct adb_request* req)
unsigned int bat_flags = PMU_BATT_TYPE_HOOPER; unsigned int bat_flags = PMU_BATT_TYPE_HOOPER;
long pcharge, charge, vb, vmax, lmax; long pcharge, charge, vb, vmax, lmax;
long vmax_charging, vmax_charged; long vmax_charging, vmax_charged;
long current, voltage, time, max; long amperage, voltage, time, max;
int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
NULL, PMAC_MB_INFO_MODEL, 0); NULL, PMAC_MB_INFO_MODEL, 0);
...@@ -676,10 +676,10 @@ done_battery_state_ohare(struct adb_request* req) ...@@ -676,10 +676,10 @@ done_battery_state_ohare(struct adb_request* req)
bat_flags |= PMU_BATT_CHARGING; bat_flags |= PMU_BATT_CHARGING;
vb = (req->reply[1] << 8) | req->reply[2]; vb = (req->reply[1] << 8) | req->reply[2];
voltage = (vb * 265 + 72665) / 10; voltage = (vb * 265 + 72665) / 10;
current = req->reply[5]; amperage = req->reply[5];
if ((req->reply[0] & 0x01) == 0) { if ((req->reply[0] & 0x01) == 0) {
if (current > 200) if (amperage > 200)
vb += ((current - 200) * 15)/100; vb += ((amperage - 200) * 15)/100;
} else if (req->reply[0] & 0x02) { } else if (req->reply[0] & 0x02) {
vb = (vb * 97) / 100; vb = (vb * 97) / 100;
vmax = vmax_charging; vmax = vmax_charging;
...@@ -694,19 +694,19 @@ done_battery_state_ohare(struct adb_request* req) ...@@ -694,19 +694,19 @@ done_battery_state_ohare(struct adb_request* req)
if (pcharge < charge) if (pcharge < charge)
charge = pcharge; charge = pcharge;
} }
if (current > 0) if (amperage > 0)
time = (charge * 16440) / current; time = (charge * 16440) / amperage;
else else
time = 0; time = 0;
max = 100; max = 100;
current = -current; amperage = -amperage;
} else } else
charge = max = current = voltage = time = 0; charge = max = amperage = voltage = time = 0;
pmu_batteries[pmu_cur_battery].flags = bat_flags; pmu_batteries[pmu_cur_battery].flags = bat_flags;
pmu_batteries[pmu_cur_battery].charge = charge; pmu_batteries[pmu_cur_battery].charge = charge;
pmu_batteries[pmu_cur_battery].max_charge = max; pmu_batteries[pmu_cur_battery].max_charge = max;
pmu_batteries[pmu_cur_battery].current = current; pmu_batteries[pmu_cur_battery].amperage = amperage;
pmu_batteries[pmu_cur_battery].voltage = voltage; pmu_batteries[pmu_cur_battery].voltage = voltage;
pmu_batteries[pmu_cur_battery].time_remaining = time; pmu_batteries[pmu_cur_battery].time_remaining = time;
} }
...@@ -734,7 +734,7 @@ done_battery_state_smart(struct adb_request* req) ...@@ -734,7 +734,7 @@ done_battery_state_smart(struct adb_request* req)
*/ */
unsigned int bat_flags = PMU_BATT_TYPE_SMART; unsigned int bat_flags = PMU_BATT_TYPE_SMART;
int current; int amperage;
unsigned int capa, max, voltage; unsigned int capa, max, voltage;
if (req->reply[1] & 0x01) if (req->reply[1] & 0x01)
...@@ -749,12 +749,12 @@ done_battery_state_smart(struct adb_request* req) ...@@ -749,12 +749,12 @@ done_battery_state_smart(struct adb_request* req)
case 3: case 3:
case 4: capa = req->reply[2]; case 4: capa = req->reply[2];
max = req->reply[3]; max = req->reply[3];
current = *((signed char *)&req->reply[4]); amperage = *((signed char *)&req->reply[4]);
voltage = req->reply[5]; voltage = req->reply[5];
break; break;
case 5: capa = (req->reply[2] << 8) | req->reply[3]; case 5: capa = (req->reply[2] << 8) | req->reply[3];
max = (req->reply[4] << 8) | req->reply[5]; max = (req->reply[4] << 8) | req->reply[5];
current = *((signed short *)&req->reply[6]); amperage = *((signed short *)&req->reply[6]);
voltage = (req->reply[8] << 8) | req->reply[9]; voltage = (req->reply[8] << 8) | req->reply[9];
break; break;
default: default:
...@@ -763,23 +763,23 @@ done_battery_state_smart(struct adb_request* req) ...@@ -763,23 +763,23 @@ done_battery_state_smart(struct adb_request* req)
break; break;
} }
} else } else
capa = max = current = voltage = 0; capa = max = amperage = voltage = 0;
if ((req->reply[1] & 0x01) && (current > 0)) if ((req->reply[1] & 0x01) && (amperage > 0))
bat_flags |= PMU_BATT_CHARGING; bat_flags |= PMU_BATT_CHARGING;
pmu_batteries[pmu_cur_battery].flags = bat_flags; pmu_batteries[pmu_cur_battery].flags = bat_flags;
pmu_batteries[pmu_cur_battery].charge = capa; pmu_batteries[pmu_cur_battery].charge = capa;
pmu_batteries[pmu_cur_battery].max_charge = max; pmu_batteries[pmu_cur_battery].max_charge = max;
pmu_batteries[pmu_cur_battery].current = current; pmu_batteries[pmu_cur_battery].amperage = amperage;
pmu_batteries[pmu_cur_battery].voltage = voltage; pmu_batteries[pmu_cur_battery].voltage = voltage;
if (current) { if (amperage) {
if ((req->reply[1] & 0x01) && (current > 0)) if ((req->reply[1] & 0x01) && (amperage > 0))
pmu_batteries[pmu_cur_battery].time_remaining pmu_batteries[pmu_cur_battery].time_remaining
= ((max-capa) * 3600) / current; = ((max-capa) * 3600) / amperage;
else else
pmu_batteries[pmu_cur_battery].time_remaining pmu_batteries[pmu_cur_battery].time_remaining
= (capa * 3600) / (-current); = (capa * 3600) / (-amperage);
} else } else
pmu_batteries[pmu_cur_battery].time_remaining = 0; pmu_batteries[pmu_cur_battery].time_remaining = 0;
...@@ -861,7 +861,7 @@ proc_get_batt(char *page, char **start, off_t off, ...@@ -861,7 +861,7 @@ proc_get_batt(char *page, char **start, off_t off,
p += sprintf(p, "max_charge : %d\n", p += sprintf(p, "max_charge : %d\n",
pmu_batteries[batnum].max_charge); pmu_batteries[batnum].max_charge);
p += sprintf(p, "current : %d\n", p += sprintf(p, "current : %d\n",
pmu_batteries[batnum].current); pmu_batteries[batnum].amperage);
p += sprintf(p, "voltage : %d\n", p += sprintf(p, "voltage : %d\n",
pmu_batteries[batnum].voltage); pmu_batteries[batnum].voltage);
p += sprintf(p, "time rem. : %d\n", p += sprintf(p, "time rem. : %d\n",
......
...@@ -226,7 +226,7 @@ struct pmu_battery_info ...@@ -226,7 +226,7 @@ struct pmu_battery_info
unsigned int flags; unsigned int flags;
unsigned int charge; /* current charge */ unsigned int charge; /* current charge */
unsigned int max_charge; /* maximum charge */ unsigned int max_charge; /* maximum charge */
signed int current; /* current, positive if charging */ signed int amperage; /* current, positive if charging */
unsigned int voltage; /* voltage */ unsigned int voltage; /* voltage */
unsigned int time_remaining; /* remaining time */ unsigned int time_remaining; /* remaining time */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment