[3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check
Commit Message
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(-)
@@ -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);