aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sbs.c
diff options
context:
space:
mode:
authorAlexey Starikovskiy <astarikovskiy@suse.de>2009-03-27 22:23:52 -0400
committerLen Brown <len.brown@intel.com>2009-03-27 22:23:52 -0400
commit7faa144a518c456e2057918f030f50100144ccc6 (patch)
tree4f1a9406419ba486386b460164e3afb270a0beb5 /drivers/acpi/sbs.c
parent8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff)
ACPI: battery: add power_{now,avg} properties to power_class
ACPI has smart batteries, which work in units of energy and measure rate of (dis)charge as power, thus it is not appropriate to export it as a current_now. Current_now will still be exported to allow for userland applications to match. Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sbs.c')
-rw-r--r--drivers/acpi/sbs.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 6050ce481873..3963cb6e0f19 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -102,8 +102,8 @@ struct acpi_battery {
102 u16 cycle_count; 102 u16 cycle_count;
103 u16 temp_now; 103 u16 temp_now;
104 u16 voltage_now; 104 u16 voltage_now;
105 s16 current_now; 105 s16 rate_now;
106 s16 current_avg; 106 s16 rate_avg;
107 u16 capacity_now; 107 u16 capacity_now;
108 u16 state_of_charge; 108 u16 state_of_charge;
109 u16 state; 109 u16 state;
@@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
202 return -ENODEV; 202 return -ENODEV;
203 switch (psp) { 203 switch (psp) {
204 case POWER_SUPPLY_PROP_STATUS: 204 case POWER_SUPPLY_PROP_STATUS:
205 if (battery->current_now < 0) 205 if (battery->rate_now < 0)
206 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; 206 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
207 else if (battery->current_now > 0) 207 else if (battery->rate_now > 0)
208 val->intval = POWER_SUPPLY_STATUS_CHARGING; 208 val->intval = POWER_SUPPLY_STATUS_CHARGING;
209 else 209 else
210 val->intval = POWER_SUPPLY_STATUS_FULL; 210 val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
224 acpi_battery_vscale(battery) * 1000; 224 acpi_battery_vscale(battery) * 1000;
225 break; 225 break;
226 case POWER_SUPPLY_PROP_CURRENT_NOW: 226 case POWER_SUPPLY_PROP_CURRENT_NOW:
227 val->intval = abs(battery->current_now) * 227 case POWER_SUPPLY_PROP_POWER_NOW:
228 val->intval = abs(battery->rate_now) *
228 acpi_battery_ipscale(battery) * 1000; 229 acpi_battery_ipscale(battery) * 1000;
229 break; 230 break;
230 case POWER_SUPPLY_PROP_CURRENT_AVG: 231 case POWER_SUPPLY_PROP_CURRENT_AVG:
231 val->intval = abs(battery->current_avg) * 232 case POWER_SUPPLY_PROP_POWER_AVG:
233 val->intval = abs(battery->rate_avg) *
232 acpi_battery_ipscale(battery) * 1000; 234 acpi_battery_ipscale(battery) * 1000;
233 break; 235 break;
234 case POWER_SUPPLY_PROP_CAPACITY: 236 case POWER_SUPPLY_PROP_CAPACITY:
@@ -293,6 +295,8 @@ static enum power_supply_property sbs_energy_battery_props[] = {
293 POWER_SUPPLY_PROP_VOLTAGE_NOW, 295 POWER_SUPPLY_PROP_VOLTAGE_NOW,
294 POWER_SUPPLY_PROP_CURRENT_NOW, 296 POWER_SUPPLY_PROP_CURRENT_NOW,
295 POWER_SUPPLY_PROP_CURRENT_AVG, 297 POWER_SUPPLY_PROP_CURRENT_AVG,
298 POWER_SUPPLY_PROP_POWER_NOW,
299 POWER_SUPPLY_PROP_POWER_AVG,
296 POWER_SUPPLY_PROP_CAPACITY, 300 POWER_SUPPLY_PROP_CAPACITY,
297 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 301 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
298 POWER_SUPPLY_PROP_ENERGY_FULL, 302 POWER_SUPPLY_PROP_ENERGY_FULL,
@@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {
301 POWER_SUPPLY_PROP_MODEL_NAME, 305 POWER_SUPPLY_PROP_MODEL_NAME,
302 POWER_SUPPLY_PROP_MANUFACTURER, 306 POWER_SUPPLY_PROP_MANUFACTURER,
303}; 307};
308
304#endif 309#endif
305 310
306/* -------------------------------------------------------------------------- 311/* --------------------------------------------------------------------------
@@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {
330static struct acpi_battery_reader state_readers[] = { 335static struct acpi_battery_reader state_readers[] = {
331 {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)}, 336 {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
332 {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)}, 337 {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
333 {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)}, 338 {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
334 {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)}, 339 {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
335 {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)}, 340 {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
336 {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)}, 341 {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
337 {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)}, 342 {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
@@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
589 seq_printf(seq, "capacity state: %s\n", 594 seq_printf(seq, "capacity state: %s\n",
590 (battery->state & 0x0010) ? "critical" : "ok"); 595 (battery->state & 0x0010) ? "critical" : "ok");
591 seq_printf(seq, "charging state: %s\n", 596 seq_printf(seq, "charging state: %s\n",
592 (battery->current_now < 0) ? "discharging" : 597 (battery->rate_now < 0) ? "discharging" :
593 ((battery->current_now > 0) ? "charging" : "charged")); 598 ((battery->rate_now > 0) ? "charging" : "charged"));
594 rate = abs(battery->current_now) * acpi_battery_ipscale(battery); 599 rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
595 rate *= (acpi_battery_mode(battery))?(battery->voltage_now * 600 rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
596 acpi_battery_vscale(battery)/1000):1; 601 acpi_battery_vscale(battery)/1000):1;
597 seq_printf(seq, "present rate: %d%s\n", rate, 602 seq_printf(seq, "present rate: %d%s\n", rate,