All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi/battery: fix wrong value of capacity_now reported by few battery types when fully charged
@ 2014-06-12 14:32 Josef Gajdusek
  0 siblings, 0 replies; only message in thread
From: Josef Gajdusek @ 2014-06-12 14:32 UTC (permalink / raw)
  To: rjw; +Cc: lenb, linux-acpi, linux-kernel

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 attempts to detect this bug and trims 
capacity_now properly.

---
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e48fc98..3338dd5 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -532,6 +532,14 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
 			" invalid.\n");
 	}
 
+	/* When fully charged, some batteries wrongly report
+	 * capacity_now = design_capacity instead of = full_charge_capacity
+	 */
+	if (battery->capacity_now == battery->design_capacity &&
+	    battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN)
+		battery->capacity_now = battery->full_charge_capacity;
+
+
 	if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
 	    && battery->capacity_now >= 0 && battery->capacity_now <= 100)
 		battery->capacity_now = (battery->capacity_now *

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-12 14:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 14:32 [PATCH] acpi/battery: fix wrong value of capacity_now reported by few battery types when fully charged Josef Gajdusek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.