aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/battery.c')
-rw-r--r--drivers/acpi/battery.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 611434f413db..ff1ff70da384 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -94,11 +94,6 @@ MODULE_DEVICE_TABLE(acpi, battery_device_ids);
94enum { 94enum {
95 ACPI_BATTERY_ALARM_PRESENT, 95 ACPI_BATTERY_ALARM_PRESENT,
96 ACPI_BATTERY_XINFO_PRESENT, 96 ACPI_BATTERY_XINFO_PRESENT,
97 /* For buggy DSDTs that report negative 16-bit values for either
98 * charging or discharging current and/or report 0 as 65536
99 * due to bad math.
100 */
101 ACPI_BATTERY_QUIRK_SIGNED16_CURRENT,
102 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, 97 ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
103}; 98};
104 99
@@ -465,9 +460,17 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
465 battery->update_time = jiffies; 460 battery->update_time = jiffies;
466 kfree(buffer.pointer); 461 kfree(buffer.pointer);
467 462
468 if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) && 463 /* For buggy DSDTs that report negative 16-bit values for either
469 battery->rate_now != -1) 464 * charging or discharging current and/or report 0 as 65536
465 * due to bad math.
466 */
467 if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA &&
468 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
469 (s16)(battery->rate_now) < 0) {
470 battery->rate_now = abs((s16)battery->rate_now); 470 battery->rate_now = abs((s16)battery->rate_now);
471 printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate"
472 " invalid.\n");
473 }
471 474
472 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) 475 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
473 && battery->capacity_now >= 0 && battery->capacity_now <= 100) 476 && battery->capacity_now >= 0 && battery->capacity_now <= 100)
@@ -577,14 +580,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
577 battery->bat.dev = NULL; 580 battery->bat.dev = NULL;
578} 581}
579 582
580static void acpi_battery_quirks(struct acpi_battery *battery)
581{
582 if (dmi_name_in_vendors("Acer") &&
583 battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) {
584 set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags);
585 }
586}
587
588/* 583/*
589 * According to the ACPI spec, some kinds of primary batteries can 584 * According to the ACPI spec, some kinds of primary batteries can
590 * report percentage battery remaining capacity directly to OS. 585 * report percentage battery remaining capacity directly to OS.
@@ -628,7 +623,6 @@ static int acpi_battery_update(struct acpi_battery *battery)
628 result = acpi_battery_get_info(battery); 623 result = acpi_battery_get_info(battery);
629 if (result) 624 if (result)
630 return result; 625 return result;
631 acpi_battery_quirks(battery);
632 acpi_battery_init_alarm(battery); 626 acpi_battery_init_alarm(battery);
633 } 627 }
634 if (!battery->bat.dev) 628 if (!battery->bat.dev)