On Tue, 4 Dec 2018 17:56:57 +0530 Vignesh R <[email protected]> wrote: > Now that there is new SPI NOR framework, simplify mtd device > registration and read/write/erase operations. > > Signed-off-by: Vignesh R <[email protected]> > --- > drivers/mtd/spi/sf_internal.h | 2 +- > drivers/mtd/spi/sf_mtd.c | 39 ++++++++++++----------------------- > drivers/mtd/spi/sf_probe.c | 2 +- > 3 files changed, 15 insertions(+), 28 deletions(-) > > diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h > index 7e7d400cdbdf..8b445bb0b506 100644 > --- a/drivers/mtd/spi/sf_internal.h > +++ b/drivers/mtd/spi/sf_internal.h > @@ -99,6 +99,6 @@ int spi_flash_cmd_get_sw_write_prot(struct spi_flash > *flash); > > #ifdef CONFIG_SPI_FLASH_MTD > int spi_flash_mtd_register(struct spi_flash *flash); > -void spi_flash_mtd_unregister(void); > +void spi_flash_mtd_unregister(struct spi_flash *flash); > #endif > #endif /* _SF_INTERNAL_H_ */ > diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c > index 58d7e4439903..9c07ba3cadf7 100644 > --- a/drivers/mtd/spi/sf_mtd.c > +++ b/drivers/mtd/spi/sf_mtd.c > @@ -9,17 +9,15 @@ > #include <linux/mtd/mtd.h> > #include <spi_flash.h> > > -static struct mtd_info sf_mtd_info; > static char sf_mtd_name[8]; > > static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info > *instr) > { > - struct spi_flash *flash = mtd->priv; > int err; > > instr->state = MTD_ERASING; > > - err = spi_flash_erase(flash, instr->addr, instr->len); > + err = mtd->_erase(mtd, instr);
Please don't dereference mtd hooks directly. I'm pretty sure the mtd_erase() overhead is negligible, and if it's not, you can implement dummy wrappers for the SPL case to reduce it to zero. _______________________________________________ U-Boot mailing list [email protected] https://lists.denx.de/listinfo/u-boot

