Date: Sat Nov 26 13:43:50 2011
New Revision: 227992
Prevent a division by zero with some broken batteries
This problem was seen on a laptop with a dead battery.
--- head/sys/dev/acpica/acpi_battery.c Sat Nov 26 08:23:25 2011 (r227991)
+++ head/sys/dev/acpica/acpi_battery.c Sat Nov 26 13:43:50 2011 (r227992)
@@ -205,6 +205,14 @@ acpi_battery_get_battinfo(device_t dev,
bif->lfcap = (bif->lfcap * bif->dvol) / 1000;
+ * The calculation above may set bif->lfcap to zero. This was
+ * seen on a laptop with a broken battery. The result of the
+ * division was rounded to zero.
+ if (!acpi_battery_bif_valid(bif))
/* Calculate percent capacity remaining. */
bi[i].cap = (100 * bst[i].cap) / bif->lfcap;