Commit 5740d4c4 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: Pass a nand_chip object to all nand_xxx_bbt() helpers

Let's make the raw NAND API consistent by patching all helpers and
hooks to take a nand_chip object instead of an mtd_info one or
remove the mtd_info object when both are passed.

Let's tackle the nand_xxx_bbt() helpers.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 858838b8
...@@ -515,7 +515,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs) ...@@ -515,7 +515,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)
/* Mark block bad in BBT */ /* Mark block bad in BBT */
if (chip->bbt) { if (chip->bbt) {
res = nand_markbad_bbt(mtd, ofs); res = nand_markbad_bbt(chip, ofs);
if (!ret) if (!ret)
ret = res; ret = res;
} }
...@@ -565,7 +565,7 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs) ...@@ -565,7 +565,7 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)
if (!chip->bbt) if (!chip->bbt)
return 0; return 0;
/* Return info from the table */ /* Return info from the table */
return nand_isreserved_bbt(mtd, ofs); return nand_isreserved_bbt(chip, ofs);
} }
/** /**
...@@ -585,7 +585,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt) ...@@ -585,7 +585,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt)
return chip->block_bad(chip, ofs); return chip->block_bad(chip, ofs);
/* Return info from the table */ /* Return info from the table */
return nand_isbad_bbt(mtd, ofs, allowbbt); return nand_isbad_bbt(chip, ofs, allowbbt);
} }
/** /**
......
...@@ -1387,12 +1387,11 @@ EXPORT_SYMBOL(nand_create_bbt); ...@@ -1387,12 +1387,11 @@ EXPORT_SYMBOL(nand_create_bbt);
/** /**
* nand_isreserved_bbt - [NAND Interface] Check if a block is reserved * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
* @mtd: MTD device structure * @this: NAND chip object
* @offs: offset in the device * @offs: offset in the device
*/ */
int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) int nand_isreserved_bbt(struct nand_chip *this, loff_t offs)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
int block; int block;
block = (int)(offs >> this->bbt_erase_shift); block = (int)(offs >> this->bbt_erase_shift);
...@@ -1401,13 +1400,12 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs) ...@@ -1401,13 +1400,12 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs)
/** /**
* nand_isbad_bbt - [NAND Interface] Check if a block is bad * nand_isbad_bbt - [NAND Interface] Check if a block is bad
* @mtd: MTD device structure * @this: NAND chip object
* @offs: offset in the device * @offs: offset in the device
* @allowbbt: allow access to bad block table region * @allowbbt: allow access to bad block table region
*/ */
int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) int nand_isbad_bbt(struct nand_chip *this, loff_t offs, int allowbbt)
{ {
struct nand_chip *this = mtd_to_nand(mtd);
int block, res; int block, res;
block = (int)(offs >> this->bbt_erase_shift); block = (int)(offs >> this->bbt_erase_shift);
...@@ -1429,12 +1427,12 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) ...@@ -1429,12 +1427,12 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
/** /**
* nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
* @mtd: MTD device structure * @this: NAND chip object
* @offs: offset of the bad block * @offs: offset of the bad block
*/ */
int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs) int nand_markbad_bbt(struct nand_chip *this, loff_t offs)
{ {
struct nand_chip *this = mtd_to_nand(mtd); struct mtd_info *mtd = nand_to_mtd(this);
int block, ret = 0; int block, ret = 0;
block = (int)(offs >> this->bbt_erase_shift); block = (int)(offs >> this->bbt_erase_shift);
......
...@@ -1545,9 +1545,9 @@ extern const struct nand_manufacturer_ops amd_nand_manuf_ops; ...@@ -1545,9 +1545,9 @@ extern const struct nand_manufacturer_ops amd_nand_manuf_ops;
extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; extern const struct nand_manufacturer_ops macronix_nand_manuf_ops;
int nand_create_bbt(struct nand_chip *chip); int nand_create_bbt(struct nand_chip *chip);
int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs); int nand_markbad_bbt(struct nand_chip *chip, loff_t offs);
int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs); int nand_isreserved_bbt(struct nand_chip *chip, loff_t offs);
int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); int nand_isbad_bbt(struct nand_chip *chip, loff_t offs, int allowbbt);
int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
int allowbbt); int allowbbt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment