diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c index e3de3aabbdff9d52868b4cc3796332cbecb6d388..682670892aae72145eef805b9ffa28dad5f04b86 100644 --- a/drivers/mtd/spi/eon.c +++ b/drivers/mtd/spi/eon.c @@ -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; diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index ff66f2aa35c03a522d91094b6d047b40ced13976..8dacefecb5d3ed3a49b5683a79f3521ee0c24df9 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -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; diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c index 078d16ce1bc6d5ec15ec1b15373c575ae51e2ac9..27d4039aadef64a0f0a2ab2f06774fe30a6caefc 100644 --- a/drivers/mtd/spi/ramtron.c +++ b/drivers/mtd/spi/ramtron.c @@ -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; diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c index a3401b32e18570ed58ca19dc8ad440d834a30434..fa4cca162df8ebffd40f8c5c8075156a113c2b65 100644 --- a/drivers/mtd/spi/spansion.c +++ b/drivers/mtd/spi/spansion.c @@ -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; diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 016b5865c2373a0144749e2bfffae71f527bfad0..3e0d02d5a6fc1744c3751b4b6e43b9d1db062eab 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -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; diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index fc109cef53e73eb62914d48f2b6d357284b673e2..6665bed199b45ff81a0cbdd494f9b32cebde4ef3 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -45,6 +45,14 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, 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. diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c index 4dc2db2ba7b83e4aa269b42780fa939f109b8702..6691c1de8d48a0043e6f1e707912219d050c2ade 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -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; diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index a1959ca984019c9ebcf54752911a9d730ab6cb21..80d97b4bba3fa266d96a042c74ecd310e3a7e6c3 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -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; diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index e8d30ae2b9d02933a812621e0cdb47511c931bba..10fabf5e33ee6040ffb8230ccea3f9f01ab9ece5 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -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;