lkml.org 
[lkml]   [2018]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 2/2] mtd: rawnand: use bit-wise majority to recover the contents of ONFI parameter
On Tue, May 15, 2018 at 11:03 AM, Boris Brezillon
<boris.brezillon@bootlin.com> wrote:
> On Tue, 15 May 2018 10:46:00 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
>> On Tue, May 15, 2018 at 10:35 AM, Boris Brezillon
>> <boris.brezillon@bootlin.com> wrote:
>> > On Mon, 14 May 2018 20:54:36 +0300
>> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

>> >> > for (k = 0; k < nbufs; k++) {
>> >> > const u8 *srcbuf = srcbufs[j];
>> >> >
>> >> > if (srcbuf[i] & BIT(k))
>> >> > m++;
>> >> > }
>> >>
>> >> ...which is effectively hweightXX().
>> >
>> > No it's not.
>>
>> I don't see how "not". In the loop everithing except m and k are
>> invariants. What did I miss?
>
> We're not counting the number of bits set in an uXX var, but the number
> of set bits at the same position in different buffers.

...on big picture. The excerpt above is hweight() against srcbuf[i].

Let's rewrite it like this:

const u8 *srcbuf = srcbufs[j];

for (k = 0; k < nbufs; k++) {
if (srcbuf[i] & BIT(k))
m++;
}

...and now it looks obvious:

m += hweight...(srcbuf[i])

_If_ nbufs is power of two we may use primitive helper.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-05-15 22:23    [W:0.080 / U:10.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site