diff options
Diffstat (limited to 'drivers/acpi/battery.c')
| -rw-r--r-- | drivers/acpi/battery.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 3bcb5bfc45d3..b0de6312919a 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| 31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
| 32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
| 33 | #include <linux/async.h> | ||
| 33 | 34 | ||
| 34 | #ifdef CONFIG_ACPI_PROCFS_POWER | 35 | #ifdef CONFIG_ACPI_PROCFS_POWER |
| 35 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
| @@ -92,7 +93,7 @@ struct acpi_battery { | |||
| 92 | #endif | 93 | #endif |
| 93 | struct acpi_device *device; | 94 | struct acpi_device *device; |
| 94 | unsigned long update_time; | 95 | unsigned long update_time; |
| 95 | int current_now; | 96 | int rate_now; |
| 96 | int capacity_now; | 97 | int capacity_now; |
| 97 | int voltage_now; | 98 | int voltage_now; |
| 98 | int design_capacity; | 99 | int design_capacity; |
| @@ -196,7 +197,8 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
| 196 | val->intval = battery->voltage_now * 1000; | 197 | val->intval = battery->voltage_now * 1000; |
| 197 | break; | 198 | break; |
| 198 | case POWER_SUPPLY_PROP_CURRENT_NOW: | 199 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
| 199 | val->intval = battery->current_now * 1000; | 200 | case POWER_SUPPLY_PROP_POWER_NOW: |
| 201 | val->intval = battery->rate_now * 1000; | ||
| 200 | break; | 202 | break; |
| 201 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | 203 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: |
| 202 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: | 204 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: |
| @@ -247,6 +249,7 @@ static enum power_supply_property energy_battery_props[] = { | |||
| 247 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 249 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
| 248 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 250 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
| 249 | POWER_SUPPLY_PROP_CURRENT_NOW, | 251 | POWER_SUPPLY_PROP_CURRENT_NOW, |
| 252 | POWER_SUPPLY_PROP_POWER_NOW, | ||
| 250 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, | 253 | POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, |
| 251 | POWER_SUPPLY_PROP_ENERGY_FULL, | 254 | POWER_SUPPLY_PROP_ENERGY_FULL, |
| 252 | POWER_SUPPLY_PROP_ENERGY_NOW, | 255 | POWER_SUPPLY_PROP_ENERGY_NOW, |
| @@ -273,7 +276,7 @@ struct acpi_offsets { | |||
| 273 | 276 | ||
| 274 | static struct acpi_offsets state_offsets[] = { | 277 | static struct acpi_offsets state_offsets[] = { |
| 275 | {offsetof(struct acpi_battery, state), 0}, | 278 | {offsetof(struct acpi_battery, state), 0}, |
| 276 | {offsetof(struct acpi_battery, current_now), 0}, | 279 | {offsetof(struct acpi_battery, rate_now), 0}, |
| 277 | {offsetof(struct acpi_battery, capacity_now), 0}, | 280 | {offsetof(struct acpi_battery, capacity_now), 0}, |
| 278 | {offsetof(struct acpi_battery, voltage_now), 0}, | 281 | {offsetof(struct acpi_battery, voltage_now), 0}, |
| 279 | }; | 282 | }; |
| @@ -605,11 +608,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result) | |||
| 605 | else | 608 | else |
| 606 | seq_printf(seq, "charging state: charged\n"); | 609 | seq_printf(seq, "charging state: charged\n"); |
| 607 | 610 | ||
| 608 | if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN) | 611 | if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) |
| 609 | seq_printf(seq, "present rate: unknown\n"); | 612 | seq_printf(seq, "present rate: unknown\n"); |
| 610 | else | 613 | else |
| 611 | seq_printf(seq, "present rate: %d %s\n", | 614 | seq_printf(seq, "present rate: %d %s\n", |
| 612 | battery->current_now, acpi_battery_units(battery)); | 615 | battery->rate_now, acpi_battery_units(battery)); |
| 613 | 616 | ||
| 614 | if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) | 617 | if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN) |
| 615 | seq_printf(seq, "remaining capacity: unknown\n"); | 618 | seq_printf(seq, "remaining capacity: unknown\n"); |
| @@ -740,7 +743,7 @@ DECLARE_FILE_FUNCTIONS(alarm); | |||
| 740 | static struct battery_file { | 743 | static struct battery_file { |
| 741 | struct file_operations ops; | 744 | struct file_operations ops; |
| 742 | mode_t mode; | 745 | mode_t mode; |
| 743 | char *name; | 746 | const char *name; |
| 744 | } acpi_battery_file[] = { | 747 | } acpi_battery_file[] = { |
| 745 | FILE_DESCRIPTION_RO(info), | 748 | FILE_DESCRIPTION_RO(info), |
| 746 | FILE_DESCRIPTION_RO(state), | 749 | FILE_DESCRIPTION_RO(state), |
| @@ -900,21 +903,27 @@ static struct acpi_driver acpi_battery_driver = { | |||
| 900 | }, | 903 | }, |
| 901 | }; | 904 | }; |
| 902 | 905 | ||
| 903 | static int __init acpi_battery_init(void) | 906 | static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) |
| 904 | { | 907 | { |
| 905 | if (acpi_disabled) | 908 | if (acpi_disabled) |
| 906 | return -ENODEV; | 909 | return; |
| 907 | #ifdef CONFIG_ACPI_PROCFS_POWER | 910 | #ifdef CONFIG_ACPI_PROCFS_POWER |
| 908 | acpi_battery_dir = acpi_lock_battery_dir(); | 911 | acpi_battery_dir = acpi_lock_battery_dir(); |
| 909 | if (!acpi_battery_dir) | 912 | if (!acpi_battery_dir) |
| 910 | return -ENODEV; | 913 | return; |
| 911 | #endif | 914 | #endif |
| 912 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { | 915 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { |
| 913 | #ifdef CONFIG_ACPI_PROCFS_POWER | 916 | #ifdef CONFIG_ACPI_PROCFS_POWER |
| 914 | acpi_unlock_battery_dir(acpi_battery_dir); | 917 | acpi_unlock_battery_dir(acpi_battery_dir); |
| 915 | #endif | 918 | #endif |
| 916 | return -ENODEV; | 919 | return; |
| 917 | } | 920 | } |
| 921 | return; | ||
| 922 | } | ||
| 923 | |||
| 924 | static int __init acpi_battery_init(void) | ||
| 925 | { | ||
| 926 | async_schedule(acpi_battery_init_async, NULL); | ||
| 918 | return 0; | 927 | return 0; |
| 919 | } | 928 | } |
| 920 | 929 | ||
