mtd/drivers/mtd/chips cfi_cmdset_0001.c,1.139,1.140

Nicolas Pitre nico at infradead.org
Sun Jun 6 23:18:16 EDT 2004


Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv15931/drivers/mtd/chips

Modified Files:
	cfi_cmdset_0001.c 
Log Message:
proper fix for the cache invalidation in the erase case.


Index: cfi_cmdset_0001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0001.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- cfi_cmdset_0001.c	7 Jun 2004 02:01:01 -0000	1.139
+++ cfi_cmdset_0001.c	7 Jun 2004 03:18:13 -0000	1.140
@@ -1218,7 +1218,7 @@
 }
 
 typedef int (*varsize_frob_t)(struct map_info *map, struct flchip *chip,
-			      unsigned long adr, void *thunk);
+			      unsigned long adr, int len, void *thunk);
 
 static int cfi_intelext_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
 				     loff_t ofs, size_t len, void *thunk)
@@ -1285,15 +1285,19 @@
 	i=first;
 
 	while(len) {
-		ret = (*frob)(map, &cfi->chips[chipnum], adr, thunk);
+		unsigned long chipmask;
+		int size = regions[i].erasesize;
+
+		ret = (*frob)(map, &cfi->chips[chipnum], adr, size, thunk);
 		
 		if (ret)
 			return ret;
 
-		adr += regions[i].erasesize;
-		len -= regions[i].erasesize;
+		adr += size;
+		len -= size;
 
-		if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
+		chipmask = (1 << cfi->chipshift) - 1;
+		if ((adr & chipmask) == ((regions[i].offset + size * regions[i].numblocks) & chipmask))
 			i++;
 
 		if (adr >> cfi->chipshift) {
@@ -1309,7 +1313,8 @@
 }
 
 
-static int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, void *thunk)
+static int do_erase_oneblock(struct map_info *map, struct flchip *chip,
+			     unsigned long adr, int len, void *thunk)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	cfi_word status, status_OK;
@@ -1342,8 +1347,7 @@
 	chip->erase_suspended = 0;
 
 	spin_unlock(chip->mutex);
-	/* unfortunately the erase block size isn't available here */
-	/*INVALIDATE_CACHED_RANGE(map, adr, mtd->erasesize);*/
+	INVALIDATE_CACHED_RANGE(map, adr, len);
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout((chip->erase_time*HZ)/(2*1000));
 	spin_lock(chip->mutex);
@@ -1457,9 +1461,6 @@
 	if (ret)
 		return ret;
 
-	/* ideally this should be handled down in do_erase_oneblock instead */
-	INVALIDATE_CACHED_RANGE(((struct map_info *)mtd->priv), ofs, len);
-
 	instr->state = MTD_ERASE_DONE;
 	if (instr->callback)
 		instr->callback(instr);
@@ -1508,7 +1509,8 @@
 }
 
 #ifdef DEBUG_LOCK_BITS
-static int do_printlockstatus_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, void *thunk)
+static int do_printlockstatus_oneblock(struct map_info *map, struct flchip *chip,
+				       unsigned long adr, int len, void *thunk)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	int ofs_factor = cfi->interleave * cfi->device_type;
@@ -1524,7 +1526,8 @@
 #define DO_XXLOCK_ONEBLOCK_LOCK		((void *) 1)
 #define DO_XXLOCK_ONEBLOCK_UNLOCK	((void *) 2)
 
-static int do_xxlock_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr, void *thunk)
+static int do_xxlock_oneblock(struct map_info *map, struct flchip *chip,
+			      unsigned long adr, int len, void *thunk)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
 	cfi_word status, status_OK;





More information about the linux-mtd-cvs mailing list