The do_write_oneword_done() is called twice at the exit paths. By splitting the retry functionality it can be reduced to call once. Signed-off-by: Tokunori Ikegami <ikegami_to@xxxxxxxxxxx> Cc: Fabio Bettoni <fbettoni@xxxxxxxxx> Co: Hauke Mehrtens <hauke@xxxxxxxxxx> Co: Koen Vandeputte <koen.vandeputte@xxxxxxxxxxxx> Cc: Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx> Cc: Joakim Tjernlund <Joakim.Tjernlund@xxxxxxxxxxxx> Cc: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxxxxxxx> Cc: linux-mtd@xxxxxxxxxxxxxxxxxxx --- Changes since v3: - Just change the email address of Tokunori Ikegami to ikegami_to@xxxxxxxxxxx. Changes since v2: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 39 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index da48b4c..21ba6d6 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1643,25 +1643,16 @@ static void __xipram do_write_oneword_done(struct map_info *map, mutex_unlock(&chip->mutex); } -static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, - unsigned long adr, map_word datum, - int mode) +static int __xipram do_write_oneword_retry(struct map_info *map, + struct flchip *chip, + unsigned long adr, map_word datum, + int mode) { struct cfi_private *cfi = map->fldrv_priv; int ret = 0; map_word oldd; int retry_cnt = 0; - adr += chip->start; - - pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, - datum.x[0]); - - ret = do_write_oneword_start(map, chip, adr, mode); - if (ret) { - return ret; - } - /* * Check for a NOP for the case when the datum to write is already * present - it saves time and works around buggy chips that corrupt @@ -1671,7 +1662,6 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, oldd = map_read(map, adr); if (map_word_equal(map, oldd, datum)) { pr_debug("MTD %s(): NOP\n", __func__); - do_write_oneword_done(map, chip, adr, mode); return ret; } @@ -1691,6 +1681,27 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, } xip_enable(map, chip, adr); + return ret; +} + +static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, + unsigned long adr, map_word datum, + int mode) +{ + int ret = 0; + + adr += chip->start; + + pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, + datum.x[0]); + + ret = do_write_oneword_start(map, chip, adr, mode); + if (ret) { + return ret; + } + + ret = do_write_oneword_retry(map, chip, adr, datum, mode); + do_write_oneword_done(map, chip, adr, mode); return ret; -- 2.11.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/