summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/eon.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-01-10 02:20:13 -0500
committerWolfgang Denk <wd@denx.de>2011-04-11 21:00:54 +0200
commite7b44eddbef88b1a922f8d82088ba236aad01caf (patch)
tree4ba07d5e3ed3d4b9992afb6f2a47f556aa3d6741 /drivers/mtd/spi/eon.c
parent6163045bcd276818d9ad6bdd1bf36ddcd60d014b (diff)
sf: unify erase functions
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/mtd/spi/eon.c')
-rw-r--r--drivers/mtd/spi/eon.c55
1 files changed, 4 insertions, 51 deletions
diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c
index 4af1e068c3..0c0b05f010 100644
--- a/drivers/mtd/spi/eon.c
+++ b/drivers/mtd/spi/eon.c
@@ -141,58 +141,11 @@ static int eon_write(struct spi_flash *flash,
int eon_erase(struct spi_flash *flash, u32 offset, size_t len)
{
- /* block erase */
struct eon_spi_flash *eon = to_eon_spi_flash(flash);
- unsigned long block_size;
- size_t actual;
- int ret;
- u8 cmd[4];
-
-
- block_size = eon->params->page_size * eon->params->pages_per_sector
- * eon->params->sectors_per_block;
-
- if (offset % block_size || len % block_size) {
- debug("SF: Erase offset/length not multiple of block size\n");
- return -1;
- }
-
- len /= block_size;
- cmd[0] = CMD_EN25Q128_BE;
- cmd[2] = 0x00;
- cmd[3] = 0x00;
-
- ret = spi_claim_bus(flash->spi);
- if (ret) {
- debug("SF: Unable to claim SPI bus\n");
- return ret;
- }
-
- ret = 0;
- for (actual = 0; actual < len; actual++) {
- cmd[1] = (offset / block_size) + actual;
- ret = spi_flash_cmd(flash->spi, CMD_EN25Q128_WREN, NULL, 0);
- if (ret < 0) {
- debug("SF: Enabling Write failed\n");
- break;
- }
-
- ret = spi_flash_cmd_write(flash->spi, cmd, 4, NULL, 0);
- if (ret < 0) {
- debug("SF: EON page erase failed\n");
- break;
- }
-
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
- if (ret)
- break;
- }
-
- debug("SF: EON: Successfully erased %u bytes @ 0x%x\n",
- len * block_size, offset);
-
- spi_release_bus(flash->spi);
- return ret;
+ return spi_flash_cmd_erase(flash, CMD_EN25Q128_BE,
+ eon->params->page_size * eon->params->pages_per_sector *
+ eon->params->sectors_per_block;
+ offset, len);
}
struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)