[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5740bcb3490d4c17bd9bc731e79b174b@AcuMS.aculab.com>
Date: Sat, 29 Oct 2022 11:23:06 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'Sa, Nuno'" <Nuno.Sa@...log.com>, Deepak R Varma <drv@...lo.com>,
"outreachy@...ts.linux.dev" <outreachy@...ts.linux.dev>,
Lars-Peter Clausen <lars@...afoo.de>,
"Hennerich, Michael" <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
"linux-staging@...ts.linux.dev" <linux-staging@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] staging: iio: ad5933: Use div64_ul instead of do_div
> > -----Original Message-----
> > From: Deepak R Varma <drv@...lo.com>
> >
> > [External]
> >
> > do_div() does a 64-by-32 division. Here the divisor is an unsigned long
> > which on some platforms is 64 bit wide. So use div64_ul instead of do_div
> > to avoid a possible truncation. Issue was identified using the
> > coccicheck tool.
These changes should all get nacked unless the domain of the values
can be shown to be out of range.
The entire point of do_div() is that because division is expensive
using a limited range division is significantly faster.
Even on Intel 64 bit cpu the 64 by 32 divide is significantly
faster then a full 64 bit divide for the same input values.
One might also question why the divisor is actually 'unsigned long'
at all. The code is almost certainly expected to compile for 32bit
so the domain of the value should fit in 32 bits.
So either the type could be unsigned int, or it really doesn't matter
that the value is truncated to 32bit because it can never be larger.
David
> >
> > Signed-off-by: Deepak R Varma <drv@...lo.com>
> > ---
>
> Reviewed-by: Nuno Sá <nuno.sa@...log.com>
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists