Commit 85e5b2f2986310f2f75069c360669f6ce8e2ceb9

Authored by Paul Parsons
Committed by David Woodhouse
1 parent 0c78e93b44

mtd: chips: cfi_cmdset_0001: Match ENABLE_VPP()/DISABLE_VPP() calls

This patch is part of a set which fixes unnecessary flash erase and write errors
resulting from the MTD CFI driver turning off vpp while an erase is in progress.
This patch ensures that only those flash operations which call ENABLE_VPP() can
then call DISABLE_VPP(). Other operations should never call DISABLE_VPP().

Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 1 changed file with 9 additions and 6 deletions Side-by-side Diff

drivers/mtd/chips/cfi_cmdset_0001.c
... ... @@ -1017,8 +1017,6 @@
1017 1017 case FL_READY:
1018 1018 case FL_STATUS:
1019 1019 case FL_JEDEC_QUERY:
1020   - /* We should really make set_vpp() count, rather than doing this */
1021   - DISABLE_VPP(map);
1022 1020 break;
1023 1021 default:
1024 1022 printk(KERN_ERR "%s: put_chip() called with oldstate %d!!\n", map->name, chip->oldstate);
... ... @@ -1552,7 +1550,8 @@
1552 1550 }
1553 1551  
1554 1552 xip_enable(map, chip, adr);
1555   - out: put_chip(map, chip, adr);
  1553 + out: DISABLE_VPP(map);
  1554 + put_chip(map, chip, adr);
1556 1555 mutex_unlock(&chip->mutex);
1557 1556 return ret;
1558 1557 }
... ... @@ -1791,7 +1790,8 @@
1791 1790 }
1792 1791  
1793 1792 xip_enable(map, chip, cmd_adr);
1794   - out: put_chip(map, chip, cmd_adr);
  1793 + out: DISABLE_VPP(map);
  1794 + put_chip(map, chip, cmd_adr);
1795 1795 mutex_unlock(&chip->mutex);
1796 1796 return ret;
1797 1797 }
... ... @@ -1928,6 +1928,7 @@
1928 1928 ret = -EIO;
1929 1929 } else if (chipstatus & 0x20 && retries--) {
1930 1930 printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus);
  1931 + DISABLE_VPP(map);
1931 1932 put_chip(map, chip, adr);
1932 1933 mutex_unlock(&chip->mutex);
1933 1934 goto retry;
... ... @@ -1940,7 +1941,8 @@
1940 1941 }
1941 1942  
1942 1943 xip_enable(map, chip, adr);
1943   - out: put_chip(map, chip, adr);
  1944 + out: DISABLE_VPP(map);
  1945 + put_chip(map, chip, adr);
1944 1946 mutex_unlock(&chip->mutex);
1945 1947 return ret;
1946 1948 }
... ... @@ -2082,7 +2084,8 @@
2082 2084 }
2083 2085  
2084 2086 xip_enable(map, chip, adr);
2085   -out: put_chip(map, chip, adr);
  2087 + out: DISABLE_VPP(map);
  2088 + put_chip(map, chip, adr);
2086 2089 mutex_unlock(&chip->mutex);
2087 2090 return ret;
2088 2091 }