Skip to contentSkip to conversation

Fix bug with the assumtion that cmdset_priv is always valid

PATCH Boris Itkis 1 participant 1 message Sep 30, 2002 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Jedec probe produces P_ID_INTEL_STD (semi cfi flash configuration) without cmdset_priv. So I fixed cfi_cmdset_0001.c to live with this by testing for cmdset_priv and working around the missing data.

Files affected:

drivers/mtd/chips/cfi_cmdset_0001.c

drivers/mtd/chips/cfi_cmdset_0001.c +10 -0
diff -urN linux-2.4.19/drivers/mtd/chips/cfi_cmdset_0001.c linux.orig/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -300,6 +300,8 @@
 	 */
 	switch (chip->state) {
 	case FL_ERASING:
+		if (!((struct cfi_pri_intelext *)cfi->cmdset_priv))
+			goto sleep; /* Must be in Jedec Mode so assume sleep */
 		if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2))
 			goto sleep; /* We don't support erase suspend */
 		
@@ -543,6 +545,14 @@
 	struct cfi_private *cfi = map->fldrv_priv;
 	struct cfi_pri_intelext *extp=cfi->cmdset_priv;
 	int base_offst,reg_sz;
+
+	if(!extp)
+	{
+		printk(KERN_WARNING
+			"%s: This flash devive is a Jedec Flash so no protection data to read!\n"
+			,map->name);
+		return 0;
+	}
 	
 	/* Check that we actually have some protection registers */
 	if(!(extp->FeatureSupport&64)){