diff options
-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 58b4517ce712..d7a786d5c4a5 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> |
@@ -85,6 +86,10 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
85 | 86 | ||
86 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 87 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
87 | 88 | ||
89 | /* For buggy DSDTs that report negative 16-bit values for either charging | ||
90 | * or discharging current and/or report 0 as 65536 due to bad math. | ||
91 | */ | ||
92 | #define QUIRK_SIGNED16_CURRENT 0x0001 | ||
88 | 93 | ||
89 | struct acpi_battery { | 94 | struct acpi_battery { |
90 | struct mutex lock; | 95 | struct mutex lock; |
@@ -112,6 +117,7 @@ struct acpi_battery { | |||
112 | int state; | 117 | int state; |
113 | int power_unit; | 118 | int power_unit; |
114 | u8 alarm_present; | 119 | u8 alarm_present; |
120 | long quirks; | ||
115 | }; | 121 | }; |
116 | 122 | ||
117 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 123 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -390,6 +396,11 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
390 | state_offsets, ARRAY_SIZE(state_offsets)); | 396 | state_offsets, ARRAY_SIZE(state_offsets)); |
391 | battery->update_time = jiffies; | 397 | battery->update_time = jiffies; |
392 | kfree(buffer.pointer); | 398 | kfree(buffer.pointer); |
399 | |||
400 | if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && | ||
401 | battery->rate_now != -1) | ||
402 | battery->rate_now = abs((s16)battery->rate_now); | ||
403 | |||
393 | return result; | 404 | return result; |
394 | } | 405 | } |
395 | 406 | ||
@@ -495,6 +506,14 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
495 | } | 506 | } |
496 | #endif | 507 | #endif |
497 | 508 | ||
509 | static void acpi_battery_quirks(struct acpi_battery *battery) | ||
510 | { | ||
511 | battery->quirks = 0; | ||
512 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { | ||
513 | battery->quirks |= QUIRK_SIGNED16_CURRENT; | ||
514 | } | ||
515 | } | ||
516 | |||
498 | static int acpi_battery_update(struct acpi_battery *battery) | 517 | static int acpi_battery_update(struct acpi_battery *battery) |
499 | { | 518 | { |
500 | int result, old_present = acpi_battery_present(battery); | 519 | int result, old_present = acpi_battery_present(battery); |
@@ -513,6 +532,7 @@ static int acpi_battery_update(struct acpi_battery *battery) | |||
513 | result = acpi_battery_get_info(battery); | 532 | result = acpi_battery_get_info(battery); |
514 | if (result) | 533 | if (result) |
515 | return result; | 534 | return result; |
535 | acpi_battery_quirks(battery); | ||
516 | acpi_battery_init_alarm(battery); | 536 | acpi_battery_init_alarm(battery); |
517 | } | 537 | } |
518 | #ifdef CONFIG_ACPI_SYSFS_POWER | 538 | #ifdef CONFIG_ACPI_SYSFS_POWER |