bcma,ssb: simplify dependency handling for bcma and ssb drivers
Subsystems (8)
PATCH 1/1 bcma,ssb: simplify dependency handling for bcma and ssb drivers
The files, drivers/bcma/Kconfig and drivers/ssb/Kconfig, define two helper config options BCMA_POSSIBLE and SSB_POSSIBLE. Both options are defined identical:
config {BCMA_POSSIBLE,SSB_POSSIBLE}
bool depends on HAS_IOMEM && HAS_DMA default y
While this kind of duplication might still be acceptable in order to have both sections work independently of each other, it really gets strange when looking how they are then used in expression where both of those configs appear. E.g., config B43's dependency is:
(BCMA_POSSIBLE || SSB_POSSIBLE) && MAC80211 && HAS_DMA
Note that BCMA_POSSIBLE and SSB_POSSIBLE identical and already have HAS_DMA as condition, so that is then also another duplication.
Another example is the choice Supported bus types in B43, which already depends on B43 and hence, we know that HAS_IOMEM && HAS_DMA holds, so all stated dependencies in the choice are true in all cases.
Given this whole confusion around the use of these two symbols, just remove them and replace them with the expression they intend to abbreviate.
--- drivers/bcma/Kconfig | 7 +------ drivers/net/ethernet/broadcom/Kconfig | 4 ++-- drivers/net/wireless/broadcom/b43/Kconfig | 5 +---- drivers/net/wireless/broadcom/b43legacy/Kconfig | 2 +- drivers/net/wireless/broadcom/brcm80211/Kconfig | 3 +-- drivers/ssb/Kconfig | 7 +------ 6 files changed, 7 insertions(+), 21 deletions(-)
drivers/bcma/Kconfig +1 -6
@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -config BCMA_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig BCMA tristate "Broadcom specific AMBA" - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA help Bus driver for Broadcom specific Advanced Microcontroller Bus Architecture.
drivers/net/ethernet/broadcom/Kconfig +2 -2
@@ -6,7 +6,7 @@ config NET_VENDOR_BROADCOM bool "Broadcom devices" default y - depends on (SSB_POSSIBLE && HAS_DMA) || PCI || BCM63XX || \ + depends on (HAS_IOMEM && HAS_DMA) || PCI || BCM63XX || \ SIBYTE_SB1xxx_SOC help If you have a network (Ethernet) chipset belonging to this class,
@@ -21,7 +21,7 @@ if NET_VENDOR_BROADCOM config B44 tristate "Broadcom 440x/47xx ethernet support" - depends on SSB_POSSIBLE && HAS_DMA + depends on HAS_IOMEM && HAS_DMA select SSB select MII select PHYLIB
drivers/net/wireless/broadcom/b43/Kconfig +1 -4
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config B43 tristate "Broadcom 43xx wireless support (mac80211 stack)" - depends on (BCMA_POSSIBLE || SSB_POSSIBLE) && MAC80211 && HAS_DMA + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMA if B43_BCMA select SSB if B43_SSB select FW_LOADER
@@ -42,18 +42,15 @@ choice config B43_BUSES_BCMA_AND_SSB bool "BCMA and SSB" - depends on BCMA_POSSIBLE && SSB_POSSIBLE select B43_BCMA select B43_SSB config B43_BUSES_BCMA bool "BCMA only" - depends on BCMA_POSSIBLE select B43_BCMA config B43_BUSES_SSB bool "SSB only" - depends on SSB_POSSIBLE select B43_SSB endchoice
drivers/net/wireless/broadcom/b43legacy/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config B43LEGACY tristate "Broadcom 43xx-legacy wireless support (mac80211 stack)" - depends on SSB_POSSIBLE && MAC80211 && HAS_DMA + depends on HAS_IOMEM && HAS_DMA && MAC80211 select SSB select FW_LOADER help
drivers/net/wireless/broadcom/brcm80211/Kconfig +1 -2
@@ -4,8 +4,7 @@ config BRCMUTIL config BRCMSMAC tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - depends on MAC80211 - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMA select BRCMUTIL select FW_LOADER
drivers/ssb/Kconfig +1 -6
@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -config SSB_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig SSB tristate "Sonics Silicon Backplane support" - depends on SSB_POSSIBLE + depends on HAS_IOMEM && HAS_DMA help Support for the Sonics Silicon Backplane bus. You only need to enable this option, if you are
Signature · 1 line
2.17.1
On Mon, 2023-12-18 at 12:58 +0100, Lukas Bulwahn wrote:
Dunno, I'm not super involved with this but ...
Quoted 12 lines
+++ b/drivers/bcma/Kconfig
drivers/bcma/Kconfig +1
-6@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -config BCMA_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig BCMA tristate "Broadcom specific AMBA" - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA
[...]
drivers/net/wireless/broadcom/brcm80211/Kconfig config BRCMUTIL · line 8
Quoted 6 lines
config BRCMSMAC
drivers/net/wireless/broadcom/brcm80211/Kconfig +1
-2tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - depends on MAC80211 - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMA
to me it kind of seems more obvious for example in this case to say "depend on BCMA_POSSIBLE and select BCMA" rather than open-coding the BCMA dependencies both here and in BCMA? Now granted, they're rather unlikely to _change_, but it still seems more obvious?
johannes
Quoted 18 lines · Johannes Berg
On Mon, 2023-12-18 at 12:58 +0100, Lukas Bulwahn wrote:
Dunno, I'm not super involved with this but ...
Quoted 12 lines
+++ b/drivers/bcma/Kconfig
drivers/bcma/Kconfig +1
-6@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -config BCMA_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig BCMA tristate "Broadcom specific AMBA" - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA[...]
Quoted 11 lines
drivers/net/wireless/broadcom/brcm80211/Kconfig config BRCMUTIL · line 8
Quoted 6 lines
config BRCMSMAC
drivers/net/wireless/broadcom/brcm80211/Kconfig +1
-2tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - depends on MAC80211 - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMAto me it kind of seems more obvious for example in this case to say "depend on
BCMA_POSSIBLEand select BCMA" rather than open-coding the BCMA dependencies both here and in BCMA? Now granted, they're rather unlikely to _change_, but it still seems more obvious?
I was thinking the same. Lukas, is there a specific reason why you want to change this or this just something you noticed by chance?
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 28 lines · Kalle Valo
Quoted 25 lines · Johannes Berg
On Mon, 2023-12-18 at 12:58 +0100, Lukas Bulwahn wrote:
Dunno, I'm not super involved with this but ...
Quoted 12 lines
+++ b/drivers/bcma/Kconfig
drivers/bcma/Kconfig +1
-6@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -config BCMA_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig BCMA tristate "Broadcom specific AMBA" - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA[...]
Quoted 6 lines
config BRCMSMAC
tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"drivers/net/wireless/broadcom/brcm80211/Kconfig +1
-2- depends on MAC80211 - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMA
Quoted 8 lines
Quoted 4 lines
to me it kind of seems more obvious for example in this case to say "depend on
BCMA_POSSIBLEand select BCMA" rather than open-coding the BCMA dependencies both here and in BCMA? Now granted, they're rather unlikely to _change_, but it still seems more obvious?I was thinking the same. Lukas, is there a specific reason why you want to change this or this just something you noticed by chance?
I just noticed this by chance---well, I was wondering what these config symbols were doing in my kernel build configuration (they are actually in every config). While reading through the code, I was confused on what the dependencies were trying to tell me, as the config symbols and conditions seemed to repeat over and over in different places.
I thought it was worth a clean up and this was the patch I came up with in the end.
Lukas
Michael Büsch
maintainerHi Lukas,
thanks for your patch.
Quoted 4 lines · On Mon, 18 Dec 2023 16:03:54 +0100 Lukas Bulwahn <[email protected]>…
While reading through the code, I was
confused on what the dependencies were trying to tell me, as the config symbols and conditions seemed to repeat over and over in different places.
The {SSB,BCMA}_POSSIBLE constants are defining the conditions under which it is possible to 'select' SSB/BCMA.
SSB and BCMA are usually 'select'ed rather than depended on, for better user experience while configuring.
Quoted 2 lines
I thought it was worth a clean up and this was the patch I came up with in the end.
IMO this does not clean up or simplify the code.
It rather makes it more complicated to maintain.
The idea behind the POSSIBLE constants it to _not_ spread the conditions all across the drivers. That has significant advantages, if the condition changes.
I also don't see the redundancy in the resulting dependency conditions as a bad thing. It's better if every option explicitly defines its dependencies rather than expecting something else to depend on it. That's fragile.
NAK from me.
Signature · 2 lines
Michael Büsch https://bues.ch/
_______________________________________________
b43-dev mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/b43-dev
Quoted 26 lines · Johannes Berg
On Mon, 2023-12-18 at 12:58 +0100, Lukas Bulwahn wrote:
Dunno, I'm not super involved with this but ...
Quoted 12 lines
+++ b/drivers/bcma/Kconfig
drivers/bcma/Kconfig +1
-6@@ -1,12 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -config BCMA_POSSIBLE - bool - depends on HAS_IOMEM && HAS_DMA - default y - menuconfig BCMA tristate "Broadcom specific AMBA" - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA[...]
drivers/net/wireless/broadcom/brcm80211/Kconfig config BRCMUTIL · line 8
Quoted 6 lines
config BRCMSMAC
tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"drivers/net/wireless/broadcom/brcm80211/Kconfig +1
-2- depends on MAC80211 - depends on BCMA_POSSIBLE + depends on HAS_IOMEM && HAS_DMA && MAC80211 select BCMA
Quoted 5 lines
to me it kind of seems more obvious for example in this case to say "depend on
BCMA_POSSIBLEand select BCMA" rather than open-coding the BCMA dependencies both here and in BCMA? Now granted, they're rather unlikely to _change_, but it still seems more obvious?
Okay, I see. Well, if that kind of pattern is the preference, then the code as-is makes sense. The pattern just starts to become obscure when the dependencies of multiple drivers are the same and we start writing "BCMA_POSSIBLE || SSB_POSSIBLE", but the dependencies are the same anyway.
Let us see what others think.
Lukas