linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, Bayi Cheng <bayi.cheng@mediatek.com>
Subject: Re: [PATCH 1/2] mtd: spi-nor: provide default erase_sector implementation
Date: Sat, 31 Oct 2015 03:13:46 +0100	[thread overview]
Message-ID: <201510310313.46676.marex@denx.de> (raw)
In-Reply-To: <20151030210533.GK13239@google.com>

On Friday, October 30, 2015 at 10:05:33 PM, Brian Norris wrote:
> On Thu, Oct 29, 2015 at 06:24:20PM -0700, Brian Norris wrote:
> > Some spi-nor drivers perform sector erase by duplicating their
> > write_reg() command. Let's not require that the driver fill this out,
> > and provide a default instead.
> > 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > ---
> > 
> >  drivers/mtd/spi-nor/spi-nor.c | 30 ++++++++++++++++++++++++++----
> >  include/linux/mtd/spi-nor.h   |  3 ++-
> >  2 files changed, 28 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c
> > b/drivers/mtd/spi-nor/spi-nor.c index 49883905a434..58a435372be7 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -313,6 +313,29 @@ static void spi_nor_unlock_and_unprep(struct spi_nor
> > *nor, enum spi_nor_ops ops)
> > 
> >  }
> >  
> >  /*
> > 
> > + * Initiate the erasure of a single sector
> > + */
> > +static int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
> > +{
> > +	u8 buf[nor->addr_width];
> 
> Hmm, I see some warnings about variable length arrays here. Probably
> better to just set a MAX macro with the value of 4, since the extra byte
> really doesn't matter that much.

Hm yeah, this dynamic allocation is not great. You might want to put some
sort of assertion in place, to check whether addr_width isn't > MAX .

> I'll send v2.
> 
> Brian

Best regards,
Marek Vasut

      reply	other threads:[~2015-10-31  2:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30  1:24 [PATCH 1/2] mtd: spi-nor: provide default erase_sector implementation Brian Norris
2015-10-30  1:24 ` [PATCH 2/2] mtd: m25p80: drop erase() callback Brian Norris
2015-10-30 21:05 ` [PATCH 1/2] mtd: spi-nor: provide default erase_sector implementation Brian Norris
2015-10-31  2:13   ` Marek Vasut [this message]

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=201510310313.46676.marex@denx.de \
    --to=marex@denx.de \
    --cc=bayi.cheng@mediatek.com \
    --cc=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /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).