RE: [PATCH] drivers:iio:dac make expression evaluation 64-bit

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

 



> >>> Two 32-bit values are being evaluated using 32-bit arithmetic and
> >>> then passed to s64 type. It is wrong. Expression should be evaluated
> >>> using 64-bit arithmetic and then passed.
> >> ...
> >>
> >>>          dac->ch_data[ch].scale_dec = DIV_ROUND_CLOSEST((s64)rem *
> 1000000,
> >>>                                                          65536);
> >> Shouldn't the above be fixed as well? Has anybody tried to compile on
> >> 32-bit arch this?
> > No, it correct already. In this case, rem is being typecasted to s64
> > and then multiplied with a 32-bit number, 1000000. Thus 64-bit
> > arithmetic is being performed here.
> 
> What Andy means is that this needs to be DIV_S64_ROUND_CLOSEST() to
> work on 32-bit platforms. But it is clearly unrelated to your change and should
> be in its own patch.

Indeed, I didn't test it on 32 bits.
But both changes make sense to me.

Regards,
Mihail




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux