Patchwork mtd: cfi_cmdset_0002: fix the check for valid primary extension versions

login
register
mail settings
Submitter Guillaume LECERF
Date Aug. 4, 2010, 7:36 p.m.
Message ID <20100804193242.10954.14837.stgit@dev.siriade.com>
Download mbox | patch
Permalink /patch/60892/
State New
Headers show

Comments

Guillaume LECERF - Aug. 4, 2010, 7:36 p.m.
Valid primary extension versions are: 1.0, 1.1, 1.2, 1.3, 1.4 [1][2][3].
Fix the check in cfi_cmdset_0002 accordingly.

[1] http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_r20.pdf, page 19
[2] http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_100_20011201.pdf
[3] http://www.spansion.com/Support/Datasheets/s29ws-p_00_a12_e.pdf

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Guillaume LECERF <glecerf@gmail.com>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
Artem Bityutskiy - Aug. 5, 2010, 6:07 a.m.
On Wed, 2010-08-04 at 21:36 +0200, Guillaume LECERF wrote:
> Valid primary extension versions are: 1.0, 1.1, 1.2, 1.3, 1.4 [1][2][3].
> Fix the check in cfi_cmdset_0002 accordingly.
> 
> [1] http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_r20.pdf, page 19
> [2] http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_100_20011201.pdf
> [3] http://www.spansion.com/Support/Datasheets/s29ws-p_00_a12_e.pdf
> 
> Signed-off-by: Florian Fainelli <florian@openwrt.org>
> Signed-off-by: Guillaume LECERF <glecerf@gmail.com>

Please, make it applicable to mtd-2.6.git / master tree and re-send.

Patch

diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index d81079e..16c4eee 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -417,16 +417,26 @@  struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 			 */
 			cfi_fixup_major_minor(cfi, extp);
 
+			/*
+			 * Valid primary extension versions are: 1.0, 1.1, 1.2, 1.3, 1.4
+			 * see: http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_r20.pdf, page 19
+			 *      http://www.amd.com/us-en/assets/content_type/DownloadableAssets/cfi_100_20011201.pdf
+			 *      http://www.spansion.com/Support/Datasheets/s29ws-p_00_a12_e.pdf
+			 */
 			if (extp->MajorVersion != '1' ||
-			    (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
+			    (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);
+				       "version %c.%c (%#02x/%#02x).\n",
+				       extp->MajorVersion, extp->MinorVersion,
+				       extp->MajorVersion, extp->MinorVersion);
 				kfree(extp);
 				kfree(mtd);
 				return NULL;
 			}
 
+			printk(KERN_INFO "  Amd/Fujitsu Extended Query version %c.%c.\n",
+			       extp->MajorVersion, extp->MinorVersion);
+
 			/* Install our own private info structure */
 			cfi->cmdset_priv = extp;