diff options
author | njl <njl@FreeBSD.org> | 2007-10-09 07:51:46 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2007-10-09 07:51:46 +0000 |
commit | 8e21b1f738e3a7d52ec50aa5730787013a76a4d5 (patch) | |
tree | 2873564f13ec9f2f3ee34ad2efb29619414159a6 | |
parent | 8232e57ef030a255ea897c975899b89dd23e5b19 (diff) | |
download | FreeBSD-src-8e21b1f738e3a7d52ec50aa5730787013a76a4d5.zip FreeBSD-src-8e21b1f738e3a7d52ec50aa5730787013a76a4d5.tar.gz |
When the EC times out (common with Compaqs), it may report a design
voltage of 0. This can result in a divide by zero trap. Add a guard
for this case. The value of lfcap is checked in acpi_battery_bif_valid()
just before this, so it is safe.
Reportd by: sam
Approved by: re
MFC after: 3 days
-rw-r--r-- | sys/dev/acpica/acpi_battery.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c index a78aff1..cfbae03 100644 --- a/sys/dev/acpica/acpi_battery.c +++ b/sys/dev/acpica/acpi_battery.c @@ -192,9 +192,11 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_battinfo *battinfo) /* * If the battery info is in terms of mA, convert to mW by - * multiplying by the design voltage. + * multiplying by the design voltage. If the design voltage + * is 0 (due to some error reading the battery), skip this + * conversion. */ - if (bif->units == ACPI_BIF_UNITS_MA) { + if (bif->units == ACPI_BIF_UNITS_MA && bif->dvol != 0) { bst[i].rate = (bst[i].rate * bif->dvol) / 1000; bst[i].cap = (bst[i].cap * bif->dvol) / 1000; bif->lfcap = (bif->lfcap * bif->dvol) / 1000; |