[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230124135024.366486-3-daniel.lezcano@linaro.org>
Date: Tue, 24 Jan 2023 14:50:23 +0100
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: daniel.lezcano@...aro.org, rafael@...nel.org
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
NXP Linux Team <linux-imx@....com>,
linux-arm-kernel@...ts.infradead.org (moderated list:ARM/FREESCALE IMX
/ MXC ARM ARCHITECTURE)
Subject: [PATCH 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check
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@...aro.org>
---
drivers/thermal/imx_thermal.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
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);
--
2.34.1
Powered by blists - more mailing lists