Author: dumbbell
Date: Thu Jan 26 19:15:13 2012
New Revision: 230595
URL: http://svn.freebsd.org/changeset/base/230595
Log:
MFC r227992:
Prevent a division by zero with some broken batteries
This problem was seen on a laptop with a dead battery.
Modified:
stable/9/sys/dev/acpica/acpi_battery.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/dev/acpica/acpi_battery.c
==============================================================================
--- stable/9/sys/dev/acpica/acpi_battery.c Thu Jan 26 19:11:08 2012
(r230594)
+++ stable/9/sys/dev/acpica/acpi_battery.c Thu Jan 26 19:15:13 2012
(r230595)
@@ -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))
+ continue;
+
/* Calculate percent capacity remaining. */
bi[i].cap = (100 * bst[i].cap) / bif->lfcap;
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"