[PATCH] mtd: spi-nor: fix the wrong dummy value

Marek Vasut marex at denx.de
Thu Apr 17 04:30:32 PDT 2014


On Thursday, April 17, 2014 at 06:59:43 AM, Huang Shijie wrote:
> On Wed, Apr 16, 2014 at 10:08:49PM +0200, Gerhard Sittig wrote:
> > On Wed, 2014-04-16 at 16:18 +0800, Huang Shijie wrote:
> > > The dummy cycles is actually 8 for SPI fast/dual/quad read.
> > > 
> > > This patch fixes the wrong dummy value for both the spi-nor.c and
> > > m25p80.c.
> > > 
> > > Signed-off-by: Huang Shijie <b32955 at freescale.com>
> > > ---
> > > 
> > >  drivers/mtd/devices/m25p80.c  |    3 +++
> > >  drivers/mtd/spi-nor/spi-nor.c |    2 +-
> > >  2 files changed, 4 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/drivers/mtd/devices/m25p80.c
> > > b/drivers/mtd/devices/m25p80.c index 1557d8f..112ca8b 100644
> > > --- a/drivers/mtd/devices/m25p80.c
> > > +++ b/drivers/mtd/devices/m25p80.c
> > > @@ -131,6 +131,9 @@ static int m25p80_read(struct spi_nor *nor, loff_t
> > > from, size_t len,
> > > 
> > >  	int dummy = nor->read_dummy;
> > >  	int ret;
> > > 
> > > +	/* convert the dummy cycles to the number of byte */
> > > +	dummy >>= 3;
> > > +
> > 
> > "dummy /= 8" to match the comment / commit message, and for
> > better mental association with a byte's width and the below
> > return value?
> 
> I first version is "dummy /= 8". but i think the "dummy >>= 3" is more
> faster.

You can prove that by running objdump on the object file and inspecting the 
generated code. My expectation would be that GCC would optimize this as needed.
[...]

Best regards,
Marek Vasut



More information about the linux-mtd mailing list