treewide: change conditional prompt for choices to 'depends on'
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 26 Jun 2024 18:22:00 +0000 (03:22 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 15 Jul 2024 16:08:37 +0000 (01:08 +0900)
While Documentation/kbuild/kconfig-language.rst provides a brief
explanation, there are recurring confusions regarding the usage of a
prompt followed by 'if <expr>'. This conditional controls _only_ the
prompt.

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'. This is reasonable
because you are likely want to enable the block device support. When
EXPERT=y, the prompt is shown, allowing you to toggle BLOCK.

Please note that it is different from 'depends on EXPERT', which would
enable and disable the entire config entry.

However, this conditional prompt has never worked in a choice block.

The following two work in the same way: when EXPERT is disabled, the
choice block is entirely disabled.

[Test Code 1]

    choice
            prompt "choose" if EXPERT

    config A
            bool "A"

    config B
            bool "B"

    endchoice

[Test Code 2]

    choice
            prompt "choose"
            depends on EXPERT

    config A
            bool "A"

    config B
            bool "B"

    endchoice

I believe the first case should hide only the prompt, producing the
default:

   CONFIG_A=y
   # CONFIG_B is not set

The next commit will change (fix) the behavior of the conditional prompt
in choice blocks.

I see several choice blocks wrongly using a conditional prompt, where
'depends on' makes more sense.

To preserve the current behavior, this commit converts such misuses.

I did not touch the following entry in arch/x86/Kconfig:

    choice
            prompt "Memory split" if EXPERT
            default VMSPLIT_3G

This is truly the correct use of the conditional prompt; when EXPERT=n,
this choice block should silently select the reasonable VMSPLIT_3G,
although the resulting PAGE_OFFSET will not be affected anyway.

Presumably, the one in fs/jffs2/Kconfig is also correct, but I converted
it to 'depends on' to avoid any potential behavioral change.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
arch/arm/Kconfig
arch/arm64/Kconfig
arch/mips/Kconfig
arch/powerpc/Kconfig
arch/riscv/Kconfig
fs/jffs2/Kconfig

index ee51152..a5bf65b 100644 (file)
@@ -1482,7 +1482,8 @@ config ARM_ATAG_DTB_COMPAT
          from the ATAG list and store it at run time into the appended DTB.
 
 choice
-       prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
+       prompt "Kernel command line type"
+       depends on ARM_ATAG_DTB_COMPAT
        default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
 
 config ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
@@ -1511,7 +1512,8 @@ config CMDLINE
          memory size and the root device (e.g., mem=64M root=/dev/nfs).
 
 choice
-       prompt "Kernel command line type" if CMDLINE != ""
+       prompt "Kernel command line type"
+       depends on CMDLINE != ""
        default CMDLINE_FROM_BOOTLOADER
 
 config CMDLINE_FROM_BOOTLOADER
index 5d91259..c87d16b 100644 (file)
@@ -2302,7 +2302,8 @@ config CMDLINE
          root device (e.g. root=/dev/nfs).
 
 choice
-       prompt "Kernel command line type" if CMDLINE != ""
+       prompt "Kernel command line type"
+       depends on CMDLINE != ""
        default CMDLINE_FROM_BOOTLOADER
        help
          Choose how the kernel will handle the provided default kernel
index f1aa1bf..8cbc23f 100644 (file)
@@ -2924,7 +2924,8 @@ config BUILTIN_DTB
        bool
 
 choice
-       prompt "Kernel appended dtb support" if USE_OF
+       prompt "Kernel appended dtb support"
+       depends on USE_OF
        default MIPS_NO_APPENDED_DTB
 
        config MIPS_NO_APPENDED_DTB
@@ -2965,7 +2966,8 @@ choice
 endchoice
 
 choice
-       prompt "Kernel command line type" if !CMDLINE_OVERRIDE
+       prompt "Kernel command line type"
+       depends on !CMDLINE_OVERRIDE
        default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
                                         !MACH_LOONGSON64 && !MIPS_MALTA && \
                                         !CAVIUM_OCTEON_SOC
index c88c6d4..68e35b3 100644 (file)
@@ -965,7 +965,8 @@ config CMDLINE
          most cases you will need to specify the root device here.
 
 choice
-       prompt "Kernel command line type" if CMDLINE != ""
+       prompt "Kernel command line type"
+       depends on CMDLINE != ""
        default CMDLINE_FROM_BOOTLOADER
 
 config CMDLINE_FROM_BOOTLOADER
index 0525ee2..48b7faf 100644 (file)
@@ -914,7 +914,8 @@ config CMDLINE
          line here and choose how the kernel should use it later on.
 
 choice
-       prompt "Built-in command line usage" if CMDLINE != ""
+       prompt "Built-in command line usage"
+       depends on CMDLINE != ""
        default CMDLINE_FALLBACK
        help
          Choose how the kernel will handle the provided built-in command
index 7c96bc1..560187d 100644 (file)
@@ -151,8 +151,9 @@ config JFFS2_RUBIN
          RUBINMIPS and DYNRUBIN compressors. Say 'N' if unsure.
 
 choice
-       prompt "JFFS2 default compression mode" if JFFS2_COMPRESSION_OPTIONS
+       prompt "JFFS2 default compression mode"
        default JFFS2_CMODE_PRIORITY
+       depends on JFFS2_COMPRESSION_OPTIONS
        depends on JFFS2_FS
        help
          You can set here the default compression mode of JFFS2 from