Skip to contentSkip to conversation

thermal: imx_thermal: fix busywait if IMX6 temp <0C

PATCH New Tim Harvey 2 participants 2 messages Jul 8, 2015 – Jul 10, 2015

Subsystems (2)
lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 thermal: imx_thermal: fix busywait if IMX6 temp <0C

The temperature calculation must be typecasted to keep the compiler from sign extending a negative value prior to division.

This fixes an issue where if the CPU temperature is <0C it will get stuck in the busywait loop until the CPU heats up to 0C.

---
 drivers/thermal/imx_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/imx_thermal.c +1 -1
index 0d893c9..6d1ac97 100644
@@ -115,7 +115,7 @@ static int read_cpu_temperature(struct udevice *dev)
 	writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr);
 
 	/* milli_Tmeas = c2 - Nmeas * c1 */
-	temperature = (c2 - n_meas * c1)/1000;
+	temperature = (long)(c2 - n_meas * c1)/1000;
 
 	/* power down anatop thermal sensor */
 	writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_set);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 thermal: imx_thermal: fix busywait if IMX6 temp <0C

Hi Tim,

Quoted 19 lines · Tim Harvey

The temperature calculation must be typecasted to keep the compiler from sign extending a negative value prior to division.

This fixes an issue where if the CPU temperature is <0C it will get stuck in the busywait loop until the CPU heats up to 0C.

---
 drivers/thermal/imx_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/imx_thermal.c +0 -0
index 0d893c9..6d1ac97 100644

drivers/thermal/imx_thermal.c static int read_cpu_temperature(struct udevice *dev) · line 121

Quoted 8 lines
drivers/thermal/imx_thermal.c +1 -1
@@ -115,7 +115,7 @@ static int read_cpu_temperature(struct udevice *dev)
 	writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr);
 
 	/* milli_Tmeas = c2 - Nmeas * c1 */
-	temperature = (c2 - n_meas * c1)/1000;
+	temperature = (long)(c2 - n_meas * c1)/1000;
 
 	/* power down anatop thermal sensor */
 	writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_set);

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================