diff options
author | Boris Brezillon | 2018-02-12 22:03:11 +0100 |
---|---|---|
committer | Boris Brezillon | 2018-03-21 09:50:56 +0100 |
commit | e7bfb3fdbde3bfeeeb64e2d73ac6babe59519c9e (patch) | |
tree | f8aaed7657f3b7af86cdf2b5eade135e0f9f740b /drivers/mtd/devices | |
parent | 8f347c4232d5fc097599b711a3385722a6834005 (diff) |
mtd: Stop updating erase_info->state and calling mtd_erase_callback()
MTD users are no longer checking erase_info->state to determine if the
erase operation failed or succeeded. Moreover, mtd_erase_callback() is
now a NOP.
We can safely get rid of all mtd_erase_callback() calls and all
erase_info->state assignments. While at it, get rid of the
erase_info->state field, all MTD_ERASE_XXX definitions and the
mtd_erase_callback() function.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Bert Kenward <bkenward@solarflare.com>
---
Changes in v2:
- Address a few coding style issues (reported by Miquel)
- Remove comments that are no longer valid (reported by Miquel)
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/bcm47xxsflash.c | 9 | ||||
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 7 | ||||
-rw-r--r-- | drivers/mtd/devices/docg3.c | 16 | ||||
-rw-r--r-- | drivers/mtd/devices/lart.c | 6 | ||||
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 4 | ||||
-rw-r--r-- | drivers/mtd/devices/mtdram.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/phram.c | 7 | ||||
-rw-r--r-- | drivers/mtd/devices/pmc551.c | 2 | ||||
-rw-r--r-- | drivers/mtd/devices/powernv_flash.c | 12 | ||||
-rw-r--r-- | drivers/mtd/devices/slram.c | 7 | ||||
-rw-r--r-- | drivers/mtd/devices/spear_smi.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/st_spi_fsm.c | 4 |
13 files changed, 8 insertions, 75 deletions
diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c index 6b84947cfbea..9baa81b8780c 100644 --- a/drivers/mtd/devices/bcm47xxsflash.c +++ b/drivers/mtd/devices/bcm47xxsflash.c @@ -68,7 +68,6 @@ static int bcm47xxsflash_poll(struct bcm47xxsflash *b47s, int timeout) static int bcm47xxsflash_erase(struct mtd_info *mtd, struct erase_info *erase) { struct bcm47xxsflash *b47s = mtd->priv; - int err; switch (b47s->type) { case BCM47XXSFLASH_TYPE_ST: @@ -89,13 +88,7 @@ static int bcm47xxsflash_erase(struct mtd_info *mtd, struct erase_info *erase) break; } - err = bcm47xxsflash_poll(b47s, HZ); - if (err) - erase->state = MTD_ERASE_FAILED; - else - erase->state = MTD_ERASE_DONE; - - return err; + return bcm47xxsflash_poll(b47s, HZ); } static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len, diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index bb0734600a07..c9e424993e37 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -88,17 +88,12 @@ static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr) size_t len = instr->len; int err; - instr->state = MTD_ERASING; mutex_lock(&dev->write_mutex); err = _block2mtd_erase(dev, from, len); mutex_unlock(&dev->write_mutex); - if (err) { + if (err) pr_err("erase failed err = %d\n", err); - instr->state = MTD_ERASE_FAILED; - } else - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return err; } diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index a85af236b44d..c594fe5eac08 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c @@ -1191,39 +1191,27 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *info) { struct docg3 *docg3 = mtd->priv; uint64_t len; - int block0, block1, page, ret, ofs = 0; + int block0, block1, page, ret = 0, ofs = 0; doc_dbg("doc_erase(from=%lld, len=%lld\n", info->addr, info->len); - info->state = MTD_ERASE_PENDING; calc_block_sector(info->addr + info->len, &block0, &block1, &page, &ofs, docg3->reliable); - ret = -EINVAL; if (info->addr + info->len > mtd->size || page || ofs) - goto reset_err; + return -EINVAL; - ret = 0; calc_block_sector(info->addr, &block0, &block1, &page, &ofs, docg3->reliable); mutex_lock(&docg3->cascade->lock); doc_set_device_id(docg3, docg3->device_id); doc_set_reliable_mode(docg3); for (len = info->len; !ret && len > 0; len -= mtd->erasesize) { - info->state = MTD_ERASING; ret = doc_erase_block(docg3, block0, block1); block0 += 2; block1 += 2; } mutex_unlock(&docg3->cascade->lock); - if (ret) - goto reset_err; - - info->state = MTD_ERASE_DONE; - return 0; - -reset_err: - info->state = MTD_ERASE_FAILED; return ret; } diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c index 555b94406e0b..f67b653c17d7 100644 --- a/drivers/mtd/devices/lart.c +++ b/drivers/mtd/devices/lart.c @@ -414,10 +414,7 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr) while (len) { if (!erase_block (addr)) - { - instr->state = MTD_ERASE_FAILED; return (-EIO); - } addr += mtd->eraseregions[i].erasesize; len -= mtd->eraseregions[i].erasesize; @@ -425,9 +422,6 @@ static int flash_erase (struct mtd_info *mtd,struct erase_info *instr) if (addr == mtd->eraseregions[i].offset + (mtd->eraseregions[i].erasesize * mtd->eraseregions[i].numblocks)) i++; } - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); - return (0); } diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index 5dc8bd042cc5..aaaeaae01e1d 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -220,10 +220,6 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) } mutex_unlock(&priv->lock); - /* Inform MTD subsystem that erase is complete */ - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); - return 0; } diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 0bf4aeaf0cb8..46238796145f 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -60,8 +60,7 @@ static int ram_erase(struct mtd_info *mtd, struct erase_info *instr) if (check_offs_len(mtd, instr->addr, instr->len)) return -EINVAL; memset((char *)mtd->priv + instr->addr, 0xff, instr->len); - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); + return 0; } diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 7287696a21f9..9ee04b5f9311 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -39,13 +39,6 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) memset(start + instr->addr, 0xff, instr->len); - /* - * This'll catch a few races. Free the thing before returning :) - * I don't feel at all ashamed. This kind of thing is possible anyway - * with flash, but unlikely. - */ - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index cadea0620cd0..5d842cbca3de 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c @@ -184,12 +184,10 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) } out: - instr->state = MTD_ERASE_DONE; #ifdef CONFIG_MTD_PMC551_DEBUG printk(KERN_DEBUG "pmc551_erase() done\n"); #endif - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/devices/powernv_flash.c b/drivers/mtd/devices/powernv_flash.c index 26f9feaa5d17..c1312b141ae0 100644 --- a/drivers/mtd/devices/powernv_flash.c +++ b/drivers/mtd/devices/powernv_flash.c @@ -175,19 +175,11 @@ static int powernv_flash_erase(struct mtd_info *mtd, struct erase_info *erase) { int rc; - erase->state = MTD_ERASING; - - /* todo: register our own notifier to do a true async implementation */ rc = powernv_flash_async_op(mtd, FLASH_OP_ERASE, erase->addr, erase->len, NULL, NULL); - - if (rc) { + if (rc) erase->fail_addr = erase->addr; - erase->state = MTD_ERASE_FAILED; - } else { - erase->state = MTD_ERASE_DONE; - } - mtd_erase_callback(erase); + return rc; } diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 0ec85f316d24..10183ee4e12b 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c @@ -84,12 +84,7 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr) slram_priv_t *priv = mtd->priv; memset(priv->start + instr->addr, 0xff, instr->len); - /* This'll catch a few races. Free the thing before returning :) - * I don't feel at all ashamed. This kind of thing is possible anyway - * with flash, but unlikely. - */ - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); + return(0); } diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index ddf478976013..986f81d2f93e 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c @@ -518,7 +518,6 @@ static int spear_mtd_erase(struct mtd_info *mtd, struct erase_info *e_info) /* preparing the command for flash */ ret = spear_smi_erase_sector(dev, bank, command, 4); if (ret) { - e_info->state = MTD_ERASE_FAILED; mutex_unlock(&flash->lock); return ret; } @@ -527,8 +526,6 @@ static int spear_mtd_erase(struct mtd_info *mtd, struct erase_info *e_info) } mutex_unlock(&flash->lock); - e_info->state = MTD_ERASE_DONE; - mtd_erase_callback(e_info); return 0; } diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index 5b84d71efb36..1897f33fe3e7 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c @@ -195,7 +195,6 @@ static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr) err = sst25l_erase_sector(flash, addr); if (err) { mutex_unlock(&flash->lock); - instr->state = MTD_ERASE_FAILED; dev_err(&flash->spi->dev, "Erase failed\n"); return err; } @@ -205,8 +204,6 @@ static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr) mutex_unlock(&flash->lock); - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index a33f5fd6818c..55d4a77f3b7f 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -1825,13 +1825,9 @@ static int stfsm_mtd_erase(struct mtd_info *mtd, struct erase_info *instr) mutex_unlock(&fsm->lock); - instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); - return 0; out1: - instr->state = MTD_ERASE_FAILED; mutex_unlock(&fsm->lock); return ret; |