diff options
author | Tokunori Ikegami <ikegami.t@gmail.com> | 2019-08-05 15:03:21 -0400 |
---|---|---|
committer | Vignesh Raghavendra <vigneshr@ti.com> | 2019-08-27 08:25:53 -0400 |
commit | 228c05c2d73e072b78d0c661c2d8717d0310ef35 (patch) | |
tree | ec6ae09bf0ac2095de2ef38270fdb47935189755 /drivers/mtd/chips | |
parent | a371ba57a205e7dd6b2ccb502a4ea009d6c010f7 (diff) |
mtd: cfi_cmdset_0002: Split do_write_oneword() op_done goto statement
To reduce function size and to remove the goto statement, split the
op_done goto statement part into do_write_oneword_done(). Also
split the start part into do_write_oneword_start() to be symmetrical.
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>
[vigneshr@ti.com: Reword commit message]
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0002.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 63d69fab4b32..d7e7a1a8cbdf 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -1705,6 +1705,40 @@ static int __xipram do_write_oneword_once(struct map_info *map, | |||
1705 | return ret; | 1705 | return ret; |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | static int __xipram do_write_oneword_start(struct map_info *map, | ||
1709 | struct flchip *chip, | ||
1710 | unsigned long adr, int mode) | ||
1711 | { | ||
1712 | int ret = 0; | ||
1713 | |||
1714 | mutex_lock(&chip->mutex); | ||
1715 | |||
1716 | ret = get_chip(map, chip, adr, mode); | ||
1717 | if (ret) { | ||
1718 | mutex_unlock(&chip->mutex); | ||
1719 | return ret; | ||
1720 | } | ||
1721 | |||
1722 | if (mode == FL_OTP_WRITE) | ||
1723 | otp_enter(map, chip, adr, map_bankwidth(map)); | ||
1724 | |||
1725 | return ret; | ||
1726 | } | ||
1727 | |||
1728 | static void __xipram do_write_oneword_done(struct map_info *map, | ||
1729 | struct flchip *chip, | ||
1730 | unsigned long adr, int mode) | ||
1731 | { | ||
1732 | if (mode == FL_OTP_WRITE) | ||
1733 | otp_exit(map, chip, adr, map_bankwidth(map)); | ||
1734 | |||
1735 | chip->state = FL_READY; | ||
1736 | DISABLE_VPP(map); | ||
1737 | put_chip(map, chip, adr); | ||
1738 | |||
1739 | mutex_unlock(&chip->mutex); | ||
1740 | } | ||
1741 | |||
1708 | static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | 1742 | static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, |
1709 | unsigned long adr, map_word datum, | 1743 | unsigned long adr, map_word datum, |
1710 | int mode) | 1744 | int mode) |
@@ -1716,19 +1750,14 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1716 | 1750 | ||
1717 | adr += chip->start; | 1751 | adr += chip->start; |
1718 | 1752 | ||
1719 | mutex_lock(&chip->mutex); | 1753 | pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", __func__, adr, |
1720 | ret = get_chip(map, chip, adr, mode); | 1754 | datum.x[0]); |
1755 | |||
1756 | ret = do_write_oneword_start(map, chip, adr, mode); | ||
1721 | if (ret) { | 1757 | if (ret) { |
1722 | mutex_unlock(&chip->mutex); | ||
1723 | return ret; | 1758 | return ret; |
1724 | } | 1759 | } |
1725 | 1760 | ||
1726 | pr_debug("MTD %s(): WRITE 0x%.8lx(0x%.8lx)\n", | ||
1727 | __func__, adr, datum.x[0]); | ||
1728 | |||
1729 | if (mode == FL_OTP_WRITE) | ||
1730 | otp_enter(map, chip, adr, map_bankwidth(map)); | ||
1731 | |||
1732 | /* | 1761 | /* |
1733 | * Check for a NOP for the case when the datum to write is already | 1762 | * Check for a NOP for the case when the datum to write is already |
1734 | * present - it saves time and works around buggy chips that corrupt | 1763 | * present - it saves time and works around buggy chips that corrupt |
@@ -1737,9 +1766,9 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1737 | */ | 1766 | */ |
1738 | oldd = map_read(map, adr); | 1767 | oldd = map_read(map, adr); |
1739 | if (map_word_equal(map, oldd, datum)) { | 1768 | if (map_word_equal(map, oldd, datum)) { |
1740 | pr_debug("MTD %s(): NOP\n", | 1769 | pr_debug("MTD %s(): NOP\n", __func__); |
1741 | __func__); | 1770 | do_write_oneword_done(map, chip, adr, mode); |
1742 | goto op_done; | 1771 | return ret; |
1743 | } | 1772 | } |
1744 | 1773 | ||
1745 | XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); | 1774 | XIP_INVAL_CACHED_RANGE(map, adr, map_bankwidth(map)); |
@@ -1760,13 +1789,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1760 | } | 1789 | } |
1761 | } | 1790 | } |
1762 | xip_enable(map, chip, adr); | 1791 | xip_enable(map, chip, adr); |
1763 | op_done: | 1792 | |
1764 | if (mode == FL_OTP_WRITE) | 1793 | do_write_oneword_done(map, chip, adr, mode); |
1765 | otp_exit(map, chip, adr, map_bankwidth(map)); | ||
1766 | chip->state = FL_READY; | ||
1767 | DISABLE_VPP(map); | ||
1768 | put_chip(map, chip, adr); | ||
1769 | mutex_unlock(&chip->mutex); | ||
1770 | 1794 | ||
1771 | return ret; | 1795 | return ret; |
1772 | } | 1796 | } |