Re: [PATCH 1/3] mtd: rawnand: Support bad block markers in first, second or last page

From: Boris Brezillon
Date: Thu Dec 20 2018 - 09:07:34 EST


On Thu, 20 Dec 2018 14:59:54 +0100
Boris Brezillon <boris.brezillon@xxxxxxxxxxx> wrote:

> >
> > /**
> > + * nand_bbm_page_offset - Get the page offsets for bad block markers
> > + * @chip: NAND chip object
> > + * @index: Index for the page offset
>
> Hm, the meaning of index is far from obvious. How about passing the
> current page instead (and return 1 if there are more pages to scan 0
> otherwise)?
>
> Something like:
>
> static int nand_bbm_get_next_page(struct nand_chip *chip, int page)
> {
> struct mtd_info *mtd = nand_to_mtd(chip);
> int last_page = ((mtd->erasesize - mtd->writesize) >>
> chip->page_shift) & chip->pagemask;
>
> if (page < 0 && chip->bbt_options & NAND_BBT_SCANFIRSTPAGE)
> return 0;
> else if (page < 1 && chip->bbt_options & NAND_BBT_SCAN2NDPAGE)
> return 1;
> else if (page < last_page &&
> chip->bbt_options & NAND_BBT_SCANLASTPAGE)
> return last_page;
>
> return -1;
> }
>
> And yes, that means defining NAND_BBT_SCANFIRSTPAGE and setting it when
> appropriate.
>

Oh, and you'll have to define NAND_BBT_SCANFIRST2PAGES like this

#define NAND_BBT_SCANFIRST2PAGES NAND_BBT_SCAN1STPAGE | \
NAND_BBT_SCAN2NDPAGE

and then patch all users of NAND_BBT_SCAN2NDPAGE to use
NAND_BBT_SCANFIRST2PAGES instead.