Thread (38 messages) 38 messages, 2 authors, 2022-01-08

Re: [PATCH v11 11/15] iio: test: add basic tests for the iio-rescale driver

From: Liam Beguin <hidden>
Date: 2021-12-22 19:13:44
Also in: linux-iio, lkml

On Wed, Dec 22, 2021 at 02:38:13PM +0200, Andy Shevchenko wrote:
On Wed, Dec 22, 2021 at 5:47 AM Liam Beguin [off-list ref] wrote:
quoted
From: Liam Beguin <redacted>

The iio-rescale driver supports various combinations of scale types and
offsets. These can often result in large integer multiplications. Make
sure these calculations are done right by adding a set of kunit test
cases that build on top of iio-test-format.
...
quoted
+       int fract_mult = 100000000LL;
Perhaps also change to use the prefix?
Argh.. I missed this file. Sorry, will update.
...
quoted
+       *nano = (s64)tmp * 10 * fract_mult + tmp2;
I'm also puzzled what the meaning of the 10 is here?
That comes from iio_str_to_fixpoint().
I sould've added a comment to make it more explicit as details escape me
right now...  Will fix.
...
quoted
+       err = 1000000 * abs(exp - real);
Prefix?
Ok
...
quoted
+       err = div64_u64(err, abs(exp));
+       return (int)err;
return div64_u64();
will do.

Cheers,
Liam
-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help