All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-arm-kernel@lists.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
Date: Tue, 24 Jan 2023 14:50:23 +0100	[thread overview]
Message-ID: <20230124135024.366486-3-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20230124135024.366486-1-daniel.lezcano@linaro.org>

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 --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


WARNING: multiple messages have this Message-ID (diff)
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-arm-kernel@lists.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
Date: Tue, 24 Jan 2023 14:50:23 +0100	[thread overview]
Message-ID: <20230124135024.366486-3-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20230124135024.366486-1-daniel.lezcano@linaro.org>

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 --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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-01-24 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 13:50 [PATCH 1/3] thermal/drivers/imx: Remove get_trip_temp ops Daniel Lezcano
2023-01-24 13:50 ` Daniel Lezcano
2023-01-24 13:50 ` [PATCH 2/3] thermal/drivers/imx: Use the thermal framework for the trip point Daniel Lezcano
2023-01-24 13:50   ` Daniel Lezcano
2023-01-24 13:50 ` Daniel Lezcano [this message]
2023-01-24 13:50   ` [PATCH 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230124135024.366486-3-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=amitk@kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.