Skip to content

kconfig: stop implification of choice type

Masahiro Yamada linux-doc linux-kbuild lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2rapidio: specify the type for tristate choice explicitlydrivers/rapidio/Kconfig+1 -11 reply
2/2kconfig: do not imply the type of choice from the first entryDocumentation/kbuild/kconfig-language.rst scripts/kconfig/menu.c scripts/kconfig/parser.y +2 more+6 -161 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchNicolas Schier
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] kconfig: stop implification of choice type

There are two types supported for the choice statement, "bool" and "tristate".

There is no ambiguity if you explicitly specifiy the type of the choice.

For example

    choice
            bool "choose"

       ...

    endchoice

Or,

    choice
            tristate "choose"

       ...

    endchoice

Those are valid code, and clear about the behavior.

However, if you see the reality in the kernel code, most of people omit the type definition.

Usually, the choice is written like this:

    choice
            prompt "choose"

       ...

    endchoice

The "prompt" does not specify the type at all.

You may wonder how Kconfig knows the choice type then.

When the choice type is not specified, Kconfig infers it from the first entry within the choice block.

In the following, the choice type is bool because the first entry, CONFIG_A, is bool.

choice
prompt "choose"

config A
bool "A"

config B
bool "B"

endchoice

As described in 2/2, this has a bug when "if" ... "endif" exists within a "choice" ... "endchoice".

Of course, I can fix this bug, but the value of this feature is questionable.

This patch set stop the type implification. Instead, make the default type of the choice "bool".

This is reasonable because 99% of choice blocks are bool.

The only user of tristate choice is drivers/rapidio/Kconfig. (although that choice is unneeded because it cotains a single entry, RAPIDIO_ENUM_BASIC)

It changed it to specify "tristate" explicitly.

Masahiro Yamada (2):
rapidio: specify the type for tristate choice explicitly
kconfig: do not imply the type of choice from the first entry

 Documentation/kbuild/kconfig-language.rst             |  4 +---
 drivers/rapidio/Kconfig                               |  2 +-
 scripts/kconfig/menu.c                                | 11 -----------
 scripts/kconfig/parser.y                              |  3 +++
 scripts/kconfig/tests/choice/Kconfig                  |  2 +-
 scripts/kconfig/tests/choice_value_with_m_dep/Kconfig |  2 +-
 6 files changed, 7 insertions(+), 17 deletions(-)
Signature · 1 line
2.40.1