aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/devices/m25p80.c6
-rw-r--r--drivers/mtd/spi-nor/fsl-quadspi.c5
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c9
3 files changed, 6 insertions, 14 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index f5cb8d57bbd1..85e35467fba6 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -157,16 +157,10 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
157static int m25p80_erase(struct spi_nor *nor, loff_t offset) 157static int m25p80_erase(struct spi_nor *nor, loff_t offset)
158{ 158{
159 struct m25p *flash = nor->priv; 159 struct m25p *flash = nor->priv;
160 int ret;
161 160
162 dev_dbg(nor->dev, "%dKiB at 0x%08x\n", 161 dev_dbg(nor->dev, "%dKiB at 0x%08x\n",
163 flash->mtd.erasesize / 1024, (u32)offset); 162 flash->mtd.erasesize / 1024, (u32)offset);
164 163
165 /* Send write enable, then erase commands. */
166 ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0);
167 if (ret)
168 return ret;
169
170 /* Set up command buffer. */ 164 /* Set up command buffer. */
171 flash->command[0] = nor->erase_opcode; 165 flash->command[0] = nor->erase_opcode;
172 m25p_addr2cmd(nor, offset, flash->command); 166 m25p_addr2cmd(nor, offset, flash->command);
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 03dcffac8185..7f2ba8d946b5 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -738,11 +738,6 @@ static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs)
738 dev_dbg(nor->dev, "%dKiB at 0x%08x:0x%08x\n", 738 dev_dbg(nor->dev, "%dKiB at 0x%08x:0x%08x\n",
739 nor->mtd->erasesize / 1024, q->chip_base_addr, (u32)offs); 739 nor->mtd->erasesize / 1024, q->chip_base_addr, (u32)offs);
740 740
741 /* Send write enable, then erase commands. */
742 ret = nor->write_reg(nor, SPINOR_OP_WREN, NULL, 0, 0);
743 if (ret)
744 return ret;
745
746 ret = fsl_qspi_runcmd(q, nor->erase_opcode, offs, 0); 741 ret = fsl_qspi_runcmd(q, nor->erase_opcode, offs, 0);
747 if (ret) 742 if (ret)
748 return ret; 743 return ret;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1e08976ab028..0f4f2ba16e3e 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -265,9 +265,6 @@ static int erase_chip(struct spi_nor *nor)
265{ 265{
266 dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10)); 266 dev_dbg(nor->dev, " %lldKiB\n", (long long)(nor->mtd->size >> 10));
267 267
268 /* Send write enable, then erase commands. */
269 write_enable(nor);
270
271 return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0); 268 return nor->write_reg(nor, SPINOR_OP_CHIP_ERASE, NULL, 0, 0);
272} 269}
273 270
@@ -322,6 +319,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
322 319
323 /* whole-chip erase? */ 320 /* whole-chip erase? */
324 if (len == mtd->size) { 321 if (len == mtd->size) {
322 write_enable(nor);
323
325 if (erase_chip(nor)) { 324 if (erase_chip(nor)) {
326 ret = -EIO; 325 ret = -EIO;
327 goto erase_err; 326 goto erase_err;
@@ -339,6 +338,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
339 /* "sector"-at-a-time erase */ 338 /* "sector"-at-a-time erase */
340 } else { 339 } else {
341 while (len) { 340 while (len) {
341 write_enable(nor);
342
342 if (nor->erase(nor, addr)) { 343 if (nor->erase(nor, addr)) {
343 ret = -EIO; 344 ret = -EIO;
344 goto erase_err; 345 goto erase_err;
@@ -353,6 +354,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
353 } 354 }
354 } 355 }
355 356
357 write_disable(nor);
358
356 spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE); 359 spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_ERASE);
357 360
358 instr->state = MTD_ERASE_DONE; 361 instr->state = MTD_ERASE_DONE;