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:
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Clemens Zeidler, [email protected]
|
* Clemens Zeidler, [email protected]
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "acpi_battery.h"
|
#include "acpi_battery.h"
|
||||||
@@ -59,7 +60,7 @@ ReadBatteryStatus(battery_driver_cookie* cookie, acpi_battery_info* batteryStatu
|
|||||||
|
|
||||||
pointer = object->data.package.objects;
|
pointer = object->data.package.objects;
|
||||||
batteryStatus->state = (pointer->object_type == ACPI_TYPE_INTEGER)
|
batteryStatus->state = (pointer->object_type == ACPI_TYPE_INTEGER)
|
||||||
? pointer->data.integer : -1;
|
? pointer->data.integer : BATTERY_CRITICAL_STATE;
|
||||||
|
|
||||||
pointer++;
|
pointer++;
|
||||||
batteryStatus->current_rate = (pointer->object_type == ACPI_TYPE_INTEGER)
|
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)
|
batteryStatus->voltage = (pointer->object_type == ACPI_TYPE_INTEGER)
|
||||||
? pointer->data.integer : -1;
|
? 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:
|
exit:
|
||||||
free(buffer.pointer);
|
free(buffer.pointer);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
Reference in New Issue
Block a user