diff options
author | Len Brown <len.brown@intel.com> | 2009-09-19 01:56:17 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-19 01:56:17 -0400 |
commit | 7a92d803227a523a9a5546e4e0dce1325a4b5926 (patch) | |
tree | fd914dcba7a367939550774d786355352628c3b3 /drivers/acpi/battery.c | |
parent | b4549a24b6194201077d0295207ec204f785fab1 (diff) | |
parent | bc76f90b8a5cf4aceedf210d08d5e8292f820cec (diff) |
Merge branch 'battery' into release
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r-- | drivers/acpi/battery.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index f8c3d1bb6969..3f4602b8f287 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -31,6 +31,7 @@ | |||
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 | #include <linux/async.h> |
34 | #include <linux/dmi.h> | ||
34 | 35 | ||
35 | #ifdef CONFIG_ACPI_PROCFS_POWER | 36 | #ifdef CONFIG_ACPI_PROCFS_POWER |
36 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
@@ -87,6 +88,10 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
87 | 88 | ||
88 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 89 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
89 | 90 | ||
91 | /* For buggy DSDTs that report negative 16-bit values for either charging | ||
92 | * or discharging current and/or report 0 as 65536 due to bad math. | ||
93 | */ | ||
94 | #define QUIRK_SIGNED16_CURRENT 0x0001 | ||
90 | 95 | ||
91 | struct acpi_battery { | 96 | struct acpi_battery { |
92 | struct mutex lock; | 97 | struct mutex lock; |
@@ -114,6 +119,7 @@ struct acpi_battery { | |||
114 | int state; | 119 | int state; |
115 | int power_unit; | 120 | int power_unit; |
116 | u8 alarm_present; | 121 | u8 alarm_present; |
122 | long quirks; | ||
117 | }; | 123 | }; |
118 | 124 | ||
119 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 125 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -392,6 +398,11 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
392 | state_offsets, ARRAY_SIZE(state_offsets)); | 398 | state_offsets, ARRAY_SIZE(state_offsets)); |
393 | battery->update_time = jiffies; | 399 | battery->update_time = jiffies; |
394 | kfree(buffer.pointer); | 400 | kfree(buffer.pointer); |
401 | |||
402 | if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && | ||
403 | battery->rate_now != -1) | ||
404 | battery->rate_now = abs((s16)battery->rate_now); | ||
405 | |||
395 | return result; | 406 | return result; |
396 | } | 407 | } |
397 | 408 | ||
@@ -497,6 +508,14 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
497 | } | 508 | } |
498 | #endif | 509 | #endif |
499 | 510 | ||
511 | static void acpi_battery_quirks(struct acpi_battery *battery) | ||
512 | { | ||
513 | battery->quirks = 0; | ||
514 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { | ||
515 | battery->quirks |= QUIRK_SIGNED16_CURRENT; | ||
516 | } | ||
517 | } | ||
518 | |||
500 | static int acpi_battery_update(struct acpi_battery *battery) | 519 | static int acpi_battery_update(struct acpi_battery *battery) |
501 | { | 520 | { |
502 | int result, old_present = acpi_battery_present(battery); | 521 | int result, old_present = acpi_battery_present(battery); |
@@ -515,6 +534,7 @@ static int acpi_battery_update(struct acpi_battery *battery) | |||
515 | result = acpi_battery_get_info(battery); | 534 | result = acpi_battery_get_info(battery); |
516 | if (result) | 535 | if (result) |
517 | return result; | 536 | return result; |
537 | acpi_battery_quirks(battery); | ||
518 | acpi_battery_init_alarm(battery); | 538 | acpi_battery_init_alarm(battery); |
519 | } | 539 | } |
520 | #ifdef CONFIG_ACPI_SYSFS_POWER | 540 | #ifdef CONFIG_ACPI_SYSFS_POWER |