From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 18/23] dm-sf: use mtd_ops, drop dm_spi_flash_ops
Date: Sat, 7 Nov 2015 19:16:32 +0530 [thread overview]
Message-ID: <1446903997-1864-19-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1446903997-1864-1-git-send-email-jteki@openedev.com>
Since mtd_info ops got introduced, just drop the unneeded
dm_spi_flash operations.
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jagan Teki <jteki@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
next prev parent reply other threads:[~2015-11-07 13:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-07 13:46 [U-Boot] [PATCH v6 00/23] sf: MTD support Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 01/23] sf: spi_flash_validate_params => spi_flash_scan Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 02/23] sf: Move spi_flash_scan code to sf_ops Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 03/23] sf: Move read_id " Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 04/23] sf: probe: Code cleanup Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 05/23] sf: Use static for file-scope functions Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 06/23] sf: Fix Makefile Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 07/23] sf: Use simple name for register access functions Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 08/23] sf: Use flash function pointers in dm_spi_flash_ops Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 09/23] sf: Flash power up read-only based on idcode0 Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 10/23] sf: Use static for file-scope functions Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 11/23] sf: Remove unneeded header includes Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 12/23] sf: probe: Use spi_flash_scan in dm-spi-flash Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 13/23] sf: Re-factorize spi_flash_probe_tail code Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 14/23] dm-sf: Re-factorize spi_flash_std_probe code Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 15/23] sf: Add MTD support to spi_flash Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 16/23] sf: Use mtd_info ops instead of spi_flash ops Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 17/23] cmd_sf: Use mtd->size instead of flash->size Jagan Teki
2015-11-07 13:46 ` Jagan Teki [this message]
2015-11-07 13:46 ` [U-Boot] [PATCH v6 19/23] sf: Use MTD lock operations Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 20/23] sf: Add MTD support for non-dm spi_flash interface Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 21/23] sf: probe: Minor cleanup Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 22/23] sf: Drop SPI_FLASH_MTD driver Jagan Teki
2015-11-07 13:46 ` [U-Boot] [PATCH v6 23/23] configs: Remove CONFIG_SPI_FLASH_MTD Jagan Teki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446903997-1864-19-git-send-email-jteki@openedev.com \
--to=jteki@openedev.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox