]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
thermal: imx_thermal: fix busywait if IMX6 temp <0C
authorTim Harvey <tharvey@gateworks.com>
Wed, 8 Jul 2015 22:49:43 +0000 (15:49 -0700)
committerStefano Babic <sbabic@denx.de>
Fri, 10 Jul 2015 08:15:19 +0000 (10:15 +0200)
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 <b37916@freescale.com>
Cc: Jason Liu <r64343@freescale.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
drivers/thermal/imx_thermal.c

index 42ca8d0b6b3de9ac51d7f33689c91a283857e844..3c6c9679f97a89b30a30caf8b8bafb9238a41213 100644 (file)
@@ -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);