diff mbox series

[3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check

Message ID 20230124135024.366486-3-daniel.lezcano@linaro.org
State New
Headers show
Series [1/3] thermal/drivers/imx: Remove get_trip_temp ops | expand

Commit Message

Daniel Lezcano Jan. 24, 2023, 1:50 p.m. UTC
The thermal framework is reworked to use a generic trip point
description. That will consolidate the code and will allow to fix a
mishandling of the trip points crossed events.

In order self-encapsulate the thermal framework and prevent assumption
about the indexes we remove the trip id usage in the back end drivers.

As the i.MX driver is using the thermal trip generic structure, we can
rely on the thermal framework to get the critical temperature instead
of using the harcoded IMX_TRIP_CRITICAL index.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/imx_thermal.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index c115a696e83f..10ebf42f4915 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -337,7 +337,7 @@  static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
 {
 	struct imx_thermal_data *data = tz->devdata;
 	struct thermal_trip trip;
-	int ret;
+	int crit_temp, ret;
 
 	ret = pm_runtime_resume_and_get(data->dev);
 	if (ret < 0)
@@ -347,12 +347,16 @@  static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
 	if (ret)
 		return ret;
 
+	if (temp < 0)
+		return -EINVAL;
+
 	/* do not allow changing critical threshold */
 	if (trip.type == THERMAL_TRIP_CRITICAL)
 		return -EPERM;
-	
+
 	/* do not allow passive to be set higher than critical */
-	if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
+	ret = thermal_zone_get_crit_temp(tz, &crit_temp);
+	if (!ret && (crit_temp < temp))
 		return -EINVAL;
 
 	imx_set_alarm_temp(data, temp);