Skip to content

Commit

Permalink
mtd: onenand: Store bad block marker position in chip struct
Browse files Browse the repository at this point in the history
The information about where the manufacturer puts the bad block
markers inside the bad block and in the OOB data is stored in
different places. Let's move this information to the chip struct,
as we did it for rawnand.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
Frieder Schrempf authored and Miquel Raynal committed Apr 18, 2019
1 parent 04649ec commit bfd15c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion drivers/mtd/nand/onenand/onenand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);

/* We write two bytes, so we don't have to mess with 16-bit access */
ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
ofs += mtd->oobsize + (this->badblockpos & ~0x01);
/* FIXME : What to do when marking SLC block in partition
* with MLC erasesize? For now, it is not advisable to
* create partitions containing both SLC and MLC regions.
Expand Down Expand Up @@ -3967,6 +3967,9 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING))
this->unlock_all(mtd);

/* Set the bad block marker position */
this->badblockpos = ONENAND_BADBLOCK_POS;

ret = this->scan_bbt(mtd);
if ((!FLEXONENAND(this)) || ret)
return ret;
Expand Down
3 changes: 0 additions & 3 deletions drivers/mtd/nand/onenand/onenand_bbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ static int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
if (!bbm->bbt)
return -ENOMEM;

/* Set the bad block position */
bbm->badblockpos = ONENAND_BADBLOCK_POS;

/* Set erase shift */
bbm->bbt_erase_shift = this->erase_shift;

Expand Down
3 changes: 3 additions & 0 deletions include/linux/mtd/onenand.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct onenand_chip {
unsigned int technology;
unsigned int density_mask;
unsigned int options;
unsigned int badblockpos;

unsigned int erase_shift;
unsigned int page_shift;
Expand Down Expand Up @@ -188,6 +189,8 @@ struct onenand_chip {
/* Check byte access in OneNAND */
#define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1)

#define ONENAND_BADBLOCK_POS 0

/*
* Options bits
*/
Expand Down

0 comments on commit bfd15c9

Please sign in to comment.