mtd: bcm63xxpart: check version marker string for newer CFEs

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Jan 9 13:59:08 EST 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f2d9739b8e0bc9bdcc972950dd433b5083edf72f
Commit:     f2d9739b8e0bc9bdcc972950dd433b5083edf72f
Parent:     f9fbcdc357f37d6c82a75a89c64efbe8bd5274e1
Author:     Jonas Gorski <jonas.gorski at gmail.com>
AuthorDate: Sat Dec 17 13:58:14 2011 +0100
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Jan 9 18:19:00 2012 +0000

    mtd: bcm63xxpart: check version marker string for newer CFEs
    
    Recent CFEs do not contain the CFE1CFE1 magic anymore, so check for the
    "cfe-v" version marker string instead. As very old CFEs do not have
    this string, leave the CFE1CFE1 magic as a fallback for detection.
    
    Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/bcm63xxpart.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index ac7d3c8..9933b34 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -32,22 +32,34 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/mach-bcm63xx/bcm963xx_tag.h>
+#include <asm/mach-bcm63xx/board_bcm963xx.h>
 
 #define BCM63XX_EXTENDED_SIZE	0xBFC00000	/* Extended flash address */
 
+#define BCM63XX_CFE_MAGIC_OFFSET 0x4e0
+
 static int bcm63xx_detect_cfe(struct mtd_info *master)
 {
-	int idoffset = 0x4e0;
-	static char idstring[8] = "CFE1CFE1";
 	char buf[9];
 	int ret;
 	size_t retlen;
 
-	ret = master->read(master, idoffset, 8, &retlen, (void *)buf);
+	ret = master->read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen,
+			   (void *)buf);
+	buf[retlen] = 0;
+
+	if (ret)
+		return ret;
+
+	if (strncmp("cfe-v", buf, 5) == 0)
+		return 0;
+
+	/* very old CFE's do not have the cfe-v string, so check for magic */
+	ret = master->read(master, BCM63XX_CFE_MAGIC_OFFSET, 8, &retlen,
+			   (void *)buf);
 	buf[retlen] = 0;
-	pr_info("Read Signature value of %s\n", buf);
 
-	return strncmp(idstring, buf, 8);
+	return strncmp("CFE1CFE1", buf, 8);
 }
 
 static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,



More information about the linux-mtd-cvs mailing list