From patchwork Mon Jun 8 16:06:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= X-Patchwork-Id: 11593555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BB2E739 for ; Mon, 8 Jun 2020 16:07:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38BB72063A for ; Mon, 8 Jun 2020 16:07:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fP9ocDrS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZLSxxQtA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38BB72063A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F2mlgw5JGKTlmDsrwi64bMJUlBOJnJhwOcSOmZ5JEmk=; b=fP9ocDrS/d6cbQ KoA64NVqzZbJE42doyCV1x/MLlqLWmi+bGiUXOdyPcmsLIzGzeD76TYMJsT3FuQ4o9HMUQVf7CTi6 PwquKuVrQJtXnzVub8jiRE3eC/9+LGgobKlZAn8bX3toPvoulfKMyazr/Rvxoxe/lRbJpvPfIb/Wd rP6vv6NDh26gGfZldZANCHaTdQ5bXdMtkHmYGT+5UVjc+Se9RtxqKARYdkblEYQpgqX8ydmHF5npe C96QL59yTqGdqv49+f/bZZAefQ9geZvQFZ+LwXbkEgR5B/4ueNdqQbgTdLzLp3eqhl4w/bK847vjf a5sCByPi2gKKkLobp1UA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiKIk-0005vO-BN; Mon, 08 Jun 2020 16:07:06 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiKIh-0005uH-CX; Mon, 08 Jun 2020 16:07:04 +0000 Received: by mail-wm1-x344.google.com with SMTP id y20so69439wmi.2; Mon, 08 Jun 2020 09:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xSm/ixCMsXrBbAVZMWIWVyDBFHz6cDKWQtZCmAnN0nA=; b=ZLSxxQtAqk9VJDhuTPL/QytUa2FIBQopJdBHKih5e4AAFXp7fINT9N+ePLJodzE/tU MIo4bnGqf6TwcM2yJnT8F3mNUgmp+iiR7KVcEf0MRbb/a/WciLworDKVhxZ4gXx6Shts HMV0P81Yb2gscczPSxyxyT6ukEYSwfakd0VCuBT7SJriDcBqMux5KKV6paMbOPPS9Ud9 XRvv63vkPM7+tmGskVRlRvyeSWZZFi+ulGYCSujm6IW2JWESuFocQua+OIV3YkJciJFg HRbtsT0RpycizikAmUr1ILfJsTt/0ebbdX3R89RLKixL+YdeRFBH3h6OODLDz9Ucvi9b ylXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xSm/ixCMsXrBbAVZMWIWVyDBFHz6cDKWQtZCmAnN0nA=; b=l1T9A0e3CFYcW3E7OrHyx6h3n4qqS/24vzTVtY08yR8spC4DkU4e/9UhfgueaT7i/o pK75tLevqYgG3NpQXqmk3QxI4xzwCwTz56GZrg9YCSdBJ+x0HVt350nHHJxm0uOkrMnf 2FW8R6fe+Tuh0E4uh8GSijeG2Bh8WVainARnm6sX5t3sZVWLtsvJoVzP9DQK/KORRLrj 3aWP6i1H0/osLzdAKGYXOBR0BASxDqQy7se4pLm+LOX5RQ+YQn1ovBINQC41xwPBObGM G8a9LmQzCU3zawm0h4Tc7eHSM3oe7qxFWGc6RMqWJzI6AQoksTe1y3VIRN1Mz0m4IxVg psTQ== X-Gm-Message-State: AOAM530KkVPOosD91zlE4bMScXwjP3DIYWOgrdiNnJzYxGrPegwey76j 57YUjUMs5mJmZVtYZ1h9J8P34pGqEeT/fw== X-Google-Smtp-Source: ABdhPJzlh/xf/IFViONY5iqBfTW9IBvJzeWdZjU4s6WE0zKa+QDIy95NBnZc/nabW15BofK0+Fz87w== X-Received: by 2002:a1c:24c6:: with SMTP id k189mr72594wmk.9.1591632418158; Mon, 08 Jun 2020 09:06:58 -0700 (PDT) Received: from skynet.lan (28.red-83-49-61.dynamicip.rima-tde.net. [83.49.61.28]) by smtp.gmail.com with ESMTPSA id b187sm32275wmd.26.2020.06.08.09.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 09:06:57 -0700 (PDT) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: tsbogend@alpha.franken.de, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, jonas.gorski@gmail.com, linus.walleij@linaro.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v2] mtd: parsers: bcm63xx: simplify CFE detection Date: Mon, 8 Jun 2020 18:06:49 +0200 Message-Id: <20200608160649.3717152-1-noltari@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200608094053.3381512-1-noltari@gmail.com> References: <20200608094053.3381512-1-noltari@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200608_090703_426077_976E59C7 X-CRM114-Status: GOOD ( 11.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [noltari[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Instead of trying to parse CFE version string, which is customized by some vendors, let's just check that "CFE1" was passed on argument 3. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: use CFE_EPTSEAL definition and avoid using an additional funtion. drivers/mtd/parsers/bcm63xxpart.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/parsers/bcm63xxpart.c b/drivers/mtd/parsers/bcm63xxpart.c index 78f90c6c18fd..493a75b2f266 100644 --- a/drivers/mtd/parsers/bcm63xxpart.c +++ b/drivers/mtd/parsers/bcm63xxpart.c @@ -22,6 +22,9 @@ #include #include +#include +#include + #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */ #define BCM963XX_CFE_MAGIC_OFFSET 0x4e0 @@ -32,30 +35,6 @@ #define STR_NULL_TERMINATE(x) \ do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0) -static int bcm63xx_detect_cfe(struct mtd_info *master) -{ - char buf[9]; - int ret; - size_t retlen; - - ret = mtd_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 = mtd_read(master, BCM963XX_CFE_MAGIC_OFFSET, 8, &retlen, - (void *)buf); - buf[retlen] = 0; - - return strncmp("CFE1CFE1", buf, 8); -} - static int bcm63xx_read_nvram(struct mtd_info *master, struct bcm963xx_nvram *nvram) { @@ -138,7 +117,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master, struct bcm963xx_nvram *nvram = NULL; int ret; - if (bcm63xx_detect_cfe(master)) + if (fw_arg3 != CFE_EPTSEAL) return -EINVAL; nvram = vzalloc(sizeof(*nvram));