Apply patch by Alexander von Gluck. Fix #6951.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39731 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2010-12-05 00:41:53 +00:00
parent b0a8d13338
commit b8891e5123

View File

@ -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;