Skip to contentSkip to conversation

thermal/drivers/airoha: Fix low trip clamp using wrong variable

PATCH In review Wayen.Yan 2 participants 3 messages Jun 14

Subsystems (2)
lore
Share & tools
lore

Wayen.Yan

author
#0 lore raw

PATCH 1/1 thermal/drivers/airoha: Fix low trip clamp using wrong variable

In airoha_thermal_set_trips(), the low trip validation incorrectly clamps 'high' instead of 'low':

  low = clamp_t(int, high, RAW_TO_TEMP(priv, 0), ...);

This causes TEMPOFFSETL to receive the clamped high-temperature value instead of the requested low-temperature value, making the low-temperature alert threshold identical to the high-temperature threshold. As a result, low-temperature interrupts can never fire independently.

Fix by replacing 'high' with 'low' in the clamp expression, matching the symmetric pattern used for the high trip on line 264.

Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")
---
 drivers/thermal/airoha_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/airoha_thermal.c +1 -1
index b9fd6bfc88..439aa011b7 100644
@@ -273,7 +273,7 @@ static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
 
 	if (low != -INT_MAX) {
 		/* Validate low and clamp it to a supported value */
-		low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
+		low = clamp_t(int, low, RAW_TO_TEMP(priv, 0),
 			      RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
 
 		/* We offset the low temp of 1°C to trigger correct event */
Signature · 1 line
2.51.0
#1 lore raw
Quoted 36 lines · Wayen.Yan

In airoha_thermal_set_trips(), the low trip validation incorrectly clamps 'high' instead of 'low':

  low = clamp_t(int, high, RAW_TO_TEMP(priv, 0), ...);

This causes TEMPOFFSETL to receive the clamped high-temperature value instead of the requested low-temperature value, making the low-temperature alert threshold identical to the high-temperature threshold. As a result, low-temperature interrupts can never fire independently.

Fix by replacing 'high' with 'low' in the clamp expression, matching the symmetric pattern used for the high trip on line 264.

Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")
---
 drivers/thermal/airoha_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/airoha_thermal.c +1 -1
index b9fd6bfc88..439aa011b7 100644
@@ -273,7 +273,7 @@ static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
 
 	if (low != -INT_MAX) {
 		/* Validate low and clamp it to a supported value */
-		low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
+		low = clamp_t(int, low, RAW_TO_TEMP(priv, 0),
 			      RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
 
 		/* We offset the low temp of 1°C to trigger correct event */
Signature · 1 line
2.51.0

Hi I already submitted the same patch in the AN7583 series. Can you review that patch so maybe we can try to push fix for this?

Signature · 1 line
	Ansuel
author Reviewed-by on v1 1/1
#2 lore raw
In reply to Wayen.Yan

Christian Marangi has submitted the same fix in his AN7583 thermal series v5 [1/7] and [2/7]:

https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/

I have reviewed his patches and provided Reviewed-by tags. Since his series includes these fixes along with additional AN7583 support, please merge his series instead. This patch can be marked as superseded.