acpi_thermal: get the driver working

Change-Id: Ib0b7de56ef35092da93cc5fa61bdf0cfef41c042
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3440
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Lt-Henry
2020-12-04 07:29:11 +00:00
committed by Adrien Destugues
parent d99d8dbdd2
commit 3d0f2eea4f
@@ -55,13 +55,13 @@ acpi_thermal_read(void* _cookie, off_t position, void *buf, size_t* num_bytes)
{
acpi_thermal_device_info* device = (acpi_thermal_device_info*)_cookie;
acpi_thermal_type therm_info;
if (*num_bytes < 1)
return B_IO_ERROR;
if (position == 0) {
size_t max_len = *num_bytes;
char *str = (char *)buf;
dprintf("acpi_thermal: read()\n");
acpi_thermal_control(device, drvOpGetThermalType, &therm_info, 0);
snprintf(str, max_len, " Critical Temperature: %lu.%lu K\n",
@@ -120,29 +120,29 @@ acpi_thermal_control(void* _cookie, uint32 op, void* arg, size_t len)
acpi_thermal_type *att = NULL;
uint32 integer;
acpi_object_type object;
acpi_data buffer;
buffer.pointer = &integer;
buffer.length = sizeof(integer);
buffer.pointer = &object;
buffer.length = sizeof(object);
switch (op) {
case drvOpGetThermalType: {
dprintf("acpi_thermal: GetThermalType()\n");
att = (acpi_thermal_type *)arg;
// Read basic temperature thresholds.
err = device->acpi->evaluate_method(device->acpi_cookie, "_CRT", NULL, &buffer);
att->critical_temp = (err == B_OK) ? integer : 0;
att->critical_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0;
err = device->acpi->evaluate_method(device->acpi_cookie, "_TMP", NULL, &buffer);
att->current_temp = (err == B_OK) ? integer : 0;
att->current_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0;
err = device->acpi->evaluate_method(device->acpi_cookie, "_HOT", NULL, &buffer);
att->hot_temp = (err == B_OK) ? integer : 0;
dprintf("acpi_thermal: GotBasicTemperatures()\n");
att->hot_temp = (err == B_OK && object.object_type == ACPI_TYPE_INTEGER) ? object.integer.integer : 0;
// Read Passive Cooling devices
att->passive_package = NULL;
err = device->acpi->get_object(device->acpi_cookie, "_PSL", &(att->passive_package));
//err = device->acpi->get_object(device->acpi_cookie, "_PSL", &(att->passive_package));
att->active_count = 0;
att->active_devices = NULL;
@@ -186,8 +186,8 @@ acpi_thermal_support(device_node *parent)
return 0.0;
// check whether it's really a thermal Device
if (sDeviceManager->get_attr_uint32(parent, ACPI_DEVICE_TYPE_ITEM, &device_type, false) != B_OK
|| device_type != ACPI_TYPE_THERMAL) {
if (sDeviceManager->get_attr_uint32(parent, ACPI_DEVICE_TYPE_ITEM,
&device_type, false) != B_OK || device_type != ACPI_TYPE_THERMAL) {
return 0.0;
}