Skip to content

Commit 97efecf

Browse files
committed
thermal: ACPI: Initialize trips if temperature is out of range
In some cases it is still useful to register a trip point if the temperature returned by the corresponding ACPI thermal object (for example, _HOT) is invalid to start with, because the same ACPI thermal object may start to return a valid temperature after a system configuration change (for example, from an AC power source to battery an vice versa). For this reason, if the ACPI thermal object evaluated by thermal_acpi_trip_init() successfully returns a temperature value that is out of the range of values taken into account, initialize the trip point using THERMAL_TEMP_INVALID as the temperature value instead of returning an error to allow the user of the trip point to decide what to do with it. Also update pch_wpt_add_acpi_psv_trip() to reject trip points with invalid temperature values. Fixes: 7a0e397 ("thermal: ACPI: Add ACPI trip point routines") Reported-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a5c926a commit 97efecf

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/thermal/intel/intel_pch_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
107107
return;
108108

109109
ret = thermal_acpi_trip_passive(adev, &ptd->trips[*nr_trips]);
110-
if (ret)
110+
if (ret || ptd->trips[*nr_trips].temperature <= 0)
111111
return;
112112

113113
++(*nr_trips);

drivers/thermal/thermal_acpi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ static int thermal_acpi_trip_init(struct acpi_device *adev,
6464
return -ENODATA;
6565
}
6666

67-
if (temp < TEMP_MIN_DECIK || temp >= TEMP_MAX_DECIK) {
67+
if (temp >= TEMP_MIN_DECIK && temp <= TEMP_MAX_DECIK) {
68+
trip->temperature = deci_kelvin_to_millicelsius(temp);
69+
} else {
6870
acpi_handle_debug(adev->handle, "%s result %llu out of range\n",
6971
obj_name, temp);
70-
return -ENODATA;
72+
trip->temperature = THERMAL_TEMP_INVALID;
7173
}
7274

73-
trip->temperature = deci_kelvin_to_millicelsius(temp);
7475
trip->hysteresis = 0;
7576
trip->type = type;
7677

0 commit comments

Comments
 (0)