[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180515223516.16e907b3@bbrezillon>
Date: Tue, 15 May 2018 22:35:16 +0200
From: Boris Brezillon <boris.brezillon@...tlin.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: jagdish.gediya@....com,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Jane Wan <Jane.Wan@...ia.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Richard Weinberger <richard@....at>,
Marek Vasut <marek.vasut@...il.com>, ties.bos@...ia.com,
prabhakar.kushwaha@....com,
"open list:MEMORY TECHNOLOGY..." <linux-mtd@...ts.infradead.org>,
Shreeya Patel <shreeya.patel23498@...il.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Brian Norris <computersforpeace@...il.com>,
Shawn Guo <shawnguo@...nel.org>,
David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH v5 2/2] mtd: rawnand: use bit-wise majority to recover
the contents of ONFI parameter
On Tue, 15 May 2018 23:23:02 +0300
Andy Shevchenko <andy.shevchenko@...il.com> wrote:
> On Tue, May 15, 2018 at 11:03 AM, Boris Brezillon
> <boris.brezillon@...tlin.com> wrote:
> > On Tue, 15 May 2018 10:46:00 +0300
> > Andy Shevchenko <andy.shevchenko@...il.com> wrote:
> >
> >> On Tue, May 15, 2018 at 10:35 AM, Boris Brezillon
> >> <boris.brezillon@...tlin.com> wrote:
> >> > On Mon, 14 May 2018 20:54:36 +0300
> >> > Andy Shevchenko <andy.shevchenko@...il.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))
I made a mistake in my code sample, it's
if (srcbuf[i] & BIT(j))
If you look at v6, you'll see it's been fixed by Jane.
> m++;
> }
>
> ...and now it looks obvious:
>
> m += hweight...(srcbuf[i])
>
> _If_ nbufs is power of two we may use primitive helper.
>
Powered by blists - more mailing lists