aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sbs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/sbs.c')
-rw-r--r--drivers/acpi/sbs.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 59afd52ccc12..4b214b74ebaa 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)},
@@ -479,9 +484,9 @@ static int
479acpi_sbs_add_fs(struct proc_dir_entry **dir, 484acpi_sbs_add_fs(struct proc_dir_entry **dir,
480 struct proc_dir_entry *parent_dir, 485 struct proc_dir_entry *parent_dir,
481 char *dir_name, 486 char *dir_name,
482 struct file_operations *info_fops, 487 const struct file_operations *info_fops,
483 struct file_operations *state_fops, 488 const struct file_operations *state_fops,
484 struct file_operations *alarm_fops, void *data) 489 const struct file_operations *alarm_fops, void *data)
485{ 490{
486 if (!*dir) { 491 if (!*dir) {
487 *dir = proc_mkdir(dir_name, parent_dir); 492 *dir = proc_mkdir(dir_name, parent_dir);
@@ -588,9 +593,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
588 seq_printf(seq, "capacity state: %s\n", 593 seq_printf(seq, "capacity state: %s\n",
589 (battery->state & 0x0010) ? "critical" : "ok"); 594 (battery->state & 0x0010) ? "critical" : "ok");
590 seq_printf(seq, "charging state: %s\n", 595 seq_printf(seq, "charging state: %s\n",
591 (battery->current_now < 0) ? "discharging" : 596 (battery->rate_now < 0) ? "discharging" :
592 ((battery->current_now > 0) ? "charging" : "charged")); 597 ((battery->rate_now > 0) ? "charging" : "charged"));
593 rate = abs(battery->current_now) * acpi_battery_ipscale(battery); 598 rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
594 rate *= (acpi_battery_mode(battery))?(battery->voltage_now * 599 rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
595 acpi_battery_vscale(battery)/1000):1; 600 acpi_battery_vscale(battery)/1000):1;
596 seq_printf(seq, "present rate: %d%s\n", rate, 601 seq_printf(seq, "present rate: %d%s\n", rate,
@@ -676,7 +681,7 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
676 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); 681 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
677} 682}
678 683
679static struct file_operations acpi_battery_info_fops = { 684static const struct file_operations acpi_battery_info_fops = {
680 .open = acpi_battery_info_open_fs, 685 .open = acpi_battery_info_open_fs,
681 .read = seq_read, 686 .read = seq_read,
682 .llseek = seq_lseek, 687 .llseek = seq_lseek,
@@ -684,7 +689,7 @@ static struct file_operations acpi_battery_info_fops = {
684 .owner = THIS_MODULE, 689 .owner = THIS_MODULE,
685}; 690};
686 691
687static struct file_operations acpi_battery_state_fops = { 692static const struct file_operations acpi_battery_state_fops = {
688 .open = acpi_battery_state_open_fs, 693 .open = acpi_battery_state_open_fs,
689 .read = seq_read, 694 .read = seq_read,
690 .llseek = seq_lseek, 695 .llseek = seq_lseek,
@@ -692,7 +697,7 @@ static struct file_operations acpi_battery_state_fops = {
692 .owner = THIS_MODULE, 697 .owner = THIS_MODULE,
693}; 698};
694 699
695static struct file_operations acpi_battery_alarm_fops = { 700static const struct file_operations acpi_battery_alarm_fops = {
696 .open = acpi_battery_alarm_open_fs, 701 .open = acpi_battery_alarm_open_fs,
697 .read = seq_read, 702 .read = seq_read,
698 .write = acpi_battery_write_alarm, 703 .write = acpi_battery_write_alarm,
@@ -724,7 +729,7 @@ static int acpi_ac_state_open_fs(struct inode *inode, struct file *file)
724 return single_open(file, acpi_ac_read_state, PDE(inode)->data); 729 return single_open(file, acpi_ac_read_state, PDE(inode)->data);
725} 730}
726 731
727static struct file_operations acpi_ac_state_fops = { 732static const struct file_operations acpi_ac_state_fops = {
728 .open = acpi_ac_state_open_fs, 733 .open = acpi_ac_state_open_fs,
729 .read = seq_read, 734 .read = seq_read,
730 .llseek = seq_lseek, 735 .llseek = seq_lseek,