Message ID | 1436395783-8427-1-git-send-email-tharvey@gateworks.com |
---|---|
State | Awaiting Upstream |
Delegated to: | Stefano Babic |
Headers | show |
Hi Tim, On 09/07/2015 00:49, Tim Harvey wrote: > 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 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c > index 0d893c9..6d1ac97 100644 > --- a/drivers/thermal/imx_thermal.c > +++ b/drivers/thermal/imx_thermal.c > @@ -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
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 0d893c9..6d1ac97 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -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);
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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)