mtd: cfi: allow building spi-intel standalone
PATCH 1/1 mtd: cfi: allow building spi-intel standalone
From: Arnd Bergmann <[email protected]>
When MTD or MTD_CFI_GEOMETRY is disabled, the spi-intel driver fails to build, as it includes the shared CFI header:
include/linux/mtd/cfi.h:62:2: error: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. [-Werror=cpp]
62 | #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work.
Use an #ifdef here to guard the settings so the header can be included in all configurations.
--- include/linux/mtd/cfi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/mtd/cfi.h +2 -1
@@ -15,6 +15,7 @@#include <linux/mtd/cfi_endian.h> #include <linux/mtd/xip.h> +#if IS_ENABLED (CONFIG_MTD )#ifdef CONFIG_MTD_CFI_I1 #define cfi_interleave (cfi) 1#define cfi_interleave_is_1 (cfi) (cfi_interleave(cfi) == 1)
@@ -88,7 +89,7 @@ static inline int cfi_interleave_supported(int i) return 0; } } - +#endif /* 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.
Signature · 1 line
2.35.1
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When MTD or
MTD_CFI_GEOMETRYis disabled, the spi-intel driver fails to build, as it includes the shared CFI header:
Quoted 8 lines
include/linux/mtd/cfi.h:62:2: error: #warning NoCONFIG_MTD_CFI_Ixselected. No NOR chip support can work. [-Werror=cpp]
62 | #warning NoCONFIG_MTD_CFI_Ixselected. No NOR chip support can work.Use an #ifdef here to guard the settings so the header can be included in all configurations.
Fixes e23e5a05d1fd ("mtd: spi-nor: intel-spi: Convert to SPI MEM")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 4 lines · Arnd Bergmann
From: Arnd Bergmann<[email protected]>
When MTD or
MTD_CFI_GEOMETRYis disabled, the spi-intel driver fails to build, as it includes the shared CFI header:
The header file linux/mtd/cfi.h is included by the head file linux/mtd/spi-nor.h so seems the warning caused. Is it really necessary to inculude linux/mtd/cfi.h from linux/mtd/spi-nor.h?
(It seems that it can be resolved the issue by removing the including cfi.h from spi-nor.h if unnecessary.)
Quoted 18 lines
include/linux/mtd/cfi.h:62:2: error: #warning NoCONFIG_MTD_CFI_Ixselected. No NOR chip support can work. [-Werror=cpp]
62 | #warning NoCONFIG_MTD_CFI_Ixselected. No NOR chip support can work.Use an #ifdef here to guard the settings so the header can be included in all configurations.
Fixes e23e5a05d1fd ("mtd: spi-nor: intel-spi: Convert to SPI MEM")Signed-off-by Arnd Bergmann<[email protected]>--- include/linux/mtd/cfi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)include/linux/mtd/cfi.h +0
-0
include/linux/mtd/cfi.h line 18
Quoted 4 lines
include/linux/mtd/cfi.h +1
-0@@ -15,6 +15,7 @@#include <linux/mtd/cfi_endian.h> #include <linux/mtd/xip.h> +#if IS_ENABLED (CONFIG_MTD )
Is it enough to check only CONFIG_MTD here as not necessary to check if MTD_CFI_GEOMETRY also? By the way it seems also that it is needed to use #ifdef only for the cfi_interleave warning checking as below.
#if IS_ENABLED(CONFIG_MTD) && IS_ENABLED(CONFIG_MTD_CFI_GEOMETRY) #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 /* cfi_interleave */
#endif /* IS_ENABLED(CONFIG_MTD) && IS_ENABLED(CONFIG_MTD_CFI_GEOMETRY) */
Note: The cfi_interleave warning checking was implemented by the following commit. 241651d04d67 ("[MTD] Fix CFI build error when no map width or interleave supported")
Quoted 12 lines
include/linux/mtd/cfi.h +1
-1#ifdef CONFIG_MTD_CFI_I1 #define cfi_interleave (cfi) 1#define cfi_interleave_is_1 (cfi) (cfi_interleave(cfi) == 1)@@ -88,7 +89,7 @@ static inline int cfi_interleave_supported(int i) return 0; } } - +#endif /* 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.
Quoted 9 lines · Tokunori Ikegami
Quoted 4 lines · Arnd Bergmann
From: Arnd Bergmann<[email protected]>
When MTD or
MTD_CFI_GEOMETRYis disabled, the spi-intel driver fails to build, as it includes the shared CFI header:The header file
linux/mtd/cfi.his included by the head filelinux/mtd/spi-nor.hso seems the warning caused. Is it really necessary to inculudelinux/mtd/cfi.hfromlinux/mtd/spi-nor.h?
(It seems that it can be resolved the issue by removing the includingcfi.hfromspi-nor.hif unnecessary.)
SPI NOR does not depend on CFI. cfi.h shouldn't be included by spi-nor.h, indeed.
Cheers,
ta
Quoted 14 lines · Tudor Ambarus
Quoted 4 lines · Tokunori Ikegami
Quoted 2 lines · Arnd Bergmann
From: Arnd Bergmann<[email protected]>
Quoted 8 lines
Quoted 2 lines
When MTD or
MTD_CFI_GEOMETRYis disabled, the spi-intel driver fails to build, as it includes the shared CFI header:The header file
linux/mtd/cfi.his included by the head filelinux/mtd/spi-nor.hso seems the warning caused.
Is it really necessary to inculudelinux/mtd/cfi.hfromlinux/mtd/spi-nor.h?
(It seems that it can be resolved the issue by removing the includingcfi.hfromspi-nor.hif unnecessary.)
Quoted 2 lines
SPI NOR does not depend on CFI.
cfi.hshouldn't be included byspi-nor.h, indeed.
Right, I sent v2 now doing this instead.
Arnd