From patchwork Fri Jun 12 07:35: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: 11601363 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 97E6B13B4 for ; Fri, 12 Jun 2020 07:36:04 +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 5E8CE20836 for ; Fri, 12 Jun 2020 07:36:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HmLuu5vC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TVxEWGAF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E8CE20836 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=Nf9ec7AmwUg9HJ8JVGNoT+0OVvZoq1jiDV97fZemQBY=; b=HmLuu5vCM/S5yH W5mRV1mHTQLKa1rhGwFdj07ctQN5u6JqtvoJZH0REm97X5XW7k98Hr8kN3GhnJJXfvpHYtDrAPJl1 NfFAu91R2cO8+bGkAoJsJsPbhUMM6y/8TzCdvSpEjx90epH4tKd0zv69JcwXZwlOQIr92FHTzelgT HTi2UaWmQWjSLLWt/UMDIi++4OWrgG3fQk9VoOXC+9ra4JGB8dKx3za2IiDVtk+t9ZqYSo1XuFkDt xzrwriB5NK/UO5+GoVCkcBOgbTZFZTO1rZg8OzM7IMNc0GpWT2M74gv0UmrOJDYj/dSnKKB1jGxS3 XCY+Nkdj4jFjTMQPRVVQ==; 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 1jjeEJ-0005BN-Dw; Fri, 12 Jun 2020 07:35:59 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jjeED-0005Ax-UN; Fri, 12 Jun 2020 07:35:58 +0000 Received: by mail-wr1-x441.google.com with SMTP id l11so8683196wru.0; Fri, 12 Jun 2020 00:35:53 -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=i+dRr0+LqXIl7Im4UO44miDTuI38sVf6D3sGaM7BzTw=; b=TVxEWGAFYaT7Abyc6rM/L/LAQewp9ZFr4x0CqCfwUknqU4gB6N64hJXnjQ0tLBW1nj t1xpJ2B+fWTAsOlOe2LgEkv9sw1Rws6uYFpNC+fprC/cgvGx78PZnD9fiK7v5QHB9BBe p001z7xrik0ysWNGlBdRCIdQhVHJ2i7841wW9DkGsYZFOBz7AiWHdhNdZjv3ugH/qTpX 8S3k02koXX91fHvjOYx9KRm7WSh1DDnMV76BpmwiG7BKHqJ9uCva+KqgztLb1vpsvwvT XPGho0bR7/RdnzsFKa5jnXu7mP9vN1EQu9PcOrjlAweqJVPcUGrEybolvfF8YtqJjsjr OhMQ== 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=i+dRr0+LqXIl7Im4UO44miDTuI38sVf6D3sGaM7BzTw=; b=D3Vbe2/2qiUmyEh7nu3ZGOSaWciLA6DpmfmZ8B/oGv470vWXJPOr4tRy4YvZ34UCem Bxixp200nkLIAtCrhGhAxVwBEut46vVWImNkuJlx2KHo7SRem7yduvBhNBGDAFTHy8sk FDWoXBFT0VviOgsth4gqVT8QkDhmFL7hF6k4ExgSzRG94yu8ZIebKKVlxLyg37nOdatH 4zPvn3oq06R64/8dD/VUMafRmpgGog5RxPSqQ5XhgUpsJ/vP3QPV/foiR/berY3TRqyc 4TrPwZbEM/iTLqcKYwemkaULTVifWoTK9ej3l+r1KOx51lGzb9+pZE7FaCJCkRxTeF45 OHKw== X-Gm-Message-State: AOAM530NhkwKqxie4UkS7zQOSnT7N49aNSCOYdSI3PD/ll67EYRbhgcJ rfquloBwckMtUUxR6Qy2Vls= X-Google-Smtp-Source: ABdhPJxOsgd6flPA0JCauNhh1ZlR45HzUiPV+lbPcExOT9NWKh6pnzfSbwJJpTuxHF33g4XFITkT0Q== X-Received: by 2002:a5d:6751:: with SMTP id l17mr14341234wrw.179.1591947352233; Fri, 12 Jun 2020 00:35:52 -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 a1sm7729914wmd.28.2020.06.12.00.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 00:35:51 -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 v3] mtd: parsers: bcm63xx: simplify CFE detection Date: Fri, 12 Jun 2020 09:35:49 +0200 Message-Id: <20200612073549.1658336-1-noltari@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200608160649.3717152-1-noltari@gmail.com> References: <20200608160649.3717152-1-noltari@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200612_003553_996680_929C6D11 X-CRM114-Status: GOOD ( 11.54 ) 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:441 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_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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 --- v3: keep COMPILE_TEST compatibility by adding a new function that only checks fw_arg3 when CONFIG_MIPS is defined. v2: use CFE_EPTSEAL definition and avoid using an additional function. drivers/mtd/parsers/bcm63xxpart.c | 34 +++++++++++-------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/parsers/bcm63xxpart.c b/drivers/mtd/parsers/bcm63xxpart.c index 78f90c6c18fd..c514c04789af 100644 --- a/drivers/mtd/parsers/bcm63xxpart.c +++ b/drivers/mtd/parsers/bcm63xxpart.c @@ -22,6 +22,11 @@ #include #include +#ifdef CONFIG_MIPS +#include +#include +#endif /* CONFIG_MIPS */ + #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */ #define BCM963XX_CFE_MAGIC_OFFSET 0x4e0 @@ -32,28 +37,13 @@ #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) +static inline int bcm63xx_detect_cfe(void) { - 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); +#ifdef CONFIG_MIPS + return (fw_arg3 == CFE_EPTSEAL); +#else + return 0; +#endif /* CONFIG_MIPS */ } static int bcm63xx_read_nvram(struct mtd_info *master, @@ -138,7 +128,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master, struct bcm963xx_nvram *nvram = NULL; int ret; - if (bcm63xx_detect_cfe(master)) + if (!bcm63xx_detect_cfe()) return -EINVAL; nvram = vzalloc(sizeof(*nvram));