[PATCH v5 2/2] mtd: rawnand: use bit-wise majority to recover the contents of ONFI parameter

Boris Brezillon boris.brezillon at bootlin.com
Tue May 15 01:03:04 PDT 2018


On Tue, 15 May 2018 10:46:00 +0300
Andy Shevchenko <andy.shevchenko at gmail.com> wrote:

> On Tue, May 15, 2018 at 10:35 AM, Boris Brezillon
> <boris.brezillon at bootlin.com> wrote:
> > On Mon, 14 May 2018 20:54:36 +0300
> > Andy Shevchenko <andy.shevchenko at gmail.com> wrote:
> >  
> >> On Thu, May 10, 2018 at 3:03 PM, Boris Brezillon
> >> <boris.brezillon at bootlin.com> wrote:
> >>  
> >> >> +#define GET_BIT(bit, val)   (((val) >> (bit)) & 0x01)  
> >> >
> >> > Not sure we need that macro, see below.  
> >>
> >> +1. We have too many nice helpers for bit manipulations
> >> (for_each_set_bit() as an example).
> >>
> >>  
> >> >                         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.

> 
> The powerness of two of nbufs is another thing of _existing_
> prototypes of hweightXX().
> 



More information about the linux-mtd mailing list