From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Wed, 5 Dec 2018 09:27:29 +0100 Subject: [U-Boot] [RFC PATCH v2 09/11] sf_mtd: Simply mtd operations In-Reply-To: <7a7e5492-0528-7dad-29cb-2c679ad0193b@ti.com> References: <20181204122659.14720-1-vigneshr@ti.com> <20181204122659.14720-10-vigneshr@ti.com> <20181204134956.15b0a834@bbrezillon> <7a7e5492-0528-7dad-29cb-2c679ad0193b@ti.com> Message-ID: <20181205092729.16c03631@xps13> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi Vignesh, Vignesh R wrote on Wed, 5 Dec 2018 13:30:27 +0530: > Hi Boris, >=20 > On 04/12/18 6:19 PM, Boris Brezillon wrote: > > On Tue, 4 Dec 2018 17:56:57 +0530 > > Vignesh R wrote: > > =20 > >> 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_intern= al.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); > >> =20 > >> #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 > >> =20 > >> -static struct mtd_info sf_mtd_info; > >> static char sf_mtd_name[8]; > >> =20 > >> static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_inf= o *instr) > >> { > >> - struct spi_flash *flash =3D mtd->priv; > >> int err; > >> =20 > >> instr->state =3D MTD_ERASING; > >> =20 > >> - err =3D spi_flash_erase(flash, instr->addr, instr->len); > >> + err =3D mtd->_erase(mtd, instr); =20 > >=20 > > 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. > > =20 >=20 > I did start with mtd_* APIs here. But, ended up with bunch of patches > just to get MTD configs in shape to satisfy compile time dependencies. > I will send a patch to use mtd_* APIs here once Miquel's MTD config > cleanups are in. Thanks for the review! >=20 As an FYI, it took me more than 30 Travis builds to get the MTD Kconfigs/Makefiles (+ defconfigs) in shape :) To find faulty configurations (for example, configurations using CONFIG_SPI_FLASH_MTD but without enabling CONFIG_MTD) I wrote a small script just to open these files automatically. As a reference if someone wants to use/improve it, it is there [1]. [1] http://code.bulix.org/4ep8u5-518535 Thanks, Miqu=C3=A8l