From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Date: Tue, 4 Dec 2018 13:49:56 +0100 Subject: [U-Boot] [RFC PATCH v2 09/11] sf_mtd: Simply mtd operations In-Reply-To: <20181204122659.14720-10-vigneshr@ti.com> References: <20181204122659.14720-1-vigneshr@ti.com> <20181204122659.14720-10-vigneshr@ti.com> Message-ID: <20181204134956.15b0a834@bbrezillon> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, 4 Dec 2018 17:56:57 +0530 Vignesh R wrote: > Now that there is new SPI NOR framework, simplify mtd device > registration and read/write/erase operations. > > Signed-off-by: Vignesh R > --- > 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 > #include > > -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.