sf: unify write enable commands
authorMike Frysinger <vapier@gentoo.org>
Sat, 23 Apr 2011 23:05:55 +0000 (23:05 +0000)
committerWolfgang Denk <wd@denx.de>
Tue, 26 Jul 2011 14:28:21 +0000 (16:28 +0200)
Every spi flash uses the same write enable command, so unify this in
the common code.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
drivers/mtd/spi/eon.c
drivers/mtd/spi/macronix.c
drivers/mtd/spi/ramtron.c
drivers/mtd/spi/spansion.c
drivers/mtd/spi/spi_flash.c
drivers/mtd/spi/spi_flash_internal.h
drivers/mtd/spi/sst.c
drivers/mtd/spi/stmicro.c
drivers/mtd/spi/winbond.c

index e3de3aa..6826708 100644 (file)
@@ -91,7 +91,7 @@ static int eon_write(struct spi_flash *flash,
                    ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
                     buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
 
-               ret = spi_flash_cmd(flash->spi, CMD_EN25Q128_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        break;
index ff66f2a..8dacefe 100644 (file)
@@ -147,7 +147,7 @@ static int macronix_write(struct spi_flash *flash,
                    ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
                     buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
 
-               ret = spi_flash_cmd(flash->spi, CMD_MX25XX_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        break;
index 078d16c..27d4039 100644 (file)
@@ -198,7 +198,7 @@ static int ramtron_common(struct spi_flash *flash,
 
        if (command == CMD_RAMTRON_WRITE) {
                /* send WREN */
-               ret = spi_flash_cmd(flash->spi, CMD_RAMTRON_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        goto releasebus;
index a3401b3..fa4cca1 100644 (file)
@@ -168,7 +168,7 @@ static int spansion_write(struct spi_flash *flash,
                    ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
                     buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
 
-               ret = spi_flash_cmd(flash->spi, CMD_S25FLXX_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        break;
index 016b586..3e0d02d 100644 (file)
@@ -163,7 +163,7 @@ int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd,
                debug("SF: erase %2x %2x %2x %2x (%x)\n", cmd[0], cmd[1],
                      cmd[2], cmd[3], offset);
 
-               ret = spi_flash_cmd(flash->spi, CMD_WRITE_ENABLE, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret)
                        goto out;
 
index fc109ce..6665bed 100644 (file)
@@ -46,6 +46,14 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
                const void *data, size_t data_len);
 
 /*
+ * Enable writing on the SPI flash.
+ */
+static inline int spi_flash_cmd_write_enable(struct spi_flash *flash)
+{
+       return spi_flash_cmd(flash->spi, CMD_WRITE_ENABLE, NULL, 0);
+}
+
+/*
  * Same as spi_flash_cmd_read() except it also claims/releases the SPI
  * bus. Used as common part of the ->read() operation.
  */
index 4dc2db2..6691c1d 100644 (file)
@@ -96,7 +96,7 @@ static const struct sst_spi_flash_params sst_spi_flash_table[] = {
 static int
 sst_enable_writing(struct spi_flash *flash)
 {
-       int ret = spi_flash_cmd(flash->spi, CMD_SST_WREN, NULL, 0);
+       int ret = spi_flash_cmd_write_enable(flash);
        if (ret)
                debug("SF: Enabling Write failed\n");
        return ret;
index a1959ca..80d97b4 100644 (file)
@@ -169,7 +169,7 @@ static int stmicro_write(struct spi_flash *flash,
                    ("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %d\n",
                     buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
 
-               ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        break;
index e8d30ae..10fabf5 100644 (file)
@@ -140,7 +140,7 @@ static int winbond_write(struct spi_flash *flash,
                        buf + actual,
                        cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
 
-               ret = spi_flash_cmd(flash->spi, CMD_W25_WREN, NULL, 0);
+               ret = spi_flash_cmd_write_enable(flash);
                if (ret < 0) {
                        debug("SF: Enabling Write failed\n");
                        goto out;