RE: [PATCH v2] thermal: rcar_gen3_thermal: Fix undefined temperature if negative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> From: Amit Kucheria, Sent: Tuesday, June 23, 2020 9:07 PM
<snip>
> > --- a/drivers/thermal/rcar_gen3_thermal.c
> > +++ b/drivers/thermal/rcar_gen3_thermal.c
> > @@ -167,16 +167,16 @@ static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
> >  {
> >         struct rcar_gen3_thermal_tsc *tsc = devdata;
> >         int mcelsius, val;
> > -       u32 reg;
> > +       int ctemp;
> 
> Wouldn't it be better to change the variable type to fix the bug in
> this patch and make a separate one for the variable rename?

I got it. I'll keep the variable name in this patch.

Best regards,
Yoshihiro Shimoda

> Regards,
> Amit
> 
> >         /* Read register and convert to mili Celsius */
> > -       reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
> > +       ctemp = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
> >
> > -       if (reg <= thcode[tsc->id][1])
> > -               val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1,
> > +       if (ctemp <= thcode[tsc->id][1])
> > +               val = FIXPT_DIV(FIXPT_INT(ctemp) - tsc->coef.b1,
> >                                 tsc->coef.a1);
> >         else
> > -               val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2,
> > +               val = FIXPT_DIV(FIXPT_INT(ctemp) - tsc->coef.b2,
> >                                 tsc->coef.a2);
> >         mcelsius = FIXPT_TO_MCELSIUS(val);
> >
> > --
> > 2.7.4
> >




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux