Skip to contentSkip to conversation

CFI: remove major/minor version check for command set 0x0002

PATCH In review Wolfgang Grandegger 3 participants 8 messages Jan 8, 2009 – Jan 9, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CFI: remove major/minor version check for command set 0x0002

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

---
 drivers/mtd/chips/cfi_cmdset_0002.c |   10 ----------
 1 file changed, 10 deletions(-)
drivers/mtd/chips/cfi_cmdset_0002.c +0 -10
Index: linux-2.6/drivers/mtd/chips/cfi_cmdset_0002.c
===================================================================
@@ -363,16 +363,6 @@ struct mtd_info *cfi_cmdset_0002(struct 
 			return NULL;
 		}
 
-		if (extp->MajorVersion != '1' ||
-		    (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
-			printk(KERN_ERR "  Unknown Amd/Fujitsu Extended Query "
-			       "version %c.%c.\n",  extp->MajorVersion,
-			       extp->MinorVersion);
-			kfree(extp);
-			kfree(mtd);
-			return NULL;
-		}
-
 		/* Install our own private info structure */
 		cfi->cmdset_priv = extp;
 
#1 lore raw
Quoted 4 lines · Wolfgang Grandegger

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

Instead of removing the test entirely, I'd suggest you augment it with the manufacturer ID (cfi->mfr and cfi->id). Or better yet, just use that information to fix up the version number to something sensible.

Nicolas

#2 lore raw
Quoted 8 lines · Nicolas Pitre
Quoted 4 lines

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

Instead of removing the test entirely, I'd suggest you augment it with the manufacturer ID (cfi->mfr and cfi->id). Or better yet, just use that information to fix up the version number to something sensible.

Couldn't you use a quirk to do the latter?

Signature · 1 line
dwmw2
#3 lore raw
Quoted 10 lines · David Woodhouse
Quoted 7 lines · Nicolas Pitre
Quoted 4 lines

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

Instead of removing the test entirely, I'd suggest you augment it with the manufacturer ID (cfi->mfr and cfi->id). Or better yet, just use that information to fix up the version number to something sensible.

Couldn't you use a quirk to do the latter?

The major/minor version number is not used anywhere else and therefore a quirk seems to be overkill too me. But we may want to keep the message:

Unknown Amd/Fujitsu Extended Query version 0.0.

Wolfgang.

#4 lore raw
Quoted 6 lines · Wolfgang Grandegger
Quoted 5 lines · David Woodhouse
Quoted 4 lines · Nicolas Pitre
Quoted 4 lines

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Instead of removing the test entirely, I'd suggest you augment it with the manufacturer ID (cfi->mfr and cfi->id). Or better yet, just use that information to fix up the version number to something sensible.

Couldn't you use a quirk to do the latter?

The major/minor version number is not used anywhere else and therefore a quirk seems to be overkill too me.

Please look again. Searching for "MinorVersion" turns up a couple places.

A quirk is not overkill at all. To the contrary it's the whole purpose of quirks to fix up things like this.

Although, in this case, I think quirks are evaluated only after the CFI version is tested, meaning that the fixup might have to be done inline.

Nicolas

#5 lore raw
Quoted 12 lines · Nicolas Pitre
Quoted 10 lines · Wolfgang Grandegger
Quoted 9 lines · David Woodhouse
Quoted 7 lines · Nicolas Pitre
Quoted 4 lines

The NOR Flash memory K8P2815UQB from Samsung uses the major version number '0', which seems to be unusual but not illegal, IIUC. This patch removes the major-minor version check to get this Flash memory supported as well.

Instead of removing the test entirely, I'd suggest you augment it with the manufacturer ID (cfi->mfr and cfi->id). Or better yet, just use that information to fix up the version number to something sensible.

Couldn't you use a quirk to do the latter?

Quoted 8 lines
Quoted 2 lines

The major/minor version number is not used anywhere else and therefore a quirk seems to be overkill too me.

Please look again. Searching for "MinorVersion" turns up a couple places.

A quirk is not overkill at all. To the contrary it's the whole purpose of quirks to fix up things like this.

I see.

Quoted 2 lines

Although, in this case, I think quirks are evaluated only after the CFI version is tested, meaning that the fixup might have to be done inline.

Yep, the patch below introduces cfi_fixup_major_minor() to do the quirk. What do you think now?

Wolfgang.

---
 drivers/mtd/chips/cfi_cmdset_0002.c |   10 ++++++++++
 include/linux/mtd/cfi.h             |    1 +
 2 files changed, 11 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +10 -0
Index: linux-2.6/drivers/mtd/chips/cfi_cmdset_0002.c
===================================================================
@@ -322,6 +322,14 @@ static struct cfi_fixup fixup_table[] = 
 };
 
 
+static void cfi_fixup_major_minor(struct cfi_private *cfi, 
+				  struct cfi_pri_amdstd *extp)
+{
+	if (cfi->mfr == CFI_MFR_SAMSUNG && cfi->id == 0x257e &&
+	    extp->MajorVersion == '0')
+		extp->MajorVersion = '1';
+}
+
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
@@ -363,6 +371,8 @@ struct mtd_info *cfi_cmdset_0002(struct 
 			return NULL;
 		}
 
+		cfi_fixup_major_minor(cfi, extp);
+
 		if (extp->MajorVersion != '1' ||
 		    (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
 			printk(KERN_ERR "  Unknown Amd/Fujitsu Extended Query "
include/linux/mtd/cfi.h +1 -0
Index: linux-2.6/include/linux/mtd/cfi.h
===================================================================
@@ -520,6 +520,7 @@ struct cfi_fixup {
 
 #define CFI_MFR_AMD 0x0001
 #define CFI_MFR_ATMEL 0x001F
+#define CFI_MFR_SAMSUNG 0x00EC
 #define CFI_MFR_ST  0x0020 	/* STMicroelectronics */
 
 void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
#6 lore raw
Quoted 2 lines · Wolfgang Grandegger

Yep, the patch below introduces cfi_fixup_major_minor() to do the quirk. What do you think now?

Looks fine to me.

Quoted 49 lines

Wolfgang.

---
 drivers/mtd/chips/cfi_cmdset_0002.c |   10 ++++++++++
 include/linux/mtd/cfi.h             |    1 +
 2 files changed, 11 insertions(+)

Index: linux-2.6/drivers/mtd/chips/cfi_cmdset_0002.c
===================================================================

drivers/mtd/chips/cfi_cmdset_0002.c +10 -0
@@ -322,6 +322,14 @@ static struct cfi_fixup fixup_table[] = 
 };
 
 
+static void cfi_fixup_major_minor(struct cfi_private *cfi, 
+				  struct cfi_pri_amdstd *extp)
+{
+	if (cfi->mfr == CFI_MFR_SAMSUNG && cfi->id == 0x257e &&
+	    extp->MajorVersion == '0')
+		extp->MajorVersion = '1';
+}
+
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
@@ -363,6 +371,8 @@ struct mtd_info *cfi_cmdset_0002(struct 
 			return NULL;
 		}
 
+		cfi_fixup_major_minor(cfi, extp);
+
 		if (extp->MajorVersion != '1' ||
 		    (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
 			printk(KERN_ERR "  Unknown Amd/Fujitsu Extended Query "

Index: linux-2.6/include/linux/mtd/cfi.h
===================================================================

include/linux/mtd/cfi.h +1 -0
@@ -520,6 +520,7 @@ struct cfi_fixup {
 
 #define CFI_MFR_AMD 0x0001
 #define CFI_MFR_ATMEL 0x001F
+#define CFI_MFR_SAMSUNG 0x00EC
 #define CFI_MFR_ST  0x0020 	/* STMicroelectronics */
 
 void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
#7 lore raw
Quoted 6 lines · Nicolas Pitre
Quoted 2 lines · Wolfgang Grandegger

Yep, the patch below introduces cfi_fixup_major_minor() to do the quirk. What do you think now?

Looks fine to me.

I just resent the patch with a proper description.

Thanks,

Wolfgang.