From patchwork Wed Sep 14 21:29:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 1692743 X-Patchwork-Delegate: vigneshr@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=RzD4/MGg; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=angband.pl header.i=@angband.pl header.a=rsa-sha256 header.s=tartarus header.b=Ls48i0je; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mtk6v5JrDz23k2 for ; Fri, 21 Oct 2022 10:18:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Message-ID:Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Subject:Date:To: From:Resent-To:Resent-Message-ID:Resent-Date:Resent-From:Reply-To:Cc: Content-ID:Content-Description:Resent-Sender:Resent-Cc:References:List-Owner; bh=ia9hoZzE8j/8QsgwKt23GmbpZw2q/IXWH3MMKnT0jok=; b=RzD4/MGgLz8heg/i7h9boHV2gV ycvv4i/ZbiPYIrCpJEP1VX1ztSV9yYyrYf14Wz/4jGGgi9PapGT0tQQeV08xnhixed9aUU3CEMWQh MX5+kkqzDWD2Gd1bOU1P6tqcJbBBkrwqaUYShZDvHmi+L2BEnXGeErsnEvI9O4ugbb05i5jOeT9wI MMtzr8MkSvZWyMLWWPEJ2sQOK6JgdT/3T4B/p/4KkfjyWm8XKeCRx+kAgBaheJ2XLTyVSCHylSzGO +VBEOEQiS6dfYmcfLa2girReovMsj6kzN9bznMAMx6UXYvjnoQc7FFpuY21MMOB5RAi0D6rt7AXVS 9dtWkgjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olenT-002axd-90; Thu, 20 Oct 2022 23:17:55 +0000 Received: from tartarus.angband.pl ([51.83.246.204]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olenP-002auJ-EJ for linux-mtd@lists.infradead.org; Thu, 20 Oct 2022 23:17:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=angband.pl; s=tartarus; h=In-Reply-To:Subject:Date:To:From:Resent-To:Resent-Message-ID: Resent-Date:Resent-From:Sender:Reply-To:Message-ID:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Sender:Resent-Cc:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Nm1iJXuUdZU2uB9PpQSX83/wN9IfcihizUePEGEMhZE=; b=Ls48i0jeumE8G9rGzpu/zgItj/ EaMT057HE3YesF+z7+yW4TyCy84/7Gl6uQjF+BDPbeW6a8q0PLglUn7p39PLdMOc4L4b3zKOVgqjy EcuLIQQGE/Ww46xi2sKUtvMmh6cDBNEB9ONcUBoXVakd61O6JOuiL6FsGJMcsfZALpsY=; Received: from kilobyte by tartarus.angband.pl with local (Exim 4.94.2) (envelope-from ) id 1oleII-009OaO-Sl; Fri, 21 Oct 2022 00:45:42 +0200 Resent-From: Adam Borowski Resent-Date: Fri, 21 Oct 2022 00:45:42 +0200 Resent-Message-ID: Resent-To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org From: Adam Borowski To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 14 Sep 2022 23:29:09 +0200 Subject: [PATCH 3/6] mtd: eject cfi_interleave code to its own header In-Reply-To: X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: kilobyte@angband.pl X-SA-Exim-Scanned: No (on tartarus.angband.pl); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221020_161751_659355_1B160012 X-CRM114-Status: GOOD ( 16.80 ) X-Spam-Score: -0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This fixes build failures for stuff that doesn't care about that, such as: In file included from ./include/linux/mtd/spi-nor.h:10, from drivers/spi/spi-intel.c:13: ./include/linux/mtd/cfi.h:62:2: error: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support 62 | #warnin [...] Content analysis details: (-0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 MISSING_MID Missing Message-Id: header X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 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" Message-ID: Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This fixes build failures for stuff that doesn't care about that, such as: In file included from ./include/linux/mtd/spi-nor.h:10, from drivers/spi/spi-intel.c:13: ./include/linux/mtd/cfi.h:62:2: error: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support 62 | #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. | ^~~~~~~ Signed-off-by: Adam Borowski --- drivers/mtd/chips/cfi_cmdset_0001.c | 1 + drivers/mtd/chips/cfi_cmdset_0002.c | 1 + drivers/mtd/chips/cfi_cmdset_0020.c | 1 + drivers/mtd/chips/cfi_util.c | 1 + drivers/mtd/chips/gen_probe.c | 1 + drivers/mtd/chips/jedec_probe.c | 1 + include/linux/mtd/cfi.h | 75 -------------------------- include/linux/mtd/cfi_interleave.h | 83 +++++++++++++++++++++++++++++ 8 files changed, 89 insertions(+), 75 deletions(-) create mode 100644 include/linux/mtd/cfi_interleave.h diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index 54f92d09d9cf..efbf06fce95b 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c @@ -34,6 +34,7 @@ #include #include #include +#include /* #define CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE */ /* #define CMDSET0001_DISABLE_WRITE_SUSPEND */ diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 67453f59c69c..70d00c3641d8 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #define AMD_BOOTLOC_BUG diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index d35df526e0a6..007e37faff56 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c @@ -31,6 +31,7 @@ #include #include #include +#include #include diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c index 6a6a2a21d2ed..608315032f9e 100644 --- a/drivers/mtd/chips/cfi_util.c +++ b/drivers/mtd/chips/cfi_util.c @@ -22,6 +22,7 @@ #include #include #include +#include void cfi_udelay(int us) { diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index 4d4f97841016..8703890ff20e 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c @@ -10,6 +10,7 @@ #include #include #include +#include #include static struct mtd_info *check_cmd_set(struct map_info *, int); diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c index 6f7e7e1b3fe5..88a979bb59bb 100644 --- a/drivers/mtd/chips/jedec_probe.c +++ b/drivers/mtd/chips/jedec_probe.c @@ -20,6 +20,7 @@ #include #include #include +#include #include /* AMD */ diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index d88bb56c18e2..4a8ddb51afee 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h @@ -8,87 +8,12 @@ #include #include -#include #include #include #include #include #include -#ifdef CONFIG_MTD_CFI_I1 -#define cfi_interleave(cfi) 1 -#define cfi_interleave_is_1(cfi) (cfi_interleave(cfi) == 1) -#else -#define cfi_interleave_is_1(cfi) (0) -#endif - -#ifdef CONFIG_MTD_CFI_I2 -# ifdef cfi_interleave -# undef cfi_interleave -# define cfi_interleave(cfi) ((cfi)->interleave) -# else -# define cfi_interleave(cfi) 2 -# endif -#define cfi_interleave_is_2(cfi) (cfi_interleave(cfi) == 2) -#else -#define cfi_interleave_is_2(cfi) (0) -#endif - -#ifdef CONFIG_MTD_CFI_I4 -# ifdef cfi_interleave -# undef cfi_interleave -# define cfi_interleave(cfi) ((cfi)->interleave) -# else -# define cfi_interleave(cfi) 4 -# endif -#define cfi_interleave_is_4(cfi) (cfi_interleave(cfi) == 4) -#else -#define cfi_interleave_is_4(cfi) (0) -#endif - -#ifdef CONFIG_MTD_CFI_I8 -# ifdef cfi_interleave -# undef cfi_interleave -# define cfi_interleave(cfi) ((cfi)->interleave) -# else -# define cfi_interleave(cfi) 8 -# endif -#define cfi_interleave_is_8(cfi) (cfi_interleave(cfi) == 8) -#else -#define cfi_interleave_is_8(cfi) (0) -#endif - -#ifndef cfi_interleave -#warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. -static inline int cfi_interleave(void *cfi) -{ - BUG(); - return 0; -} -#endif - -static inline int cfi_interleave_supported(int i) -{ - switch (i) { -#ifdef CONFIG_MTD_CFI_I1 - case 1: -#endif -#ifdef CONFIG_MTD_CFI_I2 - case 2: -#endif -#ifdef CONFIG_MTD_CFI_I4 - case 4: -#endif -#ifdef CONFIG_MTD_CFI_I8 - case 8: -#endif - return 1; - - default: - return 0; - } -} - /* NB: these values must represents the number of bytes needed to meet the * device type (x8, x16, x32). Eg. a 32 bit device is 4 x 8 bytes. diff --git a/include/linux/mtd/cfi_interleave.h b/include/linux/mtd/cfi_interleave.h new file mode 100644 index 000000000000..03d94a6d11fc --- /dev/null +++ b/include/linux/mtd/cfi_interleave.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __MTD_CFI_INTERLEAVE_H__ +#define __MTD_CFI_INTERLEAVE_H__ + +#include + +#ifdef CONFIG_MTD_CFI_I1 +#define cfi_interleave(cfi) 1 +#define cfi_interleave_is_1(cfi) (cfi_interleave(cfi) == 1) +#else +#define cfi_interleave_is_1(cfi) (0) +#endif + +#ifdef CONFIG_MTD_CFI_I2 +# ifdef cfi_interleave +# undef cfi_interleave +# define cfi_interleave(cfi) ((cfi)->interleave) +# else +# define cfi_interleave(cfi) 2 +# endif +#define cfi_interleave_is_2(cfi) (cfi_interleave(cfi) == 2) +#else +#define cfi_interleave_is_2(cfi) (0) +#endif + +#ifdef CONFIG_MTD_CFI_I4 +# ifdef cfi_interleave +# undef cfi_interleave +# define cfi_interleave(cfi) ((cfi)->interleave) +# else +# define cfi_interleave(cfi) 4 +# endif +#define cfi_interleave_is_4(cfi) (cfi_interleave(cfi) == 4) +#else +#define cfi_interleave_is_4(cfi) (0) +#endif + +#ifdef CONFIG_MTD_CFI_I8 +# ifdef cfi_interleave +# undef cfi_interleave +# define cfi_interleave(cfi) ((cfi)->interleave) +# else +# define cfi_interleave(cfi) 8 +# endif +#define cfi_interleave_is_8(cfi) (cfi_interleave(cfi) == 8) +#else +#define cfi_interleave_is_8(cfi) (0) +#endif + +#ifndef cfi_interleave +#warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. +static inline int cfi_interleave(void *cfi) +{ + BUG(); + return 0; +} +#endif + +static inline int cfi_interleave_supported(int i) +{ + switch (i) { +#ifdef CONFIG_MTD_CFI_I1 + case 1: +#endif +#ifdef CONFIG_MTD_CFI_I2 + case 2: +#endif +#ifdef CONFIG_MTD_CFI_I4 + case 4: +#endif +#ifdef CONFIG_MTD_CFI_I8 + case 8: +#endif + return 1; + + default: + return 0; + } +} + + +#endif /* __MTD_CFI_INTERLEAVE_H__ */