mtd: cfi_cmdset_0002: Split do_write_oneword() to reduce exit paths
The do_write_oneword_done() is called twice at the exit paths. By splitting the retry functionality it can be reduced to call once. Cc: Fabio Bettoni <fbettoni@gmail.com> Co: Hauke Mehrtens <hauke@hauke-m.de> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> Cc: Joakim Tjernlund <Joakim.Tjernlund@infinera.com> Cc: linux-mtd@lists.infradead.org Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
This commit is contained in:
parent
6beb3ea746
commit
0bcf880b06
|
@ -1739,25 +1739,16 @@ static void __xipram do_write_oneword_done(struct map_info *map,
|
||||||
mutex_unlock(&chip->mutex);
|
mutex_unlock(&chip->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
|
static int __xipram do_write_oneword_retry(struct map_info *map,
|
||||||
unsigned long adr, map_word datum,
|
struct flchip *chip,
|
||||||
int mode)
|
unsigned long adr, map_word datum,
|
||||||
|
int mode)
|
||||||
{
|
{
|
||||||
struct cfi_private *cfi = map->fldrv_priv;
|
struct cfi_private *cfi = map->fldrv_priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
map_word oldd;
|
map_word oldd;
|
||||||
int retry_cnt = 0;
|
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
|
* 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
|
* present - it saves time and works around buggy chips that corrupt
|
||||||
|
@ -1767,7 +1758,6 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
|
||||||
oldd = map_read(map, adr);
|
oldd = map_read(map, adr);
|
||||||
if (map_word_equal(map, oldd, datum)) {
|
if (map_word_equal(map, oldd, datum)) {
|
||||||
pr_debug("MTD %s(): NOP\n", __func__);
|
pr_debug("MTD %s(): NOP\n", __func__);
|
||||||
do_write_oneword_done(map, chip, adr, mode);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1790,6 +1780,26 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
|
||||||
}
|
}
|
||||||
xip_enable(map, chip, adr);
|
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);
|
do_write_oneword_done(map, chip, adr, mode);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue