Skip to contentSkip to conversation

acpi/battery: capacity_now should be assigned after comparing it to design_capacity.

PATCH New Mariusz Ceier 1 participant 1 message Aug 9, 2014 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi/battery: capacity_now should be assigned after comparing it to design_capacity.

From: Mariusz Ceier <[email protected]>

Otherwise warning is printed even when capacity_now before assignment is equal to design_capacity, making the check useless and "current charge level" wrong (it should be higher than, not equal to, "maximum charge level", which is full_charge_capacity):

"battery: reported current charge level (56410) is higher than reported maximum charge level (56410)."

---
 drivers/acpi/battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/battery.c +1 -1
index 48bcf38..1c162e7 100644
@@ -540,12 +540,12 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
 	 */
 	if (battery->capacity_now > battery->full_charge_capacity
 	    && battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) {
-		battery->capacity_now = battery->full_charge_capacity;
 		if (battery->capacity_now != battery->design_capacity)
 			printk_once(KERN_WARNING FW_BUG
 				"battery: reported current charge level (%d) "
 				"is higher than reported maximum charge level (%d).\n",
 				battery->capacity_now, battery->full_charge_capacity);
+		battery->capacity_now = battery->full_charge_capacity;
 	}
 
 	if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
Signature · 1 line
2.0.4