svn commit: r227992 - head/sys/dev/acpica

[ Available lists | Index of svn-src-all | Month of Nov 2011 | Week of 26 Nov 2011 | Raw email | View thread | Wrap long lines | Reply ]
From
Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
Date
26 Nov 2011 13:43:51
Subject
svn commit: r227992 - head/sys/dev/acpica
Message-ID
201111261343.pAQDhp9a093431@svn.freebsd.org


[ Hide this part ]
Author: dumbbell
Date: Sat Nov 26 13:43:50 2011
New Revision: 227992
URL: http://svn.freebsd.org/changeset/base/227992

Log:
Prevent a division by zero with some broken batteries

This problem was seen on a laptop with a dead battery.

Modified:
head/sys/dev/acpica/acpi_battery.c

Modified: head/sys/dev/acpica/acpi_battery.c
==============================================================================
--- 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))
+ continue;
+
/* Calculate percent capacity remaining. */
bi[i].cap = (100 * bst[i].cap) / bif->lfcap;


Elapsed time: 0.129 seconds