linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Peter Pan <peterpansjtu@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 6/7] mtd: nand: raw: make BBT code more generic
Date: Wed, 16 Nov 2016 09:46:14 +0100	[thread overview]
Message-ID: <20161116094614.2cacc47f@bbrezillon> (raw)
In-Reply-To: <CAAyFORKEcxUuC61_6ngke5Qmb9U4VaS-fHx6Ly0Mgw1VwzxLEw@mail.gmail.com>

On Wed, 16 Nov 2016 16:43:58 +0800
Peter Pan <peterpansjtu@gmail.com> wrote:

> Hi Boris,
> 
> I found a bug during my review. Please see below.
> 
> On Sun, Oct 16, 2016 at 10:35 PM, Boris Brezillon
> <boris.brezillon@free-electrons.com> wrote:
> > BBT support is currently tightly tied to raw NAND, though this is the kind
> > of code we could share across all NAND based devices, no matter what
> > physical interface is to communicate with the NAND chip.
> >
> > Make BBT code interface agnostic by replacing all occurrence of
> > struct nand_chip by struct nand_device, and move functions that are
> > specific to raw NANDs to drivers/mtd/nand/rawnand/nand_base.c.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> >  drivers/mtd/nand/raw/nand_base.c |  78 ++++-
> >  drivers/mtd/nand/raw/nand_bbt.c  | 609 ++++++++++++++++++---------------------
> >  include/linux/mtd/nand.h         |   8 +
> >  include/linux/mtd/rawnand.h      |   4 -
> >  4 files changed, 361 insertions(+), 338 deletions(-)
> >  
> [...]
> >  /**
> >   * write_bbt - [GENERIC] (Re)write the bad block table
> > - * @mtd: MTD device structure
> > + * @this: NAND device
> >   * @buf: temporary buffer
> >   * @td: descriptor for the bad block table
> >   * @md: descriptor for the bad block table mirror
> > @@ -708,11 +707,11 @@ static void mark_bbt_block_bad(struct nand_chip *this,
> >   *
> >   * (Re)write the bad block table.
> >   */
> > -static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
> > +static int write_bbt(struct nand_device *this, uint8_t *buf,
> >                      struct nand_bbt_descr *td, struct nand_bbt_descr *md,
> >                      int chipsel)
> >  {
> > -       struct nand_chip *this = mtd_to_nandc(mtd);
> > +       struct mtd_info *mtd = nand_to_mtd(this);
> >         struct erase_info einfo;
> >         int i, res, chip = 0;
> >         int bits, page, offs, numblocks, sft, sftmsk;
> > @@ -723,7 +722,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
> >         loff_t to;
> >         struct mtd_oob_ops ops;
> >
> > -       ops.ooblen = mtd->oobsize;
> > +       ops.ooblen = nand_per_page_oobsize(this);
> >         ops.ooboffs = 0;
> >         ops.datbuf = NULL;
> >         ops.mode = MTD_OPS_PLACE_OOB;
> > @@ -732,16 +731,16 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
> >                 rcode = 0xff;
> >         /* Write bad block table per chip rather than per device? */
> >         if (td->options & NAND_BBT_PERCHIP) {
> > -               numblocks = (int)(this->chipsize >> this->bbt_erase_shift);
> > +               numblocks = nand_eraseblocks_per_die(this);
> >                 /* Full device write or specific chip? */
> >                 if (chipsel == -1) {
> > -                       nrchips = this->numchips;
> > +                       nrchips = nand_ndies(this);
> >                 } else {
> >                         nrchips = chipsel + 1;
> >                         chip = chipsel;
> >                 }
> >         } else {
> > -               numblocks = (int)(mtd->size >> this->bbt_erase_shift);
> > +               numblocks = nand_neraseblocks(this);
> >                 nrchips = 1;
> >         }
> >
> > @@ -760,7 +759,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
> >                  * get_bbt_block() returns a block number, shift the value to
> >                  * get a page number.
> >                  */
> > -               page = block << (this->bbt_erase_shift - this->page_shift);
> > +               nand_eraseblock_to_page(this, block);  
> 
> Should be page = nand_eraseblock_to_page(this, block);
> 
> I will continue to review and test your patch. Hope give you feedback this week.

Cool. Thanks a lot!

> 
> Thanks,
> Peter Pan

  reply	other threads:[~2016-11-16  8:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16 14:35 [PATCH v2 0/7] mtd: nand: Abstract away the NAND interface type Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 1/7] mtd: nand: Rename nand.h into rawnand.h Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 2/7] mtd: nand: move raw NAND related code to the raw/ subdir Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 3/7] mtd: nand: add a nand.h file to expose basic NAND stuff Boris Brezillon
2016-11-17  6:14   ` Peter Pan
2016-11-17  7:52     ` Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 4/7] mtd: nand: raw: prefix conflicting names with nandc instead of nand Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 5/7] mtd: nand: raw: create struct rawnand_device Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 6/7] mtd: nand: raw: make BBT code more generic Boris Brezillon
2016-11-16  8:43   ` Peter Pan
2016-11-16  8:46     ` Boris Brezillon [this message]
2016-11-17  6:19   ` Peter Pan
2016-11-17  7:51     ` Boris Brezillon
2016-10-16 14:35 ` [PATCH v2 7/7] mtd: nand: move BBT code to drivers/mtd/nand/ Boris Brezillon
2016-11-17  6:26 ` [PATCH v2 0/7] mtd: nand: Abstract away the NAND interface type Peter Pan
2016-11-17  7:56   ` Boris Brezillon
2016-11-17  8:08     ` Peter Pan

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=20161116094614.2cacc47f@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peterpansjtu@gmail.com \
    --cc=richard@nod.at \
    /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).