[U-Boot] [PATCH v6 18/23] dm-sf: use mtd_ops, drop dm_spi_flash_ops
Jagan Teki
jteki at openedev.com
Sat Nov 7 14:46:32 CET 2015
Since mtd_info ops got introduced, just drop the unneeded
dm_spi_flash operations.
Reviewed-by: Heiko Schocher <hs at denx.de>
Signed-off-by: Jagan Teki <jteki at openedev.com>
---
drivers/mtd/spi/sf-uclass.c | 16 --------
drivers/mtd/spi/sf_probe.c | 30 ---------------
include/spi_flash.h | 90 +++++++--------------------------------------
3 files changed, 14 insertions(+), 122 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(sjg at 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 8e6de05..b9d1346 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 4051a35..5bb56b4 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
More information about the U-Boot
mailing list