From b8891e51233c307cf41e72349fa723a4ea3cdefa Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Sun, 5 Dec 2010 00:41:53 +0000 Subject: [PATCH] Apply patch by Alexander von Gluck. Fix #6951. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39731 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/power/acpi_battery/acpi_battery.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.cpp b/src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.cpp index 0968fcbc1e..444d478355 100644 --- a/src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.cpp +++ b/src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.cpp @@ -4,6 +4,7 @@ * * Authors: * Clemens Zeidler, haiku@clemens-zeidler.de + * Alexander von Gluck, kallisti5@unixzen.com */ #include "acpi_battery.h" @@ -59,7 +60,7 @@ ReadBatteryStatus(battery_driver_cookie* cookie, acpi_battery_info* batteryStatu pointer = object->data.package.objects; batteryStatus->state = (pointer->object_type == ACPI_TYPE_INTEGER) - ? pointer->data.integer : -1; + ? pointer->data.integer : BATTERY_CRITICAL_STATE; pointer++; batteryStatus->current_rate = (pointer->object_type == ACPI_TYPE_INTEGER) @@ -73,6 +74,15 @@ ReadBatteryStatus(battery_driver_cookie* cookie, acpi_battery_info* batteryStatu batteryStatus->voltage = (pointer->object_type == ACPI_TYPE_INTEGER) ? pointer->data.integer : -1; + /* If key values are all < 0, it is likely that the battery slot is empty + or the battery is damaged. Set BATTERY_CRITICAL_STATE */ + if (batteryStatus->voltage < 0 + && batteryStatus->current_rate < 0 + && batteryStatus->capacity < 0) { + batteryStatus->state = BATTERY_CRITICAL_STATE; + } + + exit: free(buffer.pointer); return status;