linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Shreeya Patel <shreeya.patel23498@gmail.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Jane Wan <Jane.Wan@nokia.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Marek Vasut <marek.vasut@gmail.com>,
	ties.bos@nokia.com, prabhakar.kushwaha@nxp.com,
	"open list:MEMORY TECHNOLOGY..." <linux-mtd@lists.infradead.org>,
	jagdish.gediya@nxp.com, Richard Weinberger <richard@nod.at>,
	Shawn Guo <shawnguo@kernel.org>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v5 2/2] mtd: rawnand: use bit-wise majority to recover the contents of ONFI parameter
Date: Tue, 15 May 2018 23:23:02 +0300	[thread overview]
Message-ID: <CAHp75VeEhB=+x0toCtSvrq0zBLXVCASzN2BUDDgNParSYZc5BQ@mail.gmail.com> (raw)
In-Reply-To: <20180515100304.3daa7929@bbrezillon>

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

  reply	other threads:[~2018-05-15 20:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10  2:46 [PATCH v5 2/2] mtd: rawnand: use bit-wise majority to recover the contents of ONFI parameter Jane Wan
2018-05-10 12:03 ` Boris Brezillon
2018-05-10 21:37   ` Wan, Jane (Nokia - US/Sunnyvale)
2018-05-14 17:54   ` Andy Shevchenko
2018-05-15  7:35     ` Boris Brezillon
2018-05-15  7:46       ` Andy Shevchenko
2018-05-15  8:03         ` Boris Brezillon
2018-05-15 20:23           ` Andy Shevchenko [this message]
2018-05-15 20:35             ` Boris Brezillon
2018-05-15 21:02               ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHp75VeEhB=+x0toCtSvrq0zBLXVCASzN2BUDDgNParSYZc5BQ@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=Jane.Wan@nokia.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=jagdish.gediya@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=prabhakar.kushwaha@nxp.com \
    --cc=richard@nod.at \
    --cc=shawnguo@kernel.org \
    --cc=shreeya.patel23498@gmail.com \
    --cc=ties.bos@nokia.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).