thermal: imx_thermal: fix busywait if IMX6 temp <0C
Subsystems (2)
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
@@ -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
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.
Cc Ye Li <[email protected]>Cc Jason Liu <[email protected]>Signed-off-by Tim Harvey <[email protected]>--- drivers/thermal/imx_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/imx_thermal.c +0
-0
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 =====================================================================