mtd/drivers/mtd/chips jedec_probe.c,1.41,1.42

David Woodhouse dwmw2 at infradead.org
Sun Nov 16 18:03:42 EST 2003


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

Modified Files:
	jedec_probe.c 
Log Message:
Don't probe with unlock at unaligned addresses

Index: jedec_probe.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec_probe.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- jedec_probe.c	16 Nov 2003 22:22:20 -0000	1.41
+++ jedec_probe.c	16 Nov 2003 23:03:39 -0000	1.42
@@ -1583,6 +1583,7 @@
 	int rc = 0;           /* failure until all tests pass */
 	u32 mfr, id;
 	__u8 uaddr;
+	unsigned long mask;
 
 	/*
 	 * The IDs must match.  For X16 and X32 devices operating in
@@ -1629,20 +1630,22 @@
 	}
 
 	uaddr = finfo_uaddr(finfo, cfi->device_type);
-	if ( MTD_UADDR_NOT_SUPPORTED ) {
+	if ( uaddr == MTD_UADDR_NOT_SUPPORTED ) {
 		goto match_done;
 	}
 
+	mask = ~((1<<cfi->device_type)-1);
+
 	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): check unlock addrs 0x%.4x 0x%.4x\n",
 	       __func__, cfi->addr_unlock1, cfi->addr_unlock2 );
 	if ( MTD_UADDR_UNNECESSARY != uaddr && MTD_UADDR_DONT_CARE != uaddr
-	     && ( unlock_addrs[uaddr].addr1 != cfi->addr_unlock1
-		  || unlock_addrs[uaddr].addr2 != cfi->addr_unlock2 ) ) {
+	     && ( (unlock_addrs[uaddr].addr1 & mask) != cfi->addr_unlock1 ||
+		  (unlock_addrs[uaddr].addr2 & mask) != cfi->addr_unlock2 ) ) {
 		DEBUG( MTD_DEBUG_LEVEL3,
 		       "MTD %s(): 0x%.4x 0x%.4x did not match\n",
 		       __func__,
-		       unlock_addrs[uaddr].addr1,
-		       unlock_addrs[uaddr].addr2 );
+		       unlock_addrs[uaddr].addr1 & mask,
+		       unlock_addrs[uaddr].addr2 & mask);
 		goto match_done;
 	}
 
@@ -1697,13 +1700,16 @@
 
  retry:
 	if (!cfi->numchips) {
+		unsigned long mask = ~((1<<cfi->device_type)-1);
+
 		uaddr_idx++;
 
 		if (MTD_UADDR_UNNECESSARY == uaddr_idx)
 			return 0;
 
-		cfi->addr_unlock1 = unlock_addrs[uaddr_idx].addr1;
-		cfi->addr_unlock2 = unlock_addrs[uaddr_idx].addr2;
+		/* Mask out address bits which are smaller than the device type */
+		cfi->addr_unlock1 = unlock_addrs[uaddr_idx].addr1 & mask;
+		cfi->addr_unlock2 = unlock_addrs[uaddr_idx].addr2 & mask;
 	}
 
 	/* Make certain we aren't probing past the end of map */




More information about the linux-mtd-cvs mailing list