lkml.org 
[lkml]   [2020]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] iio: sx9310: Fix semtech,avg-pos-strength setting when > 16
From
Date
Quoting Doug Anderson (2020-11-20 10:16:28)
>
> Checking the math for the documented possible values of pos. What we want:
>
> 0 => 0
> 16 => 1
> 64 => 2
> 128 => 3
> 256 => 4
> 512 => 5
> 1024 => 6
> 4294967295 => 7
>
> So looks OK. Do we care about anything other than the documented
> numbers? If my understanding of ilog2 is correct, then you'll get the
> wrong answer for 17. I think you could fix it with:
>
> pos = min(max(ilog2(pos), 3), 11) - (pos >= 32 ? 4 : 3);
>

I don't think we really care about the rounding but to be consistent
with the first two it is better to do that. I'll send a fix.

\
 
 \ /
  Last update: 2020-11-20 19:23    [W:0.048 / U:1.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site