[PATCH 2/6] mtd: chips: cfi_cmdset_0002: Match ENABLE_VPP()/DISABLE_VPP() calls

Paul Parsons lost.distance at yahoo.com
Wed Mar 7 09:11:16 EST 2012


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 at yahoo.com>
---
diff -uprN clean-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0002.c linux-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0002.c
--- clean-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0002.c	2012-03-04 01:08:09.000000000 +0000
+++ linux-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0002.c	2012-03-06 16:38:29.787134295 +0000
@@ -770,8 +770,6 @@ static void put_chip(struct map_info *ma
 
 	case FL_READY:
 	case FL_STATUS:
-		/* We should really make set_vpp() count, rather than doing this */
-		DISABLE_VPP(map);
 		break;
 	default:
 		printk(KERN_ERR "MTD: put_chip() called with oldstate %d!!\n", chip->oldstate);
@@ -1234,6 +1232,7 @@ static int __xipram do_write_oneword(str
 	xip_enable(map, chip, adr);
  op_done:
 	chip->state = FL_READY;
+	DISABLE_VPP(map);
 	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 
@@ -1476,6 +1475,7 @@ static int __xipram do_write_buffer(stru
 	ret = -EIO;
  op_done:
 	chip->state = FL_READY;
+	DISABLE_VPP(map);
 	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 
@@ -1649,6 +1649,7 @@ static int __xipram do_erase_chip(struct
 
 	chip->state = FL_READY;
 	xip_enable(map, chip, adr);
+	DISABLE_VPP(map);
 	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 
@@ -1739,6 +1740,7 @@ static int __xipram do_erase_oneblock(st
 	}
 
 	chip->state = FL_READY;
+	DISABLE_VPP(map);
 	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 	return ret;




More information about the linux-mtd mailing list