[PATCH 1/6] mtd: chips: cfi_cmdset_0001: Match ENABLE_VPP()/DISABLE_VPP() calls

Paul Parsons lost.distance at yahoo.com
Wed Mar 7 09:10:33 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_0001.c linux-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0001.c
--- clean-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0001.c	2012-03-04 01:08:09.000000000 +0000
+++ linux-3.3-rc6/drivers/mtd/chips/cfi_cmdset_0001.c	2012-03-06 16:38:29.787134295 +0000
@@ -1017,8 +1017,6 @@ static void put_chip(struct map_info *ma
 	case FL_READY:
 	case FL_STATUS:
 	case FL_JEDEC_QUERY:
-		/* We should really make set_vpp() count, rather than doing this */
-		DISABLE_VPP(map);
 		break;
 	default:
 		printk(KERN_ERR "%s: put_chip() called with oldstate %d!!\n", map->name, chip->oldstate);
@@ -1551,7 +1549,8 @@ static int __xipram do_write_oneword(str
 	}
 
 	xip_enable(map, chip, adr);
- out:	put_chip(map, chip, adr);
+ out:	DISABLE_VPP(map);
+	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
@@ -1794,7 +1793,8 @@ static int __xipram do_write_buffer(stru
 	}
 
 	xip_enable(map, chip, cmd_adr);
- out:	put_chip(map, chip, cmd_adr);
+ out:	DISABLE_VPP(map);
+	put_chip(map, chip, cmd_adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
@@ -1932,6 +1932,7 @@ static int __xipram do_erase_oneblock(st
 			ret = -EIO;
 		} else if (chipstatus & 0x20 && retries--) {
 			printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus);
+			DISABLE_VPP(map);
 			put_chip(map, chip, adr);
 			mutex_unlock(&chip->mutex);
 			goto retry;
@@ -1944,7 +1945,8 @@ static int __xipram do_erase_oneblock(st
 	}
 
 	xip_enable(map, chip, adr);
- out:	put_chip(map, chip, adr);
+ out:	DISABLE_VPP(map);
+	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
@@ -2086,7 +2088,8 @@ static int __xipram do_xxlock_oneblock(s
 	}
 
 	xip_enable(map, chip, adr);
-out:	put_chip(map, chip, adr);
+ out:	DISABLE_VPP(map);
+	put_chip(map, chip, adr);
 	mutex_unlock(&chip->mutex);
 	return ret;
 }




More information about the linux-mtd mailing list