thermal/drivers/armada: Use the thermal_zone_get_crit_temp()
Subsystems (2)
PATCH 1/1 thermal/drivers/armada: Use the thermal_zone_get_crit_temp()
The driver browses the trip point to find out the critical trip temperature. However the function thermal_zone_get_crit_temp() does already that, so the routine is pointless in the driver.
Use thermal_zone_get_crit_temp() instead of inspecting all the trip points.
--- drivers/thermal/armada_thermal.c | 38 +++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
drivers/thermal/armada_thermal.c +15 -23
@@ -784,34 +784,26 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv, int sensor_id) {/* Retrieve the critical trip point to enable the overheat interrupt */ -struct thermal_trip trip; +int temperature;int ret; -int i; - -for (i =0 ; i <thermal_zone_get_num_trips (tz); i++) { - - ret =thermal_zone_get_trip (tz, i, &trip); -if (ret) -return ret; - -if (trip.type !=THERMAL_TRIP_CRITICAL ) -continue ; - - ret =armada_select_channel (priv, sensor_id); -if (ret) -return ret; -armada_set_overheat_thresholds (priv, trip.temperature, - trip.hysteresis); - priv->overheat_sensor = tz; - priv->interrupt_source = sensor_id; + ret =thermal_zone_get_crit_temp (tz, &temperature); +if (ret) +return ret; -armada_enable_overheat_interrupt (priv); + ret =armada_select_channel (priv, sensor_id); +if (ret) +return ret; -return 0 ; - } +/* +* A critical temperature does not have a hysteresis +*/ +armada_set_overheat_thresholds (priv, temperature,0 ); + priv->overheat_sensor = tz; + priv->interrupt_source = sensor_id; +armada_enable_overheat_interrupt (priv); -return -EINVAL ; +return 0 ; }static int armada_thermal_probe (struct platform_device *pdev)
Signature · 1 line
2.34.1
Hi Daniel,
[email protected] wrote on Wed, 18 Jan 2023 23:26:10 +0100:
Quoted 46 lines
The driver browses the trip point to find out the critical trip temperature. However the function
thermal_zone_get_crit_temp()does already that, so the routine is pointless in the driver.Use
thermal_zone_get_crit_temp()instead of inspecting all the trip points.Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/armada_thermal.c | 38 +++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-)drivers/thermal/armada_thermal.c +4
-19@@ -784,34 +784,26 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv, int sensor_id) {/* Retrieve the critical trip point to enable the overheat interrupt */ -struct thermal_trip trip; +int temperature;int ret; -int i; - -for (i =0 ; i <thermal_zone_get_num_trips (tz); i++) { - - ret =thermal_zone_get_trip (tz, i, &trip); -if (ret) -return ret; - -if (trip.type !=THERMAL_TRIP_CRITICAL ) -continue ; - - ret =armada_select_channel (priv, sensor_id); -if (ret) -return ret; -armada_set_overheat_thresholds (priv, trip.temperature, - trip.hysteresis); - priv->overheat_sensor = tz; - priv->interrupt_source = sensor_id; + ret =thermal_zone_get_crit_temp (tz, &temperature); +if (ret) +return ret;
drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 800
Quoted 10 lines
drivers/thermal/armada_thermal.c +6
-3-armada_enable_overheat_interrupt (priv); + ret =armada_select_channel (priv, sensor_id); +if (ret) +return ret; -return 0 ; - } +/* +* A critical temperature does not have a hysteresis +*/
Makes sense.
Nit: I would actually put that comment in the commit log rather than keeping it in the code, but whatever, that's a nice simplification.
drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 809
Quoted 10 lines
drivers/thermal/armada_thermal.c +5
-1+armada_set_overheat_thresholds (priv, temperature,0 ); + priv->overheat_sensor = tz; + priv->interrupt_source = sensor_id; +armada_enable_overheat_interrupt (priv); -return -EINVAL ; +return 0 ; }static int armada_thermal_probe (struct platform_device *pdev)
LGTM so,
Thanks,
Miquèl
Hi Miquel,
Quoted 14 lines · Miquel Raynal
Hi Daniel,
[email protected] wrote on Wed, 18 Jan 2023 23:26:10 +0100:
Quoted 10 lines
The driver browses the trip point to find out the critical trip temperature. However the function
thermal_zone_get_crit_temp()does already that, so the routine is pointless in the driver.Use
thermal_zone_get_crit_temp()instead of inspecting all the trip points.Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/armada_thermal.c | 38 +++++++++++++-------------------
[ ... ]
Quoted 5 lines
Makes sense.
Nit: I would actually put that comment in the commit log rather than keeping it in the code, but whatever, that's a nice simplification.
Ok, I'll do the change.
Quoted 9 lines
Quoted 9 lines
drivers/thermal/armada_thermal.c +5
-1+armada_set_overheat_thresholds (priv, temperature,0 ); + priv->overheat_sensor = tz; + priv->interrupt_source = sensor_id; +armada_enable_overheat_interrupt (priv); -return -EINVAL ; +return 0 ; }
Quoted 5 lines
Quoted 1 line
static int
armada_thermal_probe(struct platform_device *pdev)LGTM so,
Reviewed-by Miquel Raynal <[email protected]>
Thanks for the review
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 63 lines · Miquel Raynal
Hi Daniel,
[email protected] wrote on Wed, 18 Jan 2023 23:26:10 +0100:
Quoted 46 lines
The driver browses the trip point to find out the critical trip temperature. However the function
thermal_zone_get_crit_temp()does already that, so the routine is pointless in the driver.Use
thermal_zone_get_crit_temp()instead of inspecting all the trip points.Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/armada_thermal.c | 38 +++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-)drivers/thermal/armada_thermal.c +4
-19@@ -784,34 +784,26 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv, int sensor_id) {/* Retrieve the critical trip point to enable the overheat interrupt */ -struct thermal_trip trip; +int temperature;int ret; -int i; - -for (i =0 ; i <thermal_zone_get_num_trips (tz); i++) { - - ret =thermal_zone_get_trip (tz, i, &trip); -if (ret) -return ret; - -if (trip.type !=THERMAL_TRIP_CRITICAL ) -continue ; - - ret =armada_select_channel (priv, sensor_id); -if (ret) -return ret; -armada_set_overheat_thresholds (priv, trip.temperature, - trip.hysteresis); - priv->overheat_sensor = tz; - priv->interrupt_source = sensor_id; + ret =thermal_zone_get_crit_temp (tz, &temperature); +if (ret) +return ret;drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 800
Quoted 10 lines
drivers/thermal/armada_thermal.c +6
-3-armada_enable_overheat_interrupt (priv); + ret =armada_select_channel (priv, sensor_id); +if (ret) +return ret; -return 0 ; - } +/* +* A critical temperature does not have a hysteresis +*/ Makes sense.
Quoted 2 lines
Nit: I would actually put that comment in the commit log rather than keeping it in the code, but whatever, that's a nice simplification.
Oh, actually, I added the comment because of the third parameter change for armada_set_overheat_thresholds(..., 0);
Quoted 1 line
drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 801
Quoted 1 line
drivers/thermal/armada_thermal.c +1
-0+armada_set_overheat_thresholds (priv, temperature,0 );
I think it makes sense to keep the comment to clarify why we pass this zero temperature argument.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Miquel Raynal
maintainerHi Daniel,
[email protected] wrote on Tue, 24 Jan 2023 12:36:22 +0100:
Quoted 61 lines · Miquel Raynal
Quoted 60 lines
Hi Daniel,
[email protected] wrote on Wed, 18 Jan 2023 23:26:10 +0100:
Quoted 43 lines
The driver browses the trip point to find out the critical trip temperature. However the function
thermal_zone_get_crit_temp()does already that, so the routine is pointless in the driver.Use
thermal_zone_get_crit_temp()instead of inspecting all the trip points.Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/armada_thermal.c | 38 +++++++++++++------------------- 1 file changed, 15 insertions(+), 23 deletions(-)drivers/thermal/armada_thermal.c +3
-18@@ -784,34 +784,26 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv, int sensor_id) {/* Retrieve the critical trip point to enable the overheat interrupt */ -struct thermal_trip trip; +int temperature;int ret; -int i; - -for (i =0 ; i <thermal_zone_get_num_trips (tz); i++) { - - ret =thermal_zone_get_trip (tz, i, &trip); -if (ret) -return ret; - -if (trip.type !=THERMAL_TRIP_CRITICAL ) -continue ; - - ret =armada_select_channel (priv, sensor_id); -if (ret) -return ret; >> - armada_set_overheat_thresholds(priv, trip.temperature, - trip.hysteresis); - priv->overheat_sensor = tz; - priv->interrupt_source = sensor_id; + ret = thermal_zone_get_crit_temp(tz, &temperature); +if (ret)drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 800
Quoted 10 lines
drivers/thermal/armada_thermal.c +7
-1+return ret; >> - armada_enable_overheat_interrupt(priv); + ret =armada_select_channel (priv, sensor_id); +if (ret) +return ret; >> - return 0; - } +/* +* A critical temperature does not have a hysteresis +*/ Makes sense.
Quoted 4 lines
Quoted 2 lines
Nit: I would actually put that comment in the commit log rather than keeping it in the code, but whatever, that's a nice simplification.
Oh, actually, I added the comment because of the third parameter change for
armada_set_overheat_thresholds(..., 0);
Yes, that's why I proposed to mention it in the commit log rather than in the code. If having no threshold here makes sense (and it does), I don't see the point in explaining it in a comment. I usually use comments to explain what could appear strange/unclear when looking at the code.
Here, while the parameter change is intended and legitimate, I feel like it is worth justifying, but doing so in the commit logs feels enough.
But that's minor tbh, so feel free to do it like you prefer.
Quoted 3 lines
Quoted 1 line
drivers/thermal/armada_thermal.c static int armada_configure_overheat_int(struct armada_thermal_priv *priv, · line 801
Quoted 1 line
drivers/thermal/armada_thermal.c +1
-0+armada_set_overheat_thresholds (priv, temperature,0 );I think it makes sense to keep the comment to clarify why we pass this zero temperature argument.
Thanks,
Miquèl