From 1de9b7e4c9a5db8bfa753a83147a802c2f4f2a05 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Tue, 20 Nov 2007 18:35:36 +0000 Subject: [PATCH] Check battery presence first before trying to get battery information. PR: kern/117591 Tested by: Jessica Mahoney (root at varusonline dot com) --- sys/dev/acpica/acpi_battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_battery.c b/sys/dev/acpica/acpi_battery.c index cfbae03e2f5..f289b2bd64d 100644 --- a/sys/dev/acpica/acpi_battery.c +++ b/sys/dev/acpica/acpi_battery.c @@ -167,11 +167,12 @@ acpi_battery_get_battinfo(device_t dev, struct acpi_battinfo *battinfo) dev_idx = i; /* - * Be sure we can get various info from the battery. Note that we - * can't check acpi_BatteryIsPresent() because smart batteries only + * Be sure we can get various info from the battery. Note that + * acpi_BatteryIsPresent() is not enough because smart batteries only * return that the device is present. */ - if (ACPI_BATT_GET_STATUS(batt_dev, &bst[i]) != 0 || + if (!acpi_BatteryIsPresent(batt_dev) || + ACPI_BATT_GET_STATUS(batt_dev, &bst[i]) != 0 || ACPI_BATT_GET_INFO(batt_dev, bif) != 0) continue;