Skip to content

Commit eddd98f

Browse files
ulfalizernashif
authored andcommitted
kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on' that aren't there, like maybe 'if' being needed to "hide" a symbol, while 'depends on' just adds a dependency. There are no differences between 'if' and 'depends on'. 'if' is just a shorthand for 'depends on'. They work the same when it comes to creating implicit menus too. The way symbols get "hidden" is through their dependencies not being satisfied ('if'/'depends on' get copied up as a dependency on the prompt). Since 'if' and 'depends on' are the same, an 'if' with just a single symbol in it can be replaced with a 'depends on'. IMO, it's best to avoid 'if' there as a style choice too, because it confuses people into thinking there's deep Kconfig magic going on that requires 'if'. Going for 'depends on' can also remove some nested 'if's, which generates nicer symbol information and docs, because nested 'if's really are so simple/dumb that they just add the dependencies from both 'if's to all symbols within. Replace a bunch of single-symbol 'if's with 'depends on' to despam the Kconfig files a bit and make it clearer how things work. Also do some other minor related dependency refactoring. The replacement isn't complete. Will fix up the rest later. Splitting it a bit to make it more manageable. (Everything above is true for choices, menus, and comments as well.) Detected by tweaking the Kconfiglib parsing code. It's impossible to detect after parsing, because 'if' turns into 'depends on'. Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 1f0089f commit eddd98f

File tree

53 files changed

+90
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+90
-272
lines changed

drivers/clock_control/Kconfig.nrf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ config CLOCK_CONTROL_NRF_FORCE_ALT
1010
This option can be enabled to force an alternative implementation
1111
of the clock control driver.
1212

13-
if !CLOCK_CONTROL_NRF_FORCE_ALT
14-
1513
menuconfig CLOCK_CONTROL_NRF
1614
bool "NRF Clock controller support"
1715
depends on SOC_COMPATIBLE_NRF
16+
depends on !CLOCK_CONTROL_NRF_FORCE_ALT
1817
default y
1918
help
2019
Enable support for the Nordic Semiconductor nRFxx series SoC clock
@@ -130,5 +129,3 @@ config CLOCK_CONTROL_NRF_K32SRC_20PPM
130129
endchoice
131130

132131
endif # CLOCK_CONTROL_NRF
133-
134-
endif #!CLOCK_CONTROL_NRF_FORCE_ALT

drivers/clock_control/Kconfig.stm32

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
# Copyright (c) 2017 RnDity Sp. z o.o.
55
# SPDX-License-Identifier: Apache-2.0
66

7-
if SOC_FAMILY_STM32
8-
97
menuconfig CLOCK_CONTROL_STM32_CUBE
108
bool "STM32 Reset & Clock Control"
9+
depends on SOC_FAMILY_STM32
1110
select USE_STM32_LL_UTILS
1211
select USE_STM32_LL_RCC if SOC_SERIES_STM32MP1X
1312
help
1413
Enable driver for Reset & Clock Control subsystem found
1514
in STM32 family of MCUs
1615

17-
1816
if CLOCK_CONTROL_STM32_CUBE
1917

2018
config CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY
@@ -274,4 +272,3 @@ config CLOCK_STM32_MCO2_DIV
274272
allowed values: 1, 2, 3, 4, 5
275273

276274
endif # CLOCK_CONTROL_STM32_CUBE
277-
endif # SOC_FAMILY_STM32

drivers/counter/Kconfig.dtmr_cmsdk_apb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
# Copyright (c) 2016 Linaro Limited
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if SOC_FAMILY_ARM
7-
86
config TIMER_DTMR_CMSDK_APB
97
bool "ARM CMSDK (Cortex-M System Design Kit) DTMR Timer driver"
8+
depends on SOC_FAMILY_ARM
109
help
1110
The dualtimer (DTMR) present in the platform is used as a timer.
1211
This option enables the support for the timer.
13-
14-
endif # SOC_FAMILY_ARM

drivers/counter/Kconfig.nrfx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,15 @@ config COUNTER_RTC2
5151
select COUNTER_NRF_RTC
5252

5353
# Internal flag which detects if PPI wrap feature is enabled for any instance
54-
if ($(dt_node_has_bool_prop,rtc-0,ppi-wrap) && COUNTER_RTC0) || \
55-
($(dt_node_has_bool_prop,rtc-1,ppi-wrap) && COUNTER_RTC1) || \
56-
($(dt_node_has_bool_prop,rtc-2,ppi-wrap) && COUNTER_RTC2)
57-
5854
config COUNTER_RTC_WITH_PPI_WRAP
59-
bool
60-
default y
55+
def_bool ($(dt_node_has_bool_prop,rtc-0,ppi-wrap) && COUNTER_RTC0) || \
56+
($(dt_node_has_bool_prop,rtc-1,ppi-wrap) && COUNTER_RTC1) || \
57+
($(dt_node_has_bool_prop,rtc-2,ppi-wrap) && COUNTER_RTC2)
6158
select NRFX_PPI if HAS_HW_NRF_PPI
6259
select NRFX_DPPI if HAS_HW_NRF_DPPIC
6360

64-
endif
65-
6661
# Internal flag which detects if fixed top feature is enabled for any instance
67-
if (!$(dt_node_has_bool_prop,rtc-0,fixed-top) && COUNTER_RTC0) || \
68-
(!$(dt_node_has_bool_prop,rtc-1,fixed-top) && COUNTER_RTC1) || \
69-
(!$(dt_node_has_bool_prop,rtc-2,fixed-top) && COUNTER_RTC2)
70-
7162
config COUNTER_RTC_CUSTOM_TOP_SUPPORT
72-
bool
73-
default y
74-
endif
63+
def_bool (!$(dt_node_has_bool_prop,rtc-0,fixed-top) && COUNTER_RTC0) || \
64+
(!$(dt_node_has_bool_prop,rtc-1,fixed-top) && COUNTER_RTC1) || \
65+
(!$(dt_node_has_bool_prop,rtc-2,fixed-top) && COUNTER_RTC2)

drivers/counter/Kconfig.tmr_cmsdk_apb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
# Copyright (c) 2016 Linaro Limited
44
# SPDX-License-Identifier: Apache-2.0
55

6-
if SOC_FAMILY_ARM
7-
86
config TIMER_TMR_CMSDK_APB
97
bool "ARM CMSDK (Cortex-M System Design Kit) Timer driver"
8+
depends on SOC_FAMILY_ARM
109
help
1110
The timers (TMR) present in the platform are used as timers.
1211
This option enables the support for the timers.
13-
14-
endif # SOC_FAMILY_ARM

drivers/crypto/Kconfig.stm32

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ menuconfig CRYPTO_STM32
1111
help
1212
Enable STM32 HAL-based Cryptographic Accelerator driver.
1313

14-
if CRYPTO_STM32
15-
1614
config CRYPTO_STM32_MAX_SESSION
1715
int "Maximum of sessions STM32 crypto driver can handle"
1816
default 2
17+
depends on CRYPTO_STM32
1918
help
2019
This can be used to tweak the amount of sessions the driver
2120
can handle in parallel.
22-
23-
endif # CRYPTO_STM32

drivers/display/Kconfig.microbit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ config MICROBIT_DISPLAY
1212
Enable this to be able to display images and text on the 5x5
1313
LED matrix display on the BBC micro:bit.
1414

15-
if MICROBIT_DISPLAY
16-
1715
config MICROBIT_DISPLAY_STR_MAX
1816
int "Maximum length of strings that can be shown on the display"
1917
range 3 255
2018
default 40
19+
depends on MICROBIT_DISPLAY
2120
help
2221
This value specifies the maximum length of strings that can
2322
be displayed using the mb_display_string() and mb_display_print()
2423
APIs.
25-
26-
endif # MICROBIT_DISPLAY

drivers/display/Kconfig.st7789v

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ menuconfig ST7789V
99
help
1010
Enable driver for ST7789V display driver.
1111

12-
if ST7789V
13-
1412
choice ST7789V_PIXEL_FORMAT
1513
prompt "Color pixel format"
1614
default ST7789V_RGB565
15+
depends on ST7789V
1716
help
1817
Specify the color pixel format for the ST7789V display controller.
1918

@@ -24,5 +23,3 @@ config ST7789V_RGB565
2423
bool "RGB565"
2524

2625
endchoice
27-
28-
endif # ST7789V

drivers/eeprom/Kconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ config EEPROM_SIMULATOR
5757
help
5858
Enable Simulated EEPROM driver.
5959

60-
if EEPROM_SIMULATOR
61-
6260
config EEPROM_SIMULATOR_SIMULATE_TIMING
6361
bool "Enable hardware timing simulation"
62+
depends on EEPROM_SIMULATOR
6463
help
6564
Enable Simulated hardware timing.
6665

@@ -80,6 +79,4 @@ config EEPROM_SIMULATOR_MIN_WRITE_TIME_US
8079

8180
endif # EEPROM_SIMULATOR_SIMULATE_TIMING
8281

83-
endif # EEPROM_SIMULATOR
84-
8582
endif # EEPROM

drivers/espi/Kconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,16 @@ config ESPI_VWIRE_CHANNEL
4040
help
4141
eSPI Controller supports virtual wires channel.
4242

43-
if ESPI_VWIRE_CHANNEL
44-
4543
config ESPI_AUTOMATIC_WARNING_ACKNOWLEDGE
4644
bool "Automatic acknowledge for eSPI HOST warnings"
4745
default y
46+
depends on ESPI_VWIRE_CHANNEL
4847
help
4948
Enable automatic acknowledge from eSPI slave towards eSPI host
5049
whenever it receives suspend or reset warning.
5150
If this is disabled, it means the app wants to be give the opportunity
5251
to prepare for either HOST suspend or reset.
5352

54-
endif # ESPI_VWIRE_CHANNEL
55-
5653
config ESPI_OOB_CHANNEL
5754
bool "eSPI Out-of-band channel"
5855
help

0 commit comments

Comments
 (0)