Message ID | 20190526153904.28871-8-ikegami.t@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Vignesh R |
Headers | show |
Series | mtd: cfi_cmdset_0002: Fix flash write issue for OpenWrt Project | expand |
On 26-May-19 9:09 PM, Tokunori Ikegami wrote: > This is just to refactor the function by removing the goto statement. > Change to use the for loop instead of the goto statement. > This "retry: ... goto retry;" construct is consistently used across the file. Using goto to implement retry loops is common in kernel. Unless there is a better reason, lets not do this change. Regards Vignesh > Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com> > Cc: Fabio Bettoni <fbettoni@gmail.com> > Co: Hauke Mehrtens <hauke@hauke-m.de> > Co: Koen Vandeputte <koen.vandeputte@ncentric.com> > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> > Cc: Joakim Tjernlund <Joakim.Tjernlund@infinera.com> > Cc: linux-mtd@lists.infradead.org > --- > Changes since v5: > - Rebased on top of Liu Jian's fixes in master. > - Change the email address of Tokunori Ikegami to ikegami.t@gmail.com. > > Changes since v4: > - None. > > Changes since v3: > - Rebased. > - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. > > Changes since v2: > - None. > > Changes since v1: > - Add the patch. > > drivers/mtd/chips/cfi_cmdset_0002.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c > index 597b0f18269f..7784be8246cb 100755 > --- a/drivers/mtd/chips/cfi_cmdset_0002.c > +++ b/drivers/mtd/chips/cfi_cmdset_0002.c > @@ -1684,17 +1684,15 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, > ENABLE_VPP(map); > xip_disable(map, chip, adr); > > - retry: > - ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); > - if (ret) { > + for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { > + ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); > + if (!ret) > + break; > + > /* reset on all failures. */ > map_write(map, CMD(0xF0), chip->start); > - /* FIXME - should have reset delay before continuing */ > > - if (++retry_cnt <= MAX_RETRIES) { > - ret = 0; > - goto retry; > - } > + /* FIXME - should have reset delay before continuing */ > } > xip_enable(map, chip, adr); > >
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 597b0f18269f..7784be8246cb 100755 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1684,17 +1684,15 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, ENABLE_VPP(map); xip_disable(map, chip, adr); - retry: - ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); - if (ret) { + for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { + ret = do_write_oneword_once(map, chip, adr, datum, mode, cfi); + if (!ret) + break; + /* reset on all failures. */ map_write(map, CMD(0xF0), chip->start); - /* FIXME - should have reset delay before continuing */ - if (++retry_cnt <= MAX_RETRIES) { - ret = 0; - goto retry; - } + /* FIXME - should have reset delay before continuing */ } xip_enable(map, chip, adr);
This is just to refactor the function by removing the goto statement. Change to use the for loop instead of the goto statement. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com> Cc: Fabio Bettoni <fbettoni@gmail.com> Co: Hauke Mehrtens <hauke@hauke-m.de> Co: Koen Vandeputte <koen.vandeputte@ncentric.com> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> Cc: Joakim Tjernlund <Joakim.Tjernlund@infinera.com> Cc: linux-mtd@lists.infradead.org --- Changes since v5: - Rebased on top of Liu Jian's fixes in master. - Change the email address of Tokunori Ikegami to ikegami.t@gmail.com. Changes since v4: - None. Changes since v3: - Rebased. - Change the email address of Tokunori Ikegami to ikegami_to@yahoo.co.jp. Changes since v2: - None. Changes since v1: - Add the patch. drivers/mtd/chips/cfi_cmdset_0002.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)