diff options
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 69cbc57c2d1c..5dfe18bf24cb 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"); |
@@ -901,21 +904,27 @@ static struct acpi_driver acpi_battery_driver = { | |||
901 | }, | 904 | }, |
902 | }; | 905 | }; |
903 | 906 | ||
904 | static int __init acpi_battery_init(void) | 907 | static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) |
905 | { | 908 | { |
906 | if (acpi_disabled) | 909 | if (acpi_disabled) |
907 | return -ENODEV; | 910 | return; |
908 | #ifdef CONFIG_ACPI_PROCFS_POWER | 911 | #ifdef CONFIG_ACPI_PROCFS_POWER |
909 | acpi_battery_dir = acpi_lock_battery_dir(); | 912 | acpi_battery_dir = acpi_lock_battery_dir(); |
910 | if (!acpi_battery_dir) | 913 | if (!acpi_battery_dir) |
911 | return -ENODEV; | 914 | return; |
912 | #endif | 915 | #endif |
913 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { | 916 | if (acpi_bus_register_driver(&acpi_battery_driver) < 0) { |
914 | #ifdef CONFIG_ACPI_PROCFS_POWER | 917 | #ifdef CONFIG_ACPI_PROCFS_POWER |
915 | acpi_unlock_battery_dir(acpi_battery_dir); | 918 | acpi_unlock_battery_dir(acpi_battery_dir); |
916 | #endif | 919 | #endif |
917 | return -ENODEV; | 920 | return; |
918 | } | 921 | } |
922 | return; | ||
923 | } | ||
924 | |||
925 | static int __init acpi_battery_init(void) | ||
926 | { | ||
927 | async_schedule(acpi_battery_init_async, NULL); | ||
919 | return 0; | 928 | return 0; |
920 | } | 929 | } |
921 | 930 | ||