ACPI: battery: do not export degraded capacity values over 100
authorLaszlo Toth <laszlth@gmail.com>
Sat, 24 Feb 2018 09:20:15 +0000 (10:20 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 Feb 2018 16:17:11 +0000 (17:17 +0100)
commita20136a67a995cd5b74e8c0fcb3b2f2e5b2848dd
tree7daabf42ed2d71c9966492595148993b93810998
parent514bcc5dfa69d64f7772cb6442721b9d1b83504d
ACPI: battery: do not export degraded capacity values over 100

With a degraded battery, full_charge_capacity can be less
than design_capacity, however it's not sure that capacity_now's
max will follow.

Example from an affected machine:
/sys/class/power_supply/BAT0/charge_full        -> 4290000
/sys/class/power_supply/BAT0/charge_full_design -> 5900000
/sys/class/power_supply/BAT0/charge_now         -> 5900000
/sys/class/power_supply/BAT0/capacity           -> 137

The battery is a degraded one with a full charge, and
charge_now is the value of charge_full_design instead of
charge_full.

Added a new quirk to test and correct this, and
a new function to check if the battery is a degraded one
or not. This keeps the possibility to be over 100 if
it's really the case.

Signed-off-by: Laszlo Toth <laszlth@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/battery.c