Since mtd_info ops got introduced, just drop the unneeded
dm_spi_flash operations.

Signed-off-by: Jagan Teki <jt...@openedev.com>
---
 drivers/mtd/spi/sf-uclass.c | 16 --------
 drivers/mtd/spi/sf_probe.c  | 30 ---------------
 include/spi_flash.h         | 91 +++++++--------------------------------------
 3 files changed, 14 insertions(+), 123 deletions(-)

diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 350e21a..5cdbd1b 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -11,22 +11,6 @@
 #include <dm/device-internal.h>
 #include "sf_internal.h"
 
-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
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index b8704e2..5e314e2 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -104,29 +104,6 @@ void spi_flash_free(struct spi_flash *flash)
 
 #else /* defined CONFIG_DM_SPI_FLASH */
 
-static int spi_flash_std_read(struct udevice *dev, u32 offset, size_t len,
-                             void *buf)
-{
-       struct spi_flash *flash = dev_get_uclass_priv(dev);
-
-       return flash->read(flash, offset, len, buf);
-}
-
-int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len,
-                       const void *buf)
-{
-       struct spi_flash *flash = dev_get_uclass_priv(dev);
-
-       return flash->write(flash, offset, len, buf);
-}
-
-int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
-{
-       struct spi_flash *flash = dev_get_uclass_priv(dev);
-
-       return flash->erase(flash, offset, len);
-}
-
 int spi_flash_std_probe(struct udevice *dev)
 {
        struct spi_flash_priv *priv = dev_get_uclass_priv(dev);
@@ -171,12 +148,6 @@ err_scan:
        return ret;
 }
 
-static const struct dm_spi_flash_ops spi_flash_std_ops = {
-       .read = spi_flash_std_read,
-       .write = spi_flash_std_write,
-       .erase = spi_flash_std_erase,
-};
-
 static const struct udevice_id spi_flash_std_ids[] = {
        { .compatible = "spi-flash" },
        { }
@@ -188,7 +159,6 @@ U_BOOT_DRIVER(spi_flash_std) = {
        .of_match       = spi_flash_std_ids,
        .probe          = spi_flash_std_probe,
        .priv_auto_alloc_size = sizeof(struct spi_flash_priv),
-       .ops            = &spi_flash_std_ops,
 };
 
 #endif /* CONFIG_DM_SPI_FLASH */
diff --git a/include/spi_flash.h b/include/spi_flash.h
index fe03b8d..8dd000d 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -83,52 +83,7 @@ struct spi_flash {
        void *priv;
 };
 
-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);
@@ -142,31 +97,6 @@ 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)
-{
-       return mtd_read(flash->mtd, offset, len, &len, (u_char *)buf);
-}
-
-static inline int spi_flash_write(struct spi_flash *flash, u32 offset,
-                                 size_t len, const void *buf)
-{
-       return mtd_write(flash->mtd, offset, len, &len, (u_char *)buf);
-}
-
-static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
-                                 size_t len)
-{
-       struct erase_info instr;
-
-       instr.mtd = flash->mtd;
-       instr.addr = offset;
-       instr.len = len;
-       instr.callback = 0;
-
-       return mtd_erase(flash->mtd, &instr);
-}
-
 struct sandbox_state;
 
 int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
@@ -191,25 +121,32 @@ struct spi_flash *spi_flash_probe_fdt(const void *blob, 
int slave_node,
                                      int spi_node);
 
 void spi_flash_free(struct spi_flash *flash);
+#endif
 
 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
-               size_t len, void *buf)
+                                size_t len, void *buf)
 {
-       return flash->read(flash, offset, len, buf);
+       return mtd_read(flash->mtd, offset, len, &len, (u_char *)buf);
 }
 
 static inline int spi_flash_write(struct spi_flash *flash, u32 offset,
-               size_t len, const void *buf)
+                                 size_t len, const void *buf)
 {
-       return flash->write(flash, offset, len, buf);
+       return mtd_write(flash->mtd, offset, len, &len, (u_char *)buf);
 }
 
 static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
-               size_t len)
+                                 size_t len)
 {
-       return flash->erase(flash, offset, len);
+       struct erase_info instr;
+
+       instr.mtd = flash->mtd;
+       instr.addr = offset;
+       instr.len = len;
+       instr.callback = 0;
+
+       return mtd_erase(flash->mtd, &instr);
 }
-#endif
 
 void spi_boot(void) __noreturn;
 void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst);
-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to