Since mtd_info ops got introduced, just drop the unneeded dm_spi_flash operations.
Reviewed-by: Heiko Schocher <h...@denx.de> Signed-off-by: Jagan Teki <jt...@openedev.com> --- drivers/mtd/spi/sf-uclass.c | 39 -------------------- include/spi_flash.h | 90 +++++++-------------------------------------- 2 files changed, 14 insertions(+), 115 deletions(-) diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index 72e0f6b..5cdbd1b 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -11,24 +11,6 @@ #include <dm/device-internal.h> #include "sf_internal.h" -DECLARE_GLOBAL_DATA_PTR; - -int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf) -{ - return sf_get_ops(dev)->read(dev, offset, len, buf); -} - -int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len, - const void *buf) -{ - return sf_get_ops(dev)->write(dev, offset, len, buf); -} - -int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len) -{ - return sf_get_ops(dev)->erase(dev, offset, len); -} - /* * TODO(s...@chromium.org): This is an old-style function. We should remove * it when all SPI flash drivers use dm @@ -74,29 +56,8 @@ int spi_flash_remove(struct udevice *dev) return device_remove(dev); } -static int spi_flash_post_bind(struct udevice *dev) -{ -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct dm_spi_flash_ops *ops = sf_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->read) - ops->read += gd->reloc_off; - if (ops->write) - ops->write += gd->reloc_off; - if (ops->erase) - ops->erase += gd->reloc_off; - - reloc_done++; - } -#endif - return 0; -} - UCLASS_DRIVER(spi_flash) = { .id = UCLASS_SPI_FLASH, .name = "spi_flash", - .post_bind = spi_flash_post_bind, .per_device_auto_alloc_size = sizeof(struct spi_flash), }; diff --git a/include/spi_flash.h b/include/spi_flash.h index d66a8ec..dd48c97 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -91,65 +91,6 @@ struct spi_flash { int (*flash_is_locked)(struct spi_flash *flash, u32 ofs, size_t len); }; -struct dm_spi_flash_ops { - int (*read)(struct udevice *dev, u32 offset, size_t len, void *buf); - int (*write)(struct udevice *dev, u32 offset, size_t len, - const void *buf); - int (*erase)(struct udevice *dev, u32 offset, size_t len); -}; - -/* Access the serial operations for a device */ -#define sf_get_ops(dev) ((struct dm_spi_flash_ops *)(dev)->driver->ops) - -#ifdef CONFIG_DM_SPI_FLASH -/** - * spi_flash_read_dm() - Read data from SPI flash - * - * @dev: SPI flash device - * @offset: Offset into device in bytes to read from - * @len: Number of bytes to read - * @buf: Buffer to put the data that is read - * @return 0 if OK, -ve on error - */ -int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf); - -/** - * spi_flash_write_dm() - Write data to SPI flash - * - * @dev: SPI flash device - * @offset: Offset into device in bytes to write to - * @len: Number of bytes to write - * @buf: Buffer containing bytes to write - * @return 0 if OK, -ve on error - */ -int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len, - const void *buf); - -/** - * spi_flash_erase_dm() - Erase blocks of the SPI flash - * - * Note that @len must be a muiltiple of the flash sector size. - * - * @dev: SPI flash device - * @offset: Offset into device in bytes to start erasing - * @len: Number of bytes to erase - * @return 0 if OK, -ve on error - */ -int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len); - -int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, - unsigned int max_hz, unsigned int spi_mode, - struct udevice **devp); - -/* Compatibility function - this is the old U-Boot API */ -struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, - unsigned int max_hz, unsigned int spi_mode); - -/* Compatibility function - this is the old U-Boot API */ -void spi_flash_free(struct spi_flash *flash); - -int spi_flash_remove(struct udevice *flash); - static inline int spi_flash_read(struct spi_flash *flash, u32 offset, size_t len, void *buf) { @@ -175,6 +116,20 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, return mtd_erase(flash->mtd, &instr); } +#ifdef CONFIG_DM_SPI_FLASH +int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, + unsigned int max_hz, unsigned int spi_mode, + struct udevice **devp); + +/* Compatibility function - this is the old U-Boot API */ +struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int spi_mode); + +/* Compatibility function - this is the old U-Boot API */ +void spi_flash_free(struct spi_flash *flash); + +int spi_flash_remove(struct udevice *flash); + struct sandbox_state; int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs, @@ -200,23 +155,6 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node, void spi_flash_free(struct spi_flash *flash); -static inline int spi_flash_read(struct spi_flash *flash, u32 offset, - size_t len, void *buf) -{ - return flash->read(flash, offset, len, buf); -} - -static inline int spi_flash_write(struct spi_flash *flash, u32 offset, - size_t len, const void *buf) -{ - return flash->write(flash, offset, len, buf); -} - -static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, - size_t len) -{ - return flash->erase(flash, offset, len); -} #endif static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len, -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot