linux/scripts/kconfig
Masahiro Yamada d533828ef3 kconfig: fix conditional prompt behavior for choice
When a prompt is followed by "if <expr>", the symbol is configurable
when the if-conditional evaluates to true.

A typical usage is as follows:

    menuconfig BLOCK
            bool "Enable the block layer" if EXPERT
            default y

When EXPERT=n, the prompt is hidden, but this config entry is still
active, and BLOCK is set to its default value 'y'. When EXPERT=y, the
prompt is shown, making BLOCK a user-configurable option.

This usage is common throughout the kernel tree, but it has never worked
within a choice block.

[Test Code]

    config EXPERT
            bool "Allow expert users to modify more options"

    choice
            prompt "Choose" if EXPERT

    config A
            bool "A"

    config B
            bool "B"

    endchoice

[Result]

    # CONFIG_EXPERT is not set

When the prompt is hidden, the choice block should produce the default
without asking for the user's preference. Hence, the output should be:

    # CONFIG_EXPERT is not set
    CONFIG_A=y
    # CONFIG_B is not set

Removing unnecessary hacks fixes the issue.

This commit also changes the behavior of 'select' by choice members.

[Test Code 2]

    config MODULES
            def_bool y
            modules

    config DEP
            def_tristate m

    if DEP

    choice
            prompt "choose"

    config A
            bool "A"
            select C

    endchoice

    config B
            def_bool y
            select D

    endif

    config C
            tristate

    config D
            tristate

The current output is as follows:

    CONFIG_MODULES=y
    CONFIG_DEP=m
    CONFIG_A=y
    CONFIG_B=y
    CONFIG_C=y
    CONFIG_D=m

With this commit, the output will be changed as follows:

    CONFIG_MODULES=y
    CONFIG_DEP=m
    CONFIG_A=y
    CONFIG_B=y
    CONFIG_C=m
    CONFIG_D=m

CONFIG_C will be changed to 'm' because 'select C' will inherit the
dependency on DEP, which is 'm'.

This change is aligned with the behavior of 'select' outside a choice
block; 'select D' depends on DEP, therefore D is selected by (B && DEP).

Note:

With this commit, allmodconfig will set CONFIG_USB_ROLE_SWITCH to 'm'
instead of 'y'. I did not see any build regression with this change.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-07-16 01:08:37 +09:00
..
lxdialog kconfig: lxdialog: remove initialization with A_NORMAL 2024-05-14 23:36:19 +09:00
tests kconfig: remove tristate choice support 2024-07-16 01:08:36 +09:00
.gitignore kconfig: Update all declared targets 2023-01-13 16:29:52 +09:00
array_size.h kconfig: move ARRAY_SIZE to a header 2024-02-19 18:20:41 +09:00
conf.c kconfig: remove sym_get_choice_value() 2024-07-16 01:08:37 +09:00
confdata.c kconfig: change sym_choice_default() to take the choice menu 2024-07-16 01:08:37 +09:00
expr.c kconfig: remove E_LIST expression type 2024-07-16 01:08:37 +09:00
expr.h kconfig: remove E_LIST expression type 2024-07-16 01:08:37 +09:00
gconf-cfg.sh kconfig: add -e and -u options to *conf-cfg.sh scripts 2024-07-16 01:08:36 +09:00
gconf.c kconfig: remove sym_get_choice_value() 2024-07-16 01:08:37 +09:00
gconf.glade scripts/kconfig/gconf.glade Update broken web addresses. 2010-09-17 16:54:42 +02:00
hashtable.h kconfig: add macros useful for hashtable 2024-02-19 18:20:41 +09:00
images.c kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
images.h kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
internal.h kconfig: use generic macros to implement symbol hashtable 2024-02-20 20:47:45 +09:00
lexer.l kconfig: remove 'optional' property support 2024-05-02 19:48:26 +09:00
list_types.h kconfig: import more list macros and inline functions 2024-02-19 18:20:41 +09:00
list.h kconfig: import list_move(_tail) and list_for_each_entry_reverse macros 2024-07-16 01:08:37 +09:00
lkc_proto.h kconfig: remove P_CHOICE property 2024-07-16 01:08:37 +09:00
lkc.h kconfig: change sym_choice_default() to take the choice menu 2024-07-16 01:08:37 +09:00
Makefile kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
mconf-cfg.sh kconfig: add -e and -u options to *conf-cfg.sh scripts 2024-07-16 01:08:36 +09:00
mconf.c kconfig: remove sym_get_choice_value() 2024-07-16 01:08:37 +09:00
menu.c kconfig: fix conditional prompt behavior for choice 2024-07-16 01:08:37 +09:00
merge_config.sh scripts: merge_config: Fix typo in variable name. 2023-03-23 15:27:40 +09:00
mnconf-common.c kconfig: factor out common code shared by mconf and nconf 2023-12-10 15:34:37 +09:00
mnconf-common.h kconfig: factor out common code shared by mconf and nconf 2023-12-10 15:34:37 +09:00
nconf-cfg.sh kconfig: add -e and -u options to *conf-cfg.sh scripts 2024-07-16 01:08:36 +09:00
nconf.c kconfig: remove sym_get_choice_value() 2024-07-16 01:08:37 +09:00
nconf.gui.c kconfig: nconf: Add search jump feature 2023-08-13 21:29:41 +09:00
nconf.h kconfig: nconf: Add search jump feature 2023-08-13 21:29:41 +09:00
parser.y kconfig: remove P_CHOICE property 2024-07-16 01:08:37 +09:00
preprocess.c kconfig: move ARRAY_SIZE to a header 2024-02-19 18:20:41 +09:00
preprocess.h kconfig: split preprocessor prototypes into preprocess.h 2024-02-19 18:20:40 +09:00
qconf-cfg.sh kconfig: add -e and -u options to *conf-cfg.sh scripts 2024-07-16 01:08:36 +09:00
qconf.cc kconfig: remove P_CHOICE property 2024-07-16 01:08:37 +09:00
qconf.h kconfig: pass new conf_changed value to the callback 2024-07-16 01:08:36 +09:00
streamline_config.pl streamline_config.pl: handle also ${CONFIG_FOO} 2023-06-08 11:11:32 +09:00
symbol.c kconfig: fix conditional prompt behavior for choice 2024-07-16 01:08:37 +09:00
util.c kconfig: convert linked list of files to hash table 2024-02-20 20:44:48 +09:00