All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] thermal/drivers/imx: Remove get_trip_temp ops
@ 2023-01-24 13:50 ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

The i.MX thermal sensor uses the generic trip points. The thermal
framework can return the critical temperature directly.

Remove the pointless get_trip_temp ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/imx_thermal.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index fb0d5cab70af..0d94d4baea33 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -332,13 +332,6 @@ static int imx_change_mode(struct thermal_zone_device *tz,
 	return 0;
 }
 
-static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
-{
-	*temp = trips[IMX_TRIP_CRITICAL].temperature;
-
-	return 0;
-}
-
 static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
 			     int temp)
 {
@@ -406,7 +399,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
 	.unbind = imx_unbind,
 	.get_temp = imx_get_temp,
 	.change_mode = imx_change_mode,
-	.get_crit_temp = imx_get_crit_temp,
 	.set_trip_temp = imx_set_trip_temp,
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/3] thermal/drivers/imx: Remove get_trip_temp ops
@ 2023-01-24 13:50 ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

The i.MX thermal sensor uses the generic trip points. The thermal
framework can return the critical temperature directly.

Remove the pointless get_trip_temp ops.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/imx_thermal.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index fb0d5cab70af..0d94d4baea33 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -332,13 +332,6 @@ static int imx_change_mode(struct thermal_zone_device *tz,
 	return 0;
 }
 
-static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
-{
-	*temp = trips[IMX_TRIP_CRITICAL].temperature;
-
-	return 0;
-}
-
 static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
 			     int temp)
 {
@@ -406,7 +399,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
 	.unbind = imx_unbind,
 	.get_temp = imx_get_temp,
 	.change_mode = imx_change_mode,
-	.get_crit_temp = imx_get_crit_temp,
 	.set_trip_temp = imx_set_trip_temp,
 };
 
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] thermal/drivers/imx: Use the thermal framework for the trip point
  2023-01-24 13:50 ` Daniel Lezcano
@ 2023-01-24 13:50   ` Daniel Lezcano
  -1 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

The thermal framework provides an API to get the trip related to a
trip point id. We want to consolidate the generic trip points code,
thus preventing the different drivers to deal with the trip points
after they registered them.

The set_trip_temp ops will be changed regarding the above changes but
first we need to rework a bit the different implementation in the
drivers.

The goal is to prevent using the trip id but use a trip point passed
as parameter which will contain all the needed information.

As we don't have the trip point passed as parameter yet, we get the
trip point using the generic trip thermal framewrok APIs and use it to
take exactly the same decisions.

The difference with this change and the previous code is from where we
get the thermal trip point (which is the same).

No functional change intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/imx_thermal.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 0d94d4baea33..c115a696e83f 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -332,26 +332,29 @@ static int imx_change_mode(struct thermal_zone_device *tz,
 	return 0;
 }
 
-static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
+static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
 			     int temp)
 {
 	struct imx_thermal_data *data = tz->devdata;
+	struct thermal_trip trip;
 	int ret;
 
 	ret = pm_runtime_resume_and_get(data->dev);
 	if (ret < 0)
 		return ret;
 
+	ret = __thermal_zone_get_trip(tz, trip_id, &trip);
+	if (ret)
+		return ret;
+
 	/* do not allow changing critical threshold */
-	if (trip == IMX_TRIP_CRITICAL)
+	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)
 		return -EINVAL;
 
-	trips[IMX_TRIP_PASSIVE].temperature = temp;
-
 	imx_set_alarm_temp(data, temp);
 
 	pm_runtime_put(data->dev);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] thermal/drivers/imx: Use the thermal framework for the trip point
@ 2023-01-24 13:50   ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

The thermal framework provides an API to get the trip related to a
trip point id. We want to consolidate the generic trip points code,
thus preventing the different drivers to deal with the trip points
after they registered them.

The set_trip_temp ops will be changed regarding the above changes but
first we need to rework a bit the different implementation in the
drivers.

The goal is to prevent using the trip id but use a trip point passed
as parameter which will contain all the needed information.

As we don't have the trip point passed as parameter yet, we get the
trip point using the generic trip thermal framewrok APIs and use it to
take exactly the same decisions.

The difference with this change and the previous code is from where we
get the thermal trip point (which is the same).

No functional change intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/imx_thermal.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 0d94d4baea33..c115a696e83f 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -332,26 +332,29 @@ static int imx_change_mode(struct thermal_zone_device *tz,
 	return 0;
 }
 
-static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
+static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
 			     int temp)
 {
 	struct imx_thermal_data *data = tz->devdata;
+	struct thermal_trip trip;
 	int ret;
 
 	ret = pm_runtime_resume_and_get(data->dev);
 	if (ret < 0)
 		return ret;
 
+	ret = __thermal_zone_get_trip(tz, trip_id, &trip);
+	if (ret)
+		return ret;
+
 	/* do not allow changing critical threshold */
-	if (trip == IMX_TRIP_CRITICAL)
+	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)
 		return -EINVAL;
 
-	trips[IMX_TRIP_PASSIVE].temperature = temp;
-
 	imx_set_alarm_temp(data, temp);
 
 	pm_runtime_put(data->dev);
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check
  2023-01-24 13:50 ` Daniel Lezcano
@ 2023-01-24 13:50   ` Daniel Lezcano
  -1 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check
@ 2023-01-24 13:50   ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2023-01-24 13:50 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: linux-pm, linux-kernel, Amit Kucheria, Zhang Rui, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-24 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/3] thermal/drivers/imx: USe get_crit_temp() API instead of manual check Daniel Lezcano
2023-01-24 13:50   ` Daniel Lezcano

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.