On Fri, 18 Jan 2019 22:11:34 +0000 "Bean Huo (beanhuo)" <beanhuo@xxxxxxxxxx> wrote: > This patch is to add a callback function pointer > for preparation routine of erase in nand_manufacturer_ops. > > Signed-off-by: Bean Huo <beanhuo@xxxxxxxxxx> > --- > drivers/mtd/nand/raw/internals.h | 2 ++ > drivers/mtd/nand/raw/nand_base.c | 5 +++++ > 2 files changed, 7 insertions(+) > > diff --git a/drivers/mtd/nand/raw/internals.h b/drivers/mtd/nand/raw/internals.h > index fbf6ca0..8382948 100644 > --- a/drivers/mtd/nand/raw/internals.h > +++ b/drivers/mtd/nand/raw/internals.h > @@ -42,6 +42,7 @@ > * is here to let vendor specific code release those resources. > * @fixup_onfi_param_page: apply vendor specific fixups to the ONFI parameter > * page. This is called after the checksum is verified. > + * @erase_pre: preparation before actually erase a physical block. > */ > struct nand_manufacturer_ops { > void (*detect)(struct nand_chip *chip); > @@ -49,6 +50,7 @@ struct nand_manufacturer_ops { > void (*cleanup)(struct nand_chip *chip); > void (*fixup_onfi_param_page)(struct nand_chip *chip, > struct nand_onfi_params *p); > + int (*erase_pre)(struct nand_chip *chip, int page); Let's move this hook to nand_chip and name it ->pre_erase() or ->erase_preparation(). > }; > > /** > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index cca4b24..d446d1c 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -4246,6 +4246,11 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, > (page + pages_per_block)) > chip->pagebuf = -1; > > + if (chip->manufacturer.desc && chip->manufacturer.desc->ops && > + chip->manufacturer.desc->ops->erase_pre) > + chip->manufacturer.desc->ops->erase_pre(chip, > + page & chip->pagemask); > + > if (chip->legacy.erase) > status = chip->legacy.erase(chip, > page & chip->pagemask); ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/