@@ -4153,7 +4153,9 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to,
*/
static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
{
- return nand_erase_nand(mtd_to_nand(mtd), instr, 0);
+ struct nand_chip *chip = mtd_to_nand(mtd);
+
+ return chip->erase(chip, instr, 0);
}
/**
@@ -4373,6 +4375,8 @@ static void nand_set_defaults(struct nand_chip *chip)
if (!chip->buf_align)
chip->buf_align = 1;
+
+ chip->erase = nand_erase_nand;
}
/* Sanitize ONFI strings so we can safely print them */
@@ -1020,6 +1020,7 @@ struct nand_legacy {
* avoid using them.
* @setup_read_retry: [FLASHSPECIFIC] flash (vendor) specific function for
* setting the read-retry mode. Mostly needed for MLC NAND.
+ * @erase: Raw NAND erase operation.
* @ecc: [BOARDSPECIFIC] ECC control structure
* @buf_align: minimum buffer alignment required by a platform
* @oob_poi: "poison value buffer," used for laying out OOB data
@@ -1085,6 +1086,8 @@ struct nand_chip {
struct nand_legacy legacy;
int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
+ int (*erase)(struct nand_chip *chip, struct erase_info *instr,
+ int allowbbt);
unsigned int options;
unsigned int bbt_options;
In order to solve an issue with Micron NANDs, we must be able to overload the erase operation. With this in mind, we create a ->erase hook in the nand_chip structure which points by default to the currently in use nand_erase_nand() helper. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/mtd/nand/raw/nand_base.c | 6 +++++- include/linux/mtd/rawnand.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)