aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorJosef Gajdusek <atx@atx.name>2014-06-17 17:15:49 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-07 17:37:06 -0400
commit232de514379082e7ec431c66c9713a6ef23d5dcb (patch)
treea66ce250f7260efc070edf9ff9512eaf03d44f81 /drivers/acpi
parent75646e758a0ecbed5024454507d5be5b9ea9dcbf (diff)
ACPI / battery: fix wrong value of capacity_now reported when fully charged
It seems that some batteries (noticed on DELL JYPJ136) assume capacity_now = design_capacity when fully charged. This causes reported capacity to suddenly jump to >full_charge_capacity (and that means capacity reported to userspace is >100% and incorrect) values after 99%. This patch detects capacity_now > full_charge_capacity, notifies userspace (unless it is the known bug where capacity_now == design_capacity) and trims the value to full_charge_capacity. Signed-off-by: Josef Gajdusek <atx@atx.name> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/battery.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index bc0b286ff2ba..130f513e08c9 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -535,6 +535,20 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
535 " invalid.\n"); 535 " invalid.\n");
536 } 536 }
537 537
538 /*
539 * When fully charged, some batteries wrongly report
540 * capacity_now = design_capacity instead of = full_charge_capacity
541 */
542 if (battery->capacity_now > battery->full_charge_capacity
543 && battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) {
544 battery->capacity_now = battery->full_charge_capacity;
545 if (battery->capacity_now != battery->design_capacity)
546 printk_once(KERN_WARNING FW_BUG
547 "battery: reported current charge level (%d) "
548 "is higher than reported maximum charge level (%d).\n",
549 battery->capacity_now, battery->full_charge_capacity);
550 }
551
538 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) 552 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
539 && battery->capacity_now >= 0 && battery->capacity_now <= 100) 553 && battery->capacity_now >= 0 && battery->capacity_now <= 100)
540 battery->capacity_now = (battery->capacity_now * 554 battery->capacity_now = (battery->capacity_now *