From patchwork Sat Dec 17 12:58:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 131998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 91D3C1007DB for ; Sun, 18 Dec 2011 00:00:59 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Rbtqx-0008Kl-Pb; Sat, 17 Dec 2011 12:59:03 +0000 Received: from mail-ey0-f177.google.com ([209.85.215.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Rbtqn-0008Ij-1L for linux-mtd@lists.infradead.org; Sat, 17 Dec 2011 12:58:53 +0000 Received: by eaak12 with SMTP id k12so3598652eaa.36 for ; Sat, 17 Dec 2011 04:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=zFS97cPSBx69fWMSCM2YAQI+DA54TAyuW507siRdLsE=; b=WKNFHPHhL4En84yhFTG3N3AJBgAQs1uaY2JeEjHKsx7kxo7lxa5WUyxvTta58ATxzf oBGQjOZmjE3NGp4kVYkfCLAwg6EuCLU7gWdY41dLXsBkkm94Of3VSerztpCR1ZTQwiCD Z6X7ThDcgmZf9UIO1xGpdRh/XSyUyUF0/T1vI= Received: by 10.213.8.199 with SMTP id i7mr1158373ebi.129.1324126731871; Sat, 17 Dec 2011 04:58:51 -0800 (PST) Received: from shaker64.lan (dslb-088-073-137-229.pools.arcor-ip.net. [88.73.137.229]) by mx.google.com with ESMTPS id s16sm14739907eef.2.2011.12.17.04.58.50 (version=SSLv3 cipher=OTHER); Sat, 17 Dec 2011 04:58:51 -0800 (PST) From: Jonas Gorski To: linux-mtd@lists.infradead.org Subject: [PATCH 1/5] MTD: bcm63xxpart: check version marker string for newer CFEs Date: Sat, 17 Dec 2011 13:58:14 +0100 Message-Id: <1324126698-9919-2-git-send-email-jonas.gorski@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1324126698-9919-1-git-send-email-jonas.gorski@gmail.com> References: <1324126698-9919-1-git-send-email-jonas.gorski@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (jonas.gorski[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-mips@linux-mips.org, Artem Bityutskiy , David Woodhouse , Florian Fainelli X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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 #include +#include #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,