Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 19:15:13 +0000 (UTC)
From:      Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r230595 - stable/9/sys/dev/acpica
Message-ID:  <201201261915.q0QJFD5X002158@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201261915.q0QJFD5X002158>