lkml.org 
[lkml]   [2021]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 03/14] iio: inkern: make a best effort on offset calculation
Hi Andy,

On Tue, Dec 21, 2021 at 07:42:31AM +0200, Andy Shevchenko wrote:
> On Mon, Dec 20, 2021 at 11:17 AM Liam Beguin <liambeguin@gmail.com> wrote:
> >
> > From: Liam Beguin <lvb@xiphos.com>
> >
> > iio_convert_raw_to_processed_unlocked() assumes the offset is an
> > integer. Make a best effort to get a valid offset value for fractional
> > cases without breaking implicit truncations.
>
> ...
>
> > + offset_val /= (1 << offset_val2);
>
> Besides potentially being problematic (if arg is 31 for the left
> shift) why not simply
>
> _val >>= _val2;

That is safer, and more elegant! I'll update.

Thanks,
Liam

> --
> With Best Regards,
> Andy Shevchenko

\
 
 \ /
  Last update: 2021-12-21 18:50    [W:0.049 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site