diff mbox series

thermal: bcm2711_thermal: Don't clamp temperature at zero

Message ID 20220412195423.104511-1-stefan.wahren@i2se.com (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series thermal: bcm2711_thermal: Don't clamp temperature at zero | expand

Commit Message

Stefan Wahren April 12, 2022, 7:54 p.m. UTC
The thermal sensor on BCM2711 is capable of negative temperatures, so don't
clamp the measurements at zero. Since this was the only use for variable t,
drop it.

This change based on a patch by Dom Cobley, who also tested the fix.

Fixes: 59b781352dc4 ("thermal: Add BCM2711 thermal driver")
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/thermal/broadcom/bcm2711_thermal.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Florian Fainelli April 13, 2022, 5:01 p.m. UTC | #1
On 4/12/2022 12:54 PM, Stefan Wahren wrote:
> The thermal sensor on BCM2711 is capable of negative temperatures, so don't
> clamp the measurements at zero. Since this was the only use for variable t,
> drop it.
> 
> This change based on a patch by Dom Cobley, who also tested the fix.
> 
> Fixes: 59b781352dc4 ("thermal: Add BCM2711 thermal driver")
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Daniel Lezcano April 13, 2022, 5:03 p.m. UTC | #2
On 12/04/2022 21:54, Stefan Wahren wrote:
> The thermal sensor on BCM2711 is capable of negative temperatures, so don't
> clamp the measurements at zero. Since this was the only use for variable t,
> drop it.
> 
> This change based on a patch by Dom Cobley, who also tested the fix.
> 
> Fixes: 59b781352dc4 ("thermal: Add BCM2711 thermal driver")
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/thermal/broadcom/bcm2711_thermal.c b/drivers/thermal/broadcom/bcm2711_thermal.c
index 1ec57d9ecf53..e9bef5c3414b 100644
--- a/drivers/thermal/broadcom/bcm2711_thermal.c
+++ b/drivers/thermal/broadcom/bcm2711_thermal.c
@@ -38,7 +38,6 @@  static int bcm2711_get_temp(void *data, int *temp)
 	int offset = thermal_zone_get_offset(priv->thermal);
 	u32 val;
 	int ret;
-	long t;
 
 	ret = regmap_read(priv->regmap, AVS_RO_TEMP_STATUS, &val);
 	if (ret)
@@ -50,9 +49,7 @@  static int bcm2711_get_temp(void *data, int *temp)
 	val &= AVS_RO_TEMP_STATUS_DATA_MSK;
 
 	/* Convert a HW code to a temperature reading (millidegree celsius) */
-	t = slope * val + offset;
-
-	*temp = t < 0 ? 0 : t;
+	*temp = slope * val + offset;
 
 	return 0;
 }