Skip to contentSkip to conversation

mtd: cfi: enforce valid geometry configuration

PATCH Applied Arnd Bergmann 2 participants 6 messages Nov 23, 2015 – Nov 30, 2015 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: cfi: enforce valid geometry configuration

MTD allows compile-time configuration of the possible CFI geometry settings that are allowed by the kernel, but that includes a couple of invalid configurations, where no bank width or no interleave setting is allowed. These are then caught with a compile-time warning:

include/linux/mtd/cfi.h:76:2: warning: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. include/linux/mtd/map.h:145:2: warning: #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

This is a bit annoying for randconfig tests, and can be avoided if we change the Kconfig logic to always select the simplest configuration when no other one is enabled.

drivers/mtd/chips/Kconfig +4 -0
index 63b6b536b044..741ec69e0b46 100644
@@ -69,6 +69,10 @@ endchoice
 config MTD_CFI_GEOMETRY
 	bool "Specific CFI Flash geometry selection"
 	depends on MTD_CFI_ADV_OPTIONS
+	select MTD_MAP_BANK_WIDTH_1 if  !(MTD_MAP_BANK_WIDTH_2 || \
+		 MTD_MAP_BANK_WIDTH_4  || MTD_MAP_BANK_WIDTH_8 || \
+		 MTD_MAP_BANK_WIDTH_16 || MTD_MAP_BANK_WIDTH_32)
+	select MTD_CFI_I1 if !(MTD_CFI_I2 || MTD_CFI_I4 || MTD_CFI_I8)
 	help
 	  This option does not affect the code directly, but will enable
 	  some other configuration options which would allow you to reduce
#1 lore raw
Quoted 8 lines · On Monday 23 November 2015 14:39:33 Arnd Bergmann wrote:

MTD allows compile-time configuration of the possible CFI geometry settings that are allowed by the kernel, but that includes a couple of invalid configurations, where no bank width or no interleave setting is allowed. These are then caught with a compile-time warning:

include/linux/mtd/cfi.h:76:2: warning: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. include/linux/mtd/map.h:145:2: warning: #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

I'm actually still getting the warnings for any file that includes <linux/mtd/map.h> while CONFIG_MTD is disabled. I have a fix now that I'm testing overnight and plan to post tomorrow, then we can decide whether it should be part of the same patch, or we should have two separate patches.

Arnd

#2 lore raw

PATCH 1/1 mtd: cfi: don't warn about broken geometry for !CONFIG_MTD

The linux/mtd/map.h header file is included by a couple of platform specific files that are built even when CONFIG_MTD is disabled, and we always get

warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

in that case. This adds an #ifdef around the pointless warning, as everything is really fine when we don't build the drivers anyway.

---

Quoted 4 lines

I'm actually still getting the warnings for any file that includes <linux/mtd/map.h> while CONFIG_MTD is disabled. I have a fix now that I'm testing overnight and plan to post tomorrow, then we can decide whether it should be part of the same patch, or we should have two separate patches.

The patch fixes the remaining warnings I see on ARM randconfigs in this file, and I think it makes sense to keep it as a separate patch, as these are really distinct problems even thought the symptom is the same.

Please apply both.

include/linux/mtd/map.h +2 -0
index 366cf77953b5..58f3ba709ade 100644
@@ -142,7 +142,9 @@
 #endif
 
 #ifndef map_bankwidth
+#ifdef CONFIG_MTD
 #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"
+#endif
 static inline int map_bankwidth(void *map)
 {
 	BUG();
Applied
#3 lore raw

Re: [PATCH] mtd: cfi: don't warn about broken geometry for !CONFIG_MTD

Quoted 29 lines · Arnd Bergmann

The linux/mtd/map.h header file is included by a couple of platform specific files that are built even when CONFIG_MTD is disabled, and we always get

warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

in that case. This adds an #ifdef around the pointless warning, as everything is really fine when we don't build the drivers anyway.

---

Quoted 4 lines

I'm actually still getting the warnings for any file that includes <linux/mtd/map.h> while CONFIG_MTD is disabled. I have a fix now that I'm testing overnight and plan to post tomorrow, then we can decide whether it should be part of the same patch, or we should have two separate patches.

The patch fixes the remaining warnings I see on ARM randconfigs in this file, and I think it makes sense to keep it as a separate patch, as these are really distinct problems even thought the symptom is the same.

Please apply both.

include/linux/mtd/map.h +0 -0
index 366cf77953b5..58f3ba709ade 100644

include/linux/mtd/map.h line 150

Quoted 9 lines
include/linux/mtd/map.h +2 -0
@@ -142,7 +142,9 @@
 #endif
 
 #ifndef map_bankwidth
+#ifdef CONFIG_MTD
 #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"
+#endif
 static inline int map_bankwidth(void *map)
 {
 	BUG();

I guess no one includes mtd/cfi.h with CONFIG_MTD=n? Otherwise, we might have the same problems there.

Pushed to l2-mtd.git, thanks!

Brian

#4 lore raw

Re: [PATCH] mtd: cfi: don't warn about broken geometry for !CONFIG_MTD

Quoted 3 lines · On Monday 30 November 2015 12:55:05 Brian Norris wrote:

I guess no one includes mtd/cfi.h with CONFIG_MTD=n? Otherwise, we might have the same problems there.

Right, I checked that all users of that file depend on CONFIG_MTD.

Quoted 1 line

Pushed to l2-mtd.git, thanks!

Thanks,

ARnd

Applied
#5 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

MTD allows compile-time configuration of the possible CFI geometry settings that are allowed by the kernel, but that includes a couple of invalid configurations, where no bank width or no interleave setting is allowed. These are then caught with a compile-time warning:

Quoted 8 lines

include/linux/mtd/cfi.h:76:2: warning: #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work. include/linux/mtd/map.h:145:2: warning: #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work"

This is a bit annoying for randconfig tests, and can be avoided if we change the Kconfig logic to always select the simplest configuration when no other one is enabled.

Pushed to l2-mtd.git. Thanks for fixing this one! I guess an ugly fix is better than nothing here.