History log of /linux-master/scripts/kconfig/menu.c
Revision Date Author Comments
# 7e3465f6 23-Mar-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: do not reparent the menu inside a choice block

The boolean 'choice' is used to list exclusively selected config
options.

You must not add a dependency between choice members, because such a
dependency would create an invisible entry.

In the following test case, it is impossible to choose 'C'.

[Test Case 1]

choice
prompt "Choose one, but how to choose C?"

config A
bool "A"

config B
bool "B"

config C
bool "C"
depends on A

endchoice

Hence, Kconfig shows the following error message:

Kconfig:1:error: recursive dependency detected!
Kconfig:1: choice <choice> contains symbol C
Kconfig:10: symbol C is part of choice A
Kconfig:4: symbol A is part of choice <choice>
For a resolution refer to Documentation/kbuild/kconfig-language.rst
subsection "Kconfig recursive dependency limitations"

However, Kconfig does not report anything for the following similar code:

[Test Case 2]

choice
prompt "Choose one, but how to choose B?"

config A
bool "A"

config B
bool "B"
depends on A

config C
bool "C"

endchoice

This is because menu_finalize() reparents the menu tree when an entry
depends on the preceding one.

With reparenting, the menu tree:

choice
|- A
|- B
\- C

... will be transformed into the following structure:

choice
|- A
| \- B
\- C

Consequently, Kconfig considers only 'A' and 'C' as choice members.
This behavior is awkward. The second test case should be an error too.

This commit stops reparenting inside a choice.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 4957515b 10-Mar-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: check prompt for choice while parsing

This can be checked on-the-fly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# bedf9236 02-Mar-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: use linked list in get_symbol_str() to iterate over menus

Currently, get_symbol_str() uses a tricky approach to traverse the
associated menus.

With relevant menus now linked to the symbol using a linked list,
use list_for_each_entry() for iterating on the menus.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


# e0492219 02-Mar-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: link menus to a symbol

Currently, there is no direct link from (struct symbol) to (struct menu).

It is still possible to access associated menus through the P_SYMBOL
property, because property::menu is the relevant menu entry, but it
results in complex code, as seen in get_symbol_str().

Use a linked list for simpler traversal of relevant menus.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>


# 7d5f52a4 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: do not imply the type of choice value

Do not feed back the choice type to choice values.

Each choice value should explicitly specify 'bool' or 'tristate',
as all the Kconfig files already do. If the type were missing,
"config symbol defined without type" would be shown.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 4dae9cf5 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: split list_head into a separate header

The struct list_head is often embedded in other structures, while other
code is used in C functions.

By separating struct list_head into its own header, other headers are no
longer required to include the entire list.h.

This is similar to the kernel space, where struct list_head is defined
in <linux/types.h> instead of <linux/list.h>.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 5b058034 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change file_lookup() to return the file name

Currently, file_lookup() returns a pointer to (struct file), but the
callers use only file->name.

Make it return the ->name member directly.

This adjustment encapsulates struct file and file_list as internal
implementation.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 8facc5f3 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move the file and lineno in struct file to struct buffer

struct file has two link nodes, 'next' and 'parent'.

The former is used to link files in the 'file_list' linked list,
which manages the list of Kconfig files seen so far.

The latter is used to link files in the 'current_file' linked list,
which manages the inclusion ("source") tree.

The latter should be tracked together with the lexer state.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 1a90b0cd 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: associate struct property with file name directly

struct property is linked to struct file for diagnostic purposes.
It is always used to retrieve the file name through prop->file->name.

Associate struct property with the file name directly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 40bab83a 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: associate struct menu with file name directly

struct menu is linked to struct file for diagnostic purposes.
It is always used to retrieve the file name through menu->file->name.

Associate struct menu with the file name directly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 1d7c4f10 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove zconf_curname() and zconf_lineno()

Now zconf_curname() and zconf_lineno() are so simple that they just
return cur_filename, cur_lineno, respectively.

Remove these functions, and then use cur_filename and cur_lineno
directly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 092e39d1 03-Dec-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: squash menu_has_help() and menu_get_help()

menu_has_help() and menu_get_help() functions are only used within
menu_get_ext_help().

Squash them into menu_get_ext_help(). It revealed the if-conditional
in menu_get_help() was unneeded, as menu_has_help() has already checked
that menu->help is not NULL.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 356f0cb7 15-Jul-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: menuconfig: remove jump_key::index

You do not need to remember the index of each jump key because you can
count it up after a key is pressed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Jesse Taube <Mr.Bossman075@gmail.com>


# e14f1242 15-Jul-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: menuconfig: simplify global jump key assignment

Commit 95ac9b3b585d ("menuconfig: Assign jump keys per-page instead
of globally") injected a lot of hacks to the bottom of the textbox
infrastructure.

I reverted many of them without changing the behavior. (almost)
Now, the key markers are inserted when constructing the search result
instead of updating the text buffer on-the-fly.

The buffer passed to the textbox got back to a constant string.
The ugly casts from (const char *) to (char *) went away.

A disadvantage is that the same key numbers might be displayed multiple
times in the dialog if you use a huge window (but I believe it is
unlikely to happen).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Jesse Taube <Mr.Bossman075@gmail.com>


# 1791360c 13-Nov-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove unneeded variable in get_prompt_str()

The variable 'accessible' is redundant.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 7a263a04 23-Oct-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix segmentation fault in menuconfig search

Since commit d05377e184fc ("kconfig: Create links to main menu items
in search"), menuconfig shows a jump key next to "Main menu" if the
nearest visible parent is the rootmenu. If you press that jump key,
menuconfig crashes with a segmentation fault.

For example, do this:

$ make ARCH=arm64 allnoconfig menuconfig

Press '/' to search for the string "ACPI". Press '1' to choose
"(1) Main menu". Then, menuconfig crashed with a segmentation fault.

The following code in search_conf()

conf(targets[i]->parent, targets[i]);

results in NULL pointer dereference because targets[i] is the rootmenu,
which does not have a parent.

Commit d05377e184fc tried to fix the issue of top-level items not having
a jump key, but adding the "Main menu" was not the right fix.

The correct fix is to show the searched item itself. This fixes another
weird behavior described in the comment block.

Fixes: d05377e184fc ("kconfig: Create links to main menu items in search")
Reported-by: Johannes Zink <j.zink@pengutronix.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Tested-by: Johannes Zink <j.zink@pengutronix.de>


# 03764b30 12-Sep-2022 Zeng Heng <zengheng4@huawei.com>

Kconfig: remove unused function 'menu_get_root_menu'

There is nowhere calling `menu_get_root_menu` function,
so remove it.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# d05377e1 13-Sep-2021 Ariel Marcovitch <arielmarcovitch@gmail.com>

kconfig: Create links to main menu items in search

When one searches for a main menu item, links aren't created for it like
with the rest of the symbols.

This happens because we trace the item until we get to the rootmenu, but
we don't include it in the path of the item. The rationale was probably
that we don't want to show the main menu in the path of all items,
because it is redundant.

However, when an item has only the rootmenu in its path it should be
included, because this way the user can jump to its location.

Add a 'Main menu' entry in the 'Location:' section for the kconfig
items.

This makes the 'if (i > 0)' superfluous because each item with prompt
will have at least one menu in its path.

Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# a77a05dc 13-Apr-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: split menu.c out of parser.y

Compile menu.c as an independent compilation unit.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 6dd85ff1 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change "modules" from sub-option to first-level attribute

Now "modules" is the only member of the "option" property.

Remove "option", and move "modules" to the top level property.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# ab838577 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove allnoconfig_y option

Now that the only user, CONFIG_EMBEDDED has stopped using this option,
remove it entirely.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# b75b0a81 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change defconfig_list option to environment variable

"defconfig_list" is a weird option that defines a static symbol that
declares the list of base config files in case the .config does not
exist yet.

This is quite different from other normal symbols; we just abused the
"string" type and the "default" properties to list out the input files.
They must be fixed values since these are searched for and loaded in
the parse stage.

It is an ugly hack, and should not exist in the first place. Providing
this feature as an environment variable is a saner approach.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 644a4b6c 13-Apr-2020 Masahiro Yamada <masahiroy@kernel.org>

kconfig: do not assign a variable in the return statement

I am not a big fan of doing assignment in a return statement.
Split it into two lines.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# a9609686 17-Dec-2019 Thomas Hebb <tommyhebb@gmail.com>

kconfig: fix nesting of symbol help text

When we generate the help text of a symbol (e.g. when a user presses '?'
in menuconfig), we do two things:

1. We iterate through every prompt that belongs to that symbol,
printing its text and its location in the menu tree.
2. We print symbol-wide information that's not linked to a particular
prompt, such as what it selects/is selected by and what it
implies/is implied by.

Each prompt we print for 1 starts with a line that's not indented
indicating where the prompt is defined, then continues with indented
lines that describe properties of that particular definition.

Once we get to 2, however, we print all the global data indented as
well! Visually, this makes it look like the symbol-wide data is
associated with the last prompt we happened to print rather than
the symbol as a whole.

Fix this by removing the indentation for symbol-wide information.

Before:

Symbol: CPU_FREQ [=n]
Type : bool
Defined at drivers/cpufreq/Kconfig:4
Prompt: CPU Frequency scaling
Location:
-> CPU Power Management
-> CPU Frequency scaling
Selects: SRCU [=n]
Selected by [n]:
- ARCH_SA1100 [=n] && <choice>

After:

Symbol: CPU_FREQ [=n]
Type : bool
Defined at drivers/cpufreq/Kconfig:4
Prompt: CPU Frequency scaling
Location:
-> CPU Power Management
-> CPU Frequency scaling
Selects: SRCU [=n]
Selected by [n]:
- ARCH_SA1100 [=n] && <choice>

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 3460d0bc 17-Dec-2019 Thomas Hebb <tommyhebb@gmail.com>

kconfig: distinguish between dependencies and visibility in help text

Kconfig makes a distinction between dependencies (defined by "depends
on" expressions and enclosing "if" blocks) and visibility (which
includes all dependencies, but also includes inline "if" expressions of
individual properties as well as, for prompts, "visible if" expressions
of enclosing menus).

Before commit bcdedcc1afd6 ("menuconfig: print more info for symbol
without prompts"), the "Depends on" lines of a symbol's help text
indicated the visibility of the prompt property they appeared under.
After bcdedcc1afd, there was always only a single "Depends on" line,
which indicated the visibility of the first P_SYMBOL property of the
symbol. Since P_SYMBOLs never have inline if expressions, this was in
effect the same as the dependencies of the menu item that the P_SYMBOL
was attached to.

Neither of these situations accurately conveyed the dependencies of a
symbol--the first because it was actually the visibility, and the second
because it only showed the dependencies from a single definition.

With this series, we are back to printing separate dependencies for each
definition, but we print the actual dependencies (rather than the
visibility) in the "Depends on" line. However, it can still be useful to
know the visibility of a prompt, so this patch adds a "Visible if" line
that shows the visibility only if the visibility is different from the
dependencies (which it isn't for most prompts in Linux).

Before:

Symbol: THUMB2_KERNEL [=n]
Type : bool
Defined at arch/arm/Kconfig:1417
Prompt: Compile the kernel in Thumb-2 mode
Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n]
Location:
-> Kernel Features
Selects: ARM_UNWIND [=n]

After:

Symbol: THUMB2_KERNEL [=n]
Type : bool
Defined at arch/arm/Kconfig:1417
Prompt: Compile the kernel in Thumb-2 mode
Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n]
Visible if: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] && !CPU_THUMBONLY [=n]
Location:
-> Kernel Features
Selects: ARM_UNWIND [=n]

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# edda15f2 17-Dec-2019 Thomas Hebb <tommyhebb@gmail.com>

kconfig: list all definitions of a symbol in help text

In Kconfig, each symbol (representing a config option) can be defined in
multiple places. Each definition may or may not have a prompt, which
allows the option to be set via an interface like menuconfig. Each
definition has a set of dependencies, which determine whether its prompt
is visible and whether other pieces of the definition, like a default
value, take effect.

Historically, a symbol's help text (i.e. what's shown when a user
presses '?' in menuconfig) contained some symbol-wide information not
tied to any particular definition (e.g. what other symbols it selects)
as well as the location (file name and line number) and dependencies of
each prompt. Notably, the help text did not show the location or
dependencies of definitions without prompts.

Because this made it hard to reason about symbols that had no prompts,
commit bcdedcc1afd6 ("menuconfig: print more info for symbol without
prompts") changed the help text so that, instead of containing the
location and dependencies of each prompt, it contained the location and
dependencies of the symbol's first definition, regardless of whether or
not that definition had a prompt.

For symbols with only one definition, that change makes sense. However,
it breaks down for symbols with multiple definitions: each definition
has its own set of dependencies (the `dep` field of `struct menu`), and
those dependencies are ORed together to get the symbol's dependency list
(the `dir_dep` field of `struct symbol`). By printing only the
dependencies of the first definition, the help text misleads users into
believing that an option is more narrowly-applicable than it actually
is.

For an extreme example of this, we can look at the SYS_TEXT_BASE symbol
in the Das U-Boot project (version 2019.10), which also uses Kconfig. (I
unfortunately could not find an illustrative example in Linux.) This
config option specifies the load address of the built binary and, as
such, is applicable to basically every configuration possible. And yet,
without this patch, its help text is as follows:

Symbol: SYS_TEXT_BASE [=]
Type : hex
Prompt: U-Boot base address
Location:
-> ARM architecture
Prompt: Text Base
Location:
-> Boot images
Defined at arch/arm/mach-aspeed/Kconfig:9
Depends on: ARM [=n] && ARCH_ASPEED [=n]

The help text indicates that the option is applicable only for a
specific unselected architecture (aspeed), because that architecture's
promptless definition (which just sets a default value), happens to be
the first one seen. No definition or dependency information is printed
for either of the two prompts listed.

Because source locations and dependencies are fundamentally properties
of definitions and not of symbols, we should treat them as such. This
patch brings back the pre-bcdedcc1afd6 behavior for definitions with
prompts but also separately prints the location and dependencies of
those without prompts, solving the original problem in a different way.
With this change, our SYS_TEXT_BASE example becomes

Symbol: SYS_TEXT_BASE [=]
Type : hex
Defined at arch/arm/mach-stm32mp/Kconfig:83
Prompt: U-Boot base address
Depends on: ARM [=n] && ARCH_STM32MP [=n]
Location:
-> ARM architecture
Defined at Kconfig:532
Prompt: Text Base
Depends on: !NIOS2 [=n] && !XTENSA [=n] && !EFI_APP [=n]
Location:
-> Boot images
Defined at arch/arm/mach-aspeed/Kconfig:9
Depends on: ARM [=n] && ARCH_ASPEED [=n]
Defined at arch/arm/mach-socfpga/Kconfig:25
Depends on: ARM [=n] && ARCH_SOCFPGA [=n]
<snip>
Defined at board/sifive/fu540/Kconfig:15
Depends on: RISCV [=n] && TARGET_SIFIVE_FU540 [=n]

which is a much more accurate representation.

Note that there is one notable difference between what gets printed for
prompts after this change and what got printed before bcdedcc1afd6: the
"Depends on" line now accurately represents the prompt's dependencies
instead of conflating those with the prompt's visibility (which can
include extra conditions). See the patch later in this series titled
"kconfig: distinguish between dependencies and visibility in help text"
for more details and better handling of that nuance.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# adf7c5bd 16-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kconfig: squash prop_alloc() into menu_add_prop()

prop_alloc() is only called from menu_add_prop(). Squash it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 2ffeef61 16-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove 'prompt' argument from menu_add_prop()

This function no longer uses the 'prompt' argument.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 024352ff 16-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move prompt handling to menu_add_prompt() from menu_add_prop()

menu_add_prompt() is the only function that calls menu_add_prop() with
non-NULL prompt.

So, the code inside the if-conditional block of menu_add_prop() can be
moved to menu_add_prompt().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# de026ca9 16-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kconfig: use parent->dep as the parentdep of 'menu'

In menu_finalize(), the dependency of a menu entry is propagated
downwards.

For the 'menu', parent->dep and parent->prompt->visible.expr have
the same expression. Both accumulate the 'depends on' of itself and
upper menu entries.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# f64048a2 16-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove the rootmenu check in menu_add_prop()

This reverts commit ba6ff60d5eb4 ("kconfig: don't emit warning upon
rootmenu's prompt redefinition").

At that time, rootmenu.prompt was always set first, then it was set
again if a "mainmenu" statement was specified in the Kconfig file.

This is no longer the case since commit 0724a7c32a54 ("kconfig: Don't
leak main menus during parsing"). Remove the unneeded check.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 0c874100 18-Dec-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: convert to SPDX License Identifier

All files in lxdialog/ are licensed under GPL-2.0+, and the rest are
under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/.

Documentation/process/license-rules.rst does not suggest anything
about the flex/bison files. Because flex does not accept the C++
comment style at the very top of a file, I used the C style for
zconf.l, and so for zconf.y for consistency.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# ce2164ab 11-Dec-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: refactor scanning and parsing "option" properties

For the keywords "modules", "defconfig_list", and "allnoconfig_y",
the lexer should pass specific tokens instead of generic T_WORD.

This simplifies both the lexer and the parser.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 693359f7 03-Jul-2018 Dirk Gouders <dirk@gouders.net>

kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE

Over time, the use of the flag SYMBOL_AUTO changed from initially
marking three automatically generated symbols ARCH, KERNELRELEASE and
UNAME_RELEASE to today's effect of protecting symbols from being
written out.

Currently, only symbols of type CHOICE and those with option
defconf_list set have that flag set.

Reflect that change in semantics in the flag's name.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 104daea1 28-May-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: reference environment variables directly and remove 'option env='

To get access to environment variables, Kconfig needs to define a
symbol using "option env=" syntax. It is tedious to add a symbol entry
for each environment variable given that we need to define much more
such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability
in Kconfig.

Adding '$' for symbol references is grammatically inconsistent.
Looking at the code, the symbols prefixed with 'S' are expanded by:
- conf_expand_value()
This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
- sym_expand_string_value()
This is used to expand strings in 'source' and 'mainmenu'

All of them are fixed values independent of user configuration. So,
they can be changed into the direct expansion instead of symbols.

This change makes the code much cleaner. The bounce symbols 'SRCARCH',
'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.

sym_init() hard-coding 'UNAME_RELEASE' is also gone. 'UNAME_RELEASE'
should be replaced with an environment variable.

ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
without '$' prefix.

The new syntax is addicted by Make. The variable reference needs
parentheses, like $(FOO), but you can omit them for single-letter
variables, like $F. Yet, in Makefiles, people tend to use the
parenthetical form for consistency / clarification.

At this moment, only the environment variable is supported, but I will
extend the concept of 'variable' later on.

The variables are expanded in the lexer so we can simplify the token
handling on the parser side.

For example, the following code works.

[Example code]

config MY_TOOLCHAIN_LIST
string
default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)"

[Result]

$ make -s alldefconfig && tail -n 1 .config
CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Kees Cook <keescook@chromium.org>


# 694c49a7 22-May-2018 Sam Ravnborg <sam@ravnborg.org>

kconfig: drop localization support

The localization support is broken and appears unused.
There is no google hits on the update-po-config target.
And there is no recent (5 years) activity related to the localization.

So lets just drop this as it is no longer used.

Suggested-by: Ulf Magnusson <ulfalizer@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# d9119b59 24-Feb-2018 Eugeniu Rosca <erosca@de.adit-jv.com>

kconfig: Print reverse dependencies in groups

Surprisingly or not, disabling a CONFIG option (which is assumed to
be unneeded) may be not so trivial. Especially it is not trivial, when
this CONFIG option is selected by a dozen of other configs. Before the
moment commit 1ccb27143360 ("kconfig: make "Selected by:" and
"Implied by:" readable") popped up in v4.16-rc1, it was an absolute pain
to break down the "Selected by" reverse dependency expression in order
to identify all those configs which select (IOW *do not allow
disabling*) a certain feature (assumed to be not needed).

This patch tries to make one step further by putting at users'
fingertips the revdep top level OR sub-expressions grouped/clustered by
the tristate value they evaluate to. This should allow the users to
directly concentrate on and tackle the _active_ reverse dependencies.

To give some numbers and quantify the complexity of certain reverse
dependencies, assuming commit 617aebe6a97e ("Merge tag
'usercopy-v4.16-rc1' of
git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux"), ARCH=arm64
and vanilla arm64 defconfig, here is the top 10 CONFIG options with
the highest amount of top level "||" sub-expressions/tokens that make
up the final "Selected by" reverse dependency expression.

| Config | All revdep | Active revdep |
|-------------------|------------|---------------|
| REGMAP_I2C | 212 | 9 |
| CRC32 | 167 | 25 |
| FW_LOADER | 128 | 5 |
| MFD_CORE | 124 | 9 |
| FB_CFB_IMAGEBLIT | 114 | 2 |
| FB_CFB_COPYAREA | 111 | 2 |
| FB_CFB_FILLRECT | 110 | 2 |
| SND_PCM | 103 | 2 |
| CRYPTO_HASH | 87 | 19 |
| WATCHDOG_CORE | 86 | 6 |

The story behind the above is that users need to visually
review/evaluate 212 expressions which *potentially* select REGMAP_I2C
in order to identify the expressions which *actually* select REGMAP_I2C,
for a particular ARCH and for a particular defconfig used.

To make this experience smoother, change the way reverse dependencies
are displayed to the user from [1] to [2].

[1] Old representation of DMA_ENGINE_RAID:
Selected by:
- AMCC_PPC440SPE_ADMA [=n] && DMADEVICES [=y] && (440SPe || 440SP)
- BCM_SBA_RAID [=m] && DMADEVICES [=y] && (ARM64 [=y] || ...
- FSL_RAID [=n] && DMADEVICES [=y] && FSL_SOC && ...
- INTEL_IOATDMA [=n] && DMADEVICES [=y] && PCI [=y] && X86_64
- MV_XOR [=n] && DMADEVICES [=y] && (PLAT_ORION || ARCH_MVEBU [=y] ...
- MV_XOR_V2 [=y] && DMADEVICES [=y] && ARM64 [=y]
- XGENE_DMA [=n] && DMADEVICES [=y] && (ARCH_XGENE [=y] || ...
- DMATEST [=n] && DMADEVICES [=y] && DMA_ENGINE [=y]

[2] New representation of DMA_ENGINE_RAID:
Selected by [y]:
- MV_XOR_V2 [=y] && DMADEVICES [=y] && ARM64 [=y]
Selected by [m]:
- BCM_SBA_RAID [=m] && DMADEVICES [=y] && (ARM64 [=y] || ...
Selected by [n]:
- AMCC_PPC440SPE_ADMA [=n] && DMADEVICES [=y] && (440SPe || ...
- FSL_RAID [=n] && DMADEVICES [=y] && FSL_SOC && ...
- INTEL_IOATDMA [=n] && DMADEVICES [=y] && PCI [=y] && X86_64
- MV_XOR [=n] && DMADEVICES [=y] && (PLAT_ORION || ARCH_MVEBU [=y] ...
- XGENE_DMA [=n] && DMADEVICES [=y] && (ARCH_XGENE [=y] || ...
- DMATEST [=n] && DMADEVICES [=y] && DMA_ENGINE [=y]

Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 9a47ceec 20-Feb-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: clean-up reverse dependency help implementation

This commit splits out the special E_OR handling ('-' instead of '||')
into a dedicated helper expr_print_revdev().

Restore the original expr_print() prior to commit 1ccb27143360
("kconfig: make "Selected by:" and "Implied by:" readable").

This makes sense because:

- We need to chop those expressions only when printing the reverse
dependency, and only when E_OR is encountered

- Otherwise, it should be printed as before, so fall back to
expr_print()

This also improves the behavior; for a single line, it was previously
displayed in the same line as "Selected by", like this:

Selected by: A [=n] && B [=n]

This will be displayed in a new line, consistently:

Selected by:
- A [=n] && B [=n]

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>


# f4bc1eef 16-Feb-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list

The 'defconfig_list' is a weird attribute. If the '.config' is
missing, conf_read_simple() iterates over all visible defaults,
then it uses the first one for which fopen() succeeds.

config DEFCONFIG_LIST
string
depends on !UML
option defconfig_list
default "/lib/modules/$UNAME_RELEASE/.config"
default "/etc/kernel-config"
default "/boot/config-$UNAME_RELEASE"
default "$ARCH_DEFCONFIG"
default "arch/$ARCH/defconfig"

However, like other symbols, the first visible default is always
written out to the .config file. This might be different from what
has been actually used.

For example, on my machine, the third one "/boot/config-$UNAME_RELEASE"
is opened, like follows:

$ rm .config
$ make oldconfig 2>/dev/null
scripts/kconfig/conf --oldconfig Kconfig
#
# using defaults found in /boot/config-4.4.0-112-generic
#
*
* Restart config...
*
*
* IRQ subsystem
*
Expose irq internals in debugfs (GENERIC_IRQ_DEBUGFS) [N/y/?] (NEW)

However, the resulted .config file contains the first one since it is
visible:

$ grep CONFIG_DEFCONFIG_LIST .config
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"

In order to stop confusing people, prevent this CONFIG option from
being written to the .config file.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>


# 1ccb2714 25-Jan-2018 Petr Vorel <petr.vorel@gmail.com>

kconfig: make "Selected by:" and "Implied by:" readable

Reverse dependency expressions can get rather unwieldy, especially if
a symbol is selected by more than a handful of other symbols. I.e. it's
possible to have near endless expressions like:
A && B && !C || D || F && (G || H) || [...]

Chop these expressions into actually readable chunks:
- A && B && !C
- D
- F && (G || H)
- [...]

I.e. transform the top level OR tokens into newlines and prepend each
line with a minus. This makes the "Selected by:" and "Implied by:" blurb
much easier to read. This is done only if there is more than one top
level OR. "Depends on:" and "Range :" were deliberately left as they are.

Based on idea from Paul Bolle.

Suggested-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b5368801 16-Jan-2018 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Clarify menu and 'if' dependency propagation

It is not obvious that the last two cases refer to menus and ifs,
respectively, in the conditional that sets 'parentdep'.

Automatic submenu creation is done later, so the parent can't be a
symbol here.

No functional changes. Only comments added.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 9d1a9e8b 14-Jan-2018 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Document 'if' flattening logic

It is not obvious that this might refer to an 'if', making the code
pretty cryptic:

if (menu->list && (!menu->prompt || !menu->prompt->text)) {

Kconfig keeps the 'if' menu nodes even after flattening. Reflect that in
the example to be accurate.

No functional changes. Only comments added.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# d3465af6 14-Jan-2018 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Clarify choice dependency propagation

It's easy to miss that choices are special-cased to pass on their mode
as the parent dependency.

No functional changes. Only comments added.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 3e41ba05 14-Jan-2018 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Document SYMBOL_OPTIONAL logic

Not obvious, especially if you don't already know how choices are
implemented.

No functional changes. Only comments added.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b92d804a 15-Dec-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: drop 'boolean' keyword

No more users of this keyword. Drop it according to the notice by
commit 6341e62b212a ("kconfig: use bool instead of boolean for type
definition attributes").

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>


# df60f4b9 08-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Remove menu_end_entry()

menu_end_entry() is empty and completely unused as far as I can tell:

$ git log -G menu_end_entry --oneline
a02f057 [PATCH] kconfig: improve error handling in the parser
1da177e Linux-2.6.12-rc2

Last one is the initial Git commit, where menu_end_entry() is empty as
well. I couldn't find anything that redefined it on Google either.

It might be a debugging helper for setting a breakpoint after each
config, menuconfig, and comment is parsed. IMO it hurts more than it
helps in that case by making the parsing code look more complicated at a
glance than it really is, and I suspect it doesn't get used much.

Tested by running the Kconfiglib test suite, which indirectly verifies
that the .config files generated by the C implementation for each
defconfig file in the kernel stays the same.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 05cccce5 08-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Document automatic submenu creation code

It's tricky to figure out what it does (and how) without staring at the
code for a long time. Document it to make it more transparent.

No functional changes. Only comments added.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 7cf33f88 08-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Fix choice symbol expression leak

When propagating dependencies from parents after parsing, an expression
node is allocated if the parent symbol is a 'choice'. This node was
never freed.

Outline of leak:

if (sym && sym_is_choice(sym)) {
...
*Allocate (in this case only)*
parentdep = expr_alloc_symbol(sym);
} else if (parent->prompt)
parentdep = parent->prompt->visible.expr;
else
parentdep = parent->dep;

for (menu = parent->list; menu; menu = menu->next) {
...
*Copy*
basedep = expr_alloc_and(expr_copy(parentdep), basedep);
...
}
*parentdep lost if the parent is a choice!*

Fix by freeing 'parentdep' after the loop if the parent symbol is a
choice. Note that this only frees the expression node and not the choice
symbol itself.

Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

LEAK SUMMARY:
definitely lost: 1,608 bytes in 67 blocks
...

Summary after the fix:

LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
...

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# ae7440ef 08-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Fix automatic menu creation mem leak

expr_trans_compare() always allocates and returns a new expression,
giving the following leak outline:

...
*Allocate*
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
...
for (menu = parent->next; menu; menu = menu->next) {
...
*Copy*
dep2 = expr_copy(basedep);
...
*Free copy*
expr_free(dep2);
}
*basedep lost!*

Fix by freeing 'basedep' after the loop.

Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

LEAK SUMMARY:
definitely lost: 344,376 bytes in 14,349 blocks
...

Summary after the fix:

LEAK SUMMARY:
definitely lost: 44,448 bytes in 1,852 blocks
...

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# f77850d3 05-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Clean up modules handling and fix crash

Kconfig currently doesn't handle 'm' appearing in a Kconfig file before
the modules symbol is defined (the symbol with 'option modules'). The
problem is the following code, which runs during parsing:

/* change 'm' into 'm' && MODULES */
if (e->left.sym == &symbol_mod)
return expr_alloc_and(e, expr_alloc_symbol(modules_sym));

If the modules symbol has not yet been defined, modules_sym is NULL,
giving an invalid expression.

Here is a test file where both BEFORE_1 and BEFORE_2 trigger a segfault.
If the modules symbol is removed, all symbols trigger segfaults.

config BEFORE_1
def_tristate y if m

if m
config BEFORE_2
def_tristate y
endif

config MODULES
def_bool y
option modules

config AFTER_1
def_tristate y if m

if m
config AFTER_2
def_tristate y
endif

Fix the issue by rewriting 'm' in menu_finalize() instead. This function
runs after parsing and is the proper place to do it. The following
existing code in conf_parse() in zconf.y ensures that the modules symbol
exists at that point:

if (!modules_sym)
modules_sym = sym_find( "n" );

...

menu_finalize(&rootmenu);

The following tests were done to ensure no functional changes for
configurations that don't reference 'm' before the modules symbol:

- zconfdump(stdout) was run with ARCH=x86 and ARCH=arm before
and after the change and verified to produce identical output.
This function prints all symbols, choices, and menus together
with their properties and their dependency expressions. A
rewritten 'm' appears as 'm && MODULES'.

A small annoyance is that the assert(len != 0) in xfwrite()
needs to be disabled in order to use zconfdump(), because it
chokes on e.g. 'default ""'.

- The Kconfiglib test suite was run to indirectly verify that
alldefconfig, allyesconfig, allnoconfig, and all defconfigs in
the kernel still generate the same final .config.

- Valgrind was used to check for memory errors and (new) memory
leaks.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# fa8cedae 05-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Clarify expression rewriting

menu_finalize() is one of the more opaque parts of Kconfig, and I need
to make some changes to it to fix an issue related to modules. Add some
comments related to expression rewriting and dependency propagation as a
review aid. They will also help other people trying to understand the
code.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 9a826842 05-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Rename menu_check_dep() to rewrite_m()

More directly describes the only thing it does.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 2c37e084 03-Oct-2017 Ulf Magnusson <ulfalizer@gmail.com>

kconfig: Warn if choice default is not in choice

This will catch mistakes like in the following real-world example, where
a "CONFIG_" prefix snuck in, making an undefined symbol the default:

choice
prompt "Compiler optimization level"
default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE

config CC_OPTIMIZE_FOR_PERFORMANCE
...

config CC_OPTIMIZE_FOR_SIZE
...

endchoice

This now prints the following warning:

init/Kconfig:1036:warning: choice default symbol 'CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE' is not contained in the choice

Cases where the default symbol belongs to the wrong choice are also
detected.

(The mistake is harmless here: Since the default symbol is not visible,
the choice falls back on using the first visible symbol as the default,
which is CC_OPTIMIZE_FOR_PERFORMANCE, as intended.)

Discovered while playing around with Kconfiglib
(https://github.com/ulfalizer/Kconfiglib).

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 237e3ad0 10-Nov-2016 Nicolas Pitre <nico@fluxnic.net>

Kconfig: Introduce the "imply" keyword

The "imply" keyword is a weak version of "select" where the target
config symbol can still be turned off, avoiding those pitfalls that come
with the "select" keyword.

This is useful e.g. with multiple drivers that want to indicate their
ability to hook into a secondary subsystem while allowing the user to
configure that subsystem out without also having to unset these drivers.

Currently, the same effect can almost be achieved with:

config DRIVER_A
tristate

config DRIVER_B
tristate

config DRIVER_C
tristate

config DRIVER_D
tristate

[...]

config SUBSYSTEM_X
tristate
default DRIVER_A || DRIVER_B || DRIVER_C || DRIVER_D || [...]

This is unwieldy to maintain especially with a large number of drivers.
Furthermore, there is no easy way to restrict the choice for SUBSYSTEM_X
to y or n, excluding m, when some drivers are built-in. The "select"
keyword allows for excluding m, but it excludes n as well. Hence
this "imply" keyword. The above becomes:

config DRIVER_A
tristate
imply SUBSYSTEM_X

config DRIVER_B
tristate
imply SUBSYSTEM_X

[...]

config SUBSYSTEM_X
tristate

This is much cleaner, and way more flexible than "select". SUBSYSTEM_X
can still be configured out, and it can be set as a module when none of
the drivers are configured in or all of them are modular.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: linux-kbuild@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Cc: Edward Cree <ecree@solarflare.com>
Link: http://lkml.kernel.org/r/1478841010-28605-2-git-send-email-nicolas.pitre@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


# aab24a89 01-Jan-2016 Vegard Nossum <vegard.nossum@oracle.com>

kconfig: return 'false' instead of 'no' in bool function

menu_is_visible() is a bool function and should use boolean return
values. "no" is a tristate value which happens to also have a value
of 0, but we should nevertheless use the right symbol for it.

This is a very minor cleanup with no semantic change.

Fixes: 86e187ff9 ("kconfig: add an option to determine a menu's visibility")
Cc: Arnaud Lacombe <lacombar@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Michal Marek <mmarek@suse.com>


# ad8d40cd 24-Feb-2015 Michal Marek <mmarek@suse.cz>

kconfig: Remove unnecessary prototypes from headers

Signed-off-by: Michal Marek <mmarek@suse.cz>


# 2d560306 03-Nov-2014 Peter Kümmel <syntheticpp@gmx.net>

kconfig: Fix warning "‘jump’ may be used uninitialized"

Warning:
In file included from scripts/kconfig/zconf.tab.c:2537:0:
scripts/kconfig/menu.c: In function ‘get_symbol_str’:
scripts/kconfig/menu.c:590:18: warning: ‘jump’ may be used uninitialized in this function [-Wmaybe-uninitialized]
jump->offset = strlen(r->s);

Simplifies the test logic because (head && local) means (jump != 0)
and makes GCC happy when checking if the jump pointer was initialized.

Signed-off-by: Peter Kümmel <syntheticpp@gmx.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# bb66fc67 10-Jun-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

kbuild: trivial - use tabs for code indent where possible

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 5d2acfc7 07-Apr-2014 Josh Triplett <josh@joshtriplett.org>

kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT

"make allnoconfig" exists to ease testing of minimal configurations.
Documentation/SubmitChecklist includes a note to test with allnoconfig.
This helps catch missing dependencies on common-but-not-required
functionality, which might otherwise go unnoticed.

However, allnoconfig still leaves many symbols enabled, because they're
hidden behind CONFIG_EMBEDDED or CONFIG_EXPERT. For instance, allnoconfig
still has CONFIG_PRINTK and CONFIG_BLOCK enabled, so drivers don't
typically get build-tested with those disabled.

To address this, introduce a new Kconfig option "allnoconfig_y", used on
symbols which only exist to hide other symbols. Set it on CONFIG_EMBEDDED
(which then selects CONFIG_EXPERT). allnoconfig will then disable all the
symbols hidden behind those.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 503c8230 03-Oct-2013 Martin Walch <walch.martin@web.de>

kconfig: fix bug in search results string: use strlen(gstr->s), not gstr->len

The struct gstr has a capacity that may differ from the actual string length.

However, a string manipulation in the function search_conf made the assumption
that it is the same, which led to messing up some search results, especially
when the content of the gstr in use had not yet reached at least 63 chars.

Signed-off-by: Martin Walch <walch.martin@web.de>
Acked-by: Wang YanQing <udknight@gmail.com>
Acked-by: Benjamin Poirier <bpoirier@suse.de>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 57540f1d 03-Oct-2013 Martin Walch <walch.martin@web.de>

kconfig: adjust warning message for conflicting types

Each symbol must have exactly one type assigned. However, if a symbol happens
to have two different types assigned at runtime, a warning is printed and the
first type is preserved while the second type is being ignored.

The warning message says

type of <symbol name> redefined from <first type> to <second type>

which may be misleading as it may create the impression that the second type
replaces the first type.

This patch clarifies this by changing the warning to

ignoring type redefinition of <symbol name> from <first type> to <second type>

Signed-off-by: Martin Walch <walch.martin@web.de>
Acked-by: Wang YanQing <udknight@gmail.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 8d9dfe82 03-Oct-2013 Martin Walch <walch.martin@web.de>

kconfig: fix trivial typos and update mconf documentation

This fixes lots of typos in comments and strings.

It also updates the documentation strings in mconf to reflect the changes in
the user interface from the two commits

6364fd0cb1e4c7f72b974613e0cf5744ae4d2cb2
menuconfig: Add Save/Load buttons
1bdbac478a858d2aa73a6784c7c2e09de0f6d06b
menuconfig: Get rid of the top-level entries for "Load an Alternate/Save an Alternate"

And it updates the layout of the example search result, i. e. moves down the
"Defined at" and "Depends on" lines and adds a symbol state ([=n]) to the
symbol in the "Selected by" line.

Furthermore, the help texts now should fit in 80 columns again when viewed
in mconf.

Signed-off-by: Martin Walch <walch.martin@web.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Wang YanQing <udknight@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# e0627813 03-Sep-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: do not allow more than one symbol to have 'option modules'

Previously, it was possible to have more than one symbol with the
'option modules' attached to them, although only the last one would
in fact control tristates.

Since this does not make much sense, only allow at most one symbol to
control tristates.

Note: it is still possible to have more than one symbol that control
tristates, but indirectly:

config MOD1
bool "mod1"
select MODULES
config MOD2
bool "mod2"
select MODULES
config MODULES
bool
option modules

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 6902dccf 03-Sep-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: do not special-case 'MODULES' symbol

Currently, the 'MODULES' symbol is hard-coded to be the default symbol
that enables/disables tristates, if no other symbol was declared with
'option modules'.

While this used to be needed for the Linux kernel, we now have an
explicit 'option modules' attached to the 'MODULES' symbol (since
cset 11097a036), so we no longer need to special-case it in the
kconfig code.

Furthermore, kconfig is extensively used out of the Linux kernel, and
other projects may have another meaning for a symbol named 'MODULES'.

This patch changes the way we enable/disable tristates: if a symbol was
found with 'option modules' attached to it, then that symbol controls
enabling tristates. Otherwise, tristates are disabled, even if a symbol
named 'MODULES' exists.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 1278ebdb 19-May-2013 Dirk Gouders <dirk@gouders.net>

mconf/nconf: mark empty menus/menuconfigs different from non-empty ones

Submenus are sometimes empty and it would be nice if there is
something that notifies us that we should not expect any content
_before_ we enter a submenu.

A new function menu_is_empty() was introduced and empty menus and
menuconfigs are now marked by "----" as opposed to non-empty ones that
are marked by "--->".

This scheme was suggested by "Yann E. MORIN" <yann.morin.1998@free.fr>.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# e983b7b1 21-May-2013 Dirk Gouders <dirk@gouders.net>

kconfig/menu.c: fix multiple references to expressions in menu_add_prop()

menu_add_prop() applies upper menus' visibilities to actual prompts
by AND-ing the prompts visibilities with the upper menus ones.

This creates a further reference to the menu's visibilities and when
the expression reduction functions do their work, they may remove or
modify expressions that have multiple references, thus causing
unpredictable side-effects.

The following example Kconfig constructs a case where this causes
problems: a menu and a prompt which's visibilities depend on the same
symbol. When invoking mconf with this Kconfig and pressing "Z" we
see a problem caused by a free'd expression still referenced by the
menu's visibility:

------------------------------------------------------------------------
mainmenu "Kconfig Testing Configuration"

config VISIBLE
def_bool n

config Placeholder
bool "Place holder"

menu "Invisible"
visible if VISIBLE

config TEST_VAR
bool "Test option" if VISIBLE

endmenu
------------------------------------------------------------------------

This patch fixes this problem by creating copies of the menu's
visibility expressions before AND-ing them with the prompt's one.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
[yann.morin.1998@free.fr: move variable into its block-scope,
keep lines <80 chars, typo]
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 383da76f 07-May-2013 Li Zefan <lizefan@huawei.com>

menuconfig: fix NULL pointer dereference when searching a symbol

Searching for PPC_EFIKA results in a segmentation fault, and it's
because get_symbol_prop() returns NULL.

In this case CONFIG_PPC_EFIKA is defined in arch/powerpc/platforms/
52xx/Kconfig, so it won't be parsed if ARCH!=PPC, but menuconfig knows
this symbol when it parses sound/soc/fsl/Kconfig:

config SND_MPC52xx_SOC_EFIKA
tristate "SoC AC97 Audio support for bbplan Efika and STAC9766"
depends on PPC_EFIKA

This bug was introduced by commit bcdedcc1afd6 ("menuconfig: print more
info for symbol without prompts").

Reported-and-tested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Li Zefan <lizefan@huawei.com>
Tested-by: Libo Chen <libo.chen@huawei.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# bcdedcc1 30-Apr-2013 Wengmeiling <wengmeiling.weng@huawei.com>

menuconfig: print more info for symbol without prompts

When we search a config symbol, if it has no prompt the position of this
symbol in the Kconfig file and it's dependencies are not printed. This
can be inconvenient, especially when it's set to n and we want to find out
why.

the following is an example:

before:

Symbol: GENERIC_SMP_IDLE_THREAD [=y]
Type : boolean
Selected by: X86 [=y]

after:

Symbol: GENERIC_SMP_IDLE_THREAD [=y]
Type : boolean
Defined at arch/Kconfig:213
Selected by: X86 [=y]

Signed-off-by: Weng Meiling <wengmeiling.weng@huawei.com>
Signed-off-by: Libo Chen <libo.chen@huawei.com>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 177acf78 06-Nov-2012 Alan Cox <alan@linux.intel.com>

kconfig: Fix malloc handling in conf tools

(and get them out of the noise in the audit work)

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# bad9955d 21-Oct-2012 Benjamin Poirier <bpoirier@suse.de>

menuconfig: Replace CIRCLEQ by list_head-style lists.

sys/queue.h and CIRCLEQ in particular have proven to cause portability
problems (reported on Debian Sarge, Cygwin and FreeBSD)

Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 95ac9b3b 23-Aug-2012 Benjamin Poirier <bpoirier@suse.de>

menuconfig: Assign jump keys per-page instead of globally

At the moment, keys 1-9 are assigned to the first 9 search results. This patch
makes them assigned to the first 9 results per-page instead. We are much less
likely to run out of keys that way.

Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 5e609add 23-Aug-2012 Benjamin Poirier <bpoirier@suse.de>

menuconfig: Add jump keys to search results

makes it possible to jump directly to the menu for a configuration entry after
having searched for it with '/'. If this menu is not currently accessible we
jump to the nearest accessible parent instead. After exiting this menu, the
user is returned to the search results where he may jump further in or
elsewhere.

Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 57e6292d 03-Aug-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: factor code in menu_get_ext_help()

Cc: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 3f198dfe 02-Aug-2011 Srinivas Kandagatla <srinivas.kandagatla@st.com>

kbuild: Fix help text not displayed in choice option.

Help text under choice menu is never displayed because it does not have
symbol name associated with it, however many kconfigs have help text
under choice, assuming that it will be displayed when user selects help.
for example in Kconfig if we have:
choice
prompt "Choice"
---help---
HELP TEXT ...

config A
bool "A"

config B
bool "B"

endchoice

Without this patch "HELP TEXT" is not displayed when user selects help
option when "Choice" is highlighted from menuconfig or xconfig or
gconfig.

This patch changes the logic in menu_get_ext_help to display help for
cases which dont have symbol names like choice.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Reviewed-by: Stuart Menefy <stuart.menefy@st.com>
Reviewed-by: Arnaud Lacombe <lacombar@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Michal Marek <mmarek@suse.cz>


# ec6452a5 07-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: do not overwrite symbol direct dependency in assignment

Considering the following configuration:

config F
bool "F"

choice AB
bool "AB"
config A
bool "A"
config B
bool "B"
endchoice

if A
config D
bool
default y if F
select E
config E
bool "E"
endif

if B
config D
bool
default y if F
select E
config E
bool "E"
endif

The following configuration:

CONFIG_F=y
CONFIG_A=y
# CONFIG_B is not set
CONFIG_D=y
CONFIG_E=y

emits a spurious warning:

(D) selects E which has unmet direct dependencies (B)

If a symbol appears in two different branch of the tree, it should inherit the
dependency of both parent, not just the last one.

Reported-by: Yann E. Morin <yann.morin.1998@anciens.enib.fr>
Tested-by: Yann E. Morin <yann.morin.1998@anciens.enib.fr>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 5a6f8d2b 01-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: nuke LKC_DIRECT_LINK cruft

This interface is not (and has never been ?) used by any frontend, just get rid
of it.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# dd003306 01-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: add missing <ctype.h> inclusion

This header is needed when using isspace(3) function family.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 10a4b277 01-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: add missing <stdarg.h> inclusion

This header is needed when using va_{start,end,copy}(3) functions family.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 7ad12278 09-Dec-2010 Jan Beulich <JBeulich@novell.com>

kconfig: fix undesirable side effect of adding "visible" menu attribute

This lead to non-selected, non-user-selectable options to be written
out to .config. This is not only pointless, but also preventing the
user to be prompted should any of those options eventually become
visible (e.g. by de-selecting the *_AUTO options the "visible"
attribute was added for.

Furthermore it is quite logical for the "visible" attribute of a menu
to control the visibility of all contained prompts, which is what the
patch does.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# ab60bd0b 04-Dec-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: add more S_INT and S_HEX consistency checks

This patch add more number consistency checkg, trying to catch the following
situation:

config FOO0
hex
default 42

config FOO1
string

config BAR0
int
default FOO1

config BAR1
hex
default FOO1

config FOO2
hex
default 42h

config FOO3
int
default "1bar"

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 86e187ff 06-Nov-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: add an option to determine a menu's visibility

This option is aimed to add the possibility to control a menu's visibility
without adding dependency to the expression to all the submenu.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>


# ff5ff606 26-Sep-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: delay symbol direct dependency initialization

This fixes the use-after-free and associated crash in kconfig introduced
in commit 246cf9c26bf11f2bffbecea6e5bd222eee7b1df8.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# ba6ff60d 04-Sep-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: don't emit warning upon rootmenu's prompt redefinition

This silences the warning printed upon prompt redefinition for the rootmenu.
We will encounter this redefinition when a "mainmenu" statement is specified and
override the default prompt.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# 652cf982 14-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: rephrase help texts/comments not to include the package name

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Randy Dunlap <rdunlap@xenotime.net>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# ffb5957b 14-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: allow build-time definition of the internal config prefix

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# 59e89e3d 31-Jul-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: save location of config symbols

When we add a new config symbol save the file/line
so we later can refer to their location.

The information is saved as a property to a config symbol
because we may have multiple definitions of the same symbol.

This has the side-effect that a symbol always has
at least one property.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 246cf9c2 08-Jun-2010 Catalin Marinas <catalin.marinas@arm.com>

kbuild: Warn on selecting symbols with unmet direct dependencies

The "select" statement in Kconfig files allows the enabling of options
even if they have unmet direct dependencies (i.e. "depends on" expands
to "no"). Currently, the "depends on" clauses are used in calculating
the visibility but they do not affect the reverse dependencies in any
way.

The patch introduces additional tracking of the "depends on" statements
and prints a warning on selecting an option if its direct dependencies
are not met.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 3fb9acb3 06-May-2010 Li Zefan <lizf@cn.fujitsu.com>

kconfig: fix to tag NEW symbols correctly

Those configs are not new:

$ cat .config
...
CONFIG_NAMESPACES=y
...
CONFIG_BLOCK=y
...

But are tagged as NEW:

$ yes "" | make config > myconf
$ cat myconf | grep '(NEW)'
Namespaces support (NAMESPACES) [Y/?] (NEW) y
...
Enable the block layer (BLOCK) [Y/?] (NEW) y
...

You can also notice this bug when using gconfig/xconfig.

It's because the SYMBOL_DEF_USER bit of an invisible symbol is cleared
when the config file is read:

int conf_read(const char *name)
{
...
for_all_symbols(i, sym) {
if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
/* Reset values of generates values, so they'll appear
* as new, if they should become visible, but that
* doesn't quite work if the Kconfig and the saved
* configuration disagree.
*/
if (sym->visible == no && !conf_unsaved)
sym->flags &= ~SYMBOL_DEF_USER;
...
}

But a menu item which represents an invisible symbol is still
visible, if it's sub-menu is visible, so its SYMBOL_DEF_USER
bit should be set to indicate it's not NEW.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 70ed0747 06-May-2010 Li Zefan <lizf@cn.fujitsu.com>

kconfig: print the range of integer/hex symbol in help text

Without this patch, one has to refer to the Kconfig file to find
out the range of an integer/hex symbol.

│ Symbol: NR_CPUS [=4]
│ Type : integer
│ Range : [2 8]
│ Prompt: Maximum number of CPUs
│ Defined at arch/x86/Kconfig:761
│ Depends on: SMP [=y] && !MAXSMP [=n]
│ Location:
│ -> Processor type and features

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# b040b44c 06-May-2010 Li Zefan <lizf@cn.fujitsu.com>

kconfig: print symbol type in help text

Randy suggested to print out the symbol type in gconfig.

Note this change does more than Randy's suggestion, that it also
affects menuconfig and "make config".

│ Symbol: BLOCK [=y]
│ Type : boolean
│ Prompt: Enable the block layer
│ Defined at block/Kconfig:4
│ Depends on: EMBEDDED [=n]

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 22c7eca6 13-Apr-2010 Li Zefan <lizf@cn.fujitsu.com>

menuconfig: add support to show hidden options which have prompts

Usage:
Press <Z> to show all config symbols which have prompts.

Quote Tim Bird:

| I've been bitten by this numerous times. I most often
| use ftrace on ARM, but when I go back to x86, I almost
| always go through a sequence of searching for the
| function graph tracer in the menus, then realizing it's
| completely missing until I disable CC_OPTIMIZE_FOR_SIZE.
|
| Is there any way to have the menu item appear, but be
| unsettable unless the SIZE option is disabled? I'm
| not a Kconfig guru...

I myself found this useful too. For example, I need to test
ftrace/tracing and want to be sure all the tracing features are
enabled, so I enter the "Tracers" menu, and press <Z> to
see if there is any config hidden.

I also noticed gconfig and xconfig have a button "Show all options",
but that's a bit too much, and I think normally what we are not
interested in those configs which have no prompt thus can't be
changed by users.

Exmaple:

--- Tracers
-*- Kernel Function Tracer
- - Kernel Function Graph Tracer
[*] Interrupts-off Latency Tracer
- - Preemption-off Latency Tracer
[*] Sysprof Tracer

Here you can see 2 tracers are not selectable, and then can find
out how to make them selectable.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 4280eae0 13-Apr-2010 Li Zefan <lizf@cn.fujitsu.com>

kconfig: some small fixes

- fix a typo in documentation
- fix a typo in a printk on error
- fix comments in dialog_inputbox()

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 692d97c3 24-Nov-2009 nir.tzachar@gmail.com <nir.tzachar@gmail.com>

kconfig: new configuration interface (nconfig)

This patch was inspired by the kernel projects page, where an ncurses
replacement for menuconfig was mentioned (by Sam Ravnborg).

Building on menuconfig, this patch implements a more modern look
interface using ncurses and ncurses' satellite libraries (menu, panel,
form). The implementation does not depend on lxdialog, which is
currently distributed with the kernel.

Signed-off-by: Nir Tzachar <nir.tzachar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 4356f489 18-Sep-2009 Trevor Keith <tsrk@tsrk.net>

kbuild: add static to prototypes

Warnings found via gcc -Wmissing-prototypes.

Signed-off-by: Trevor Keith <tsrk@tsrk.net>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 4779105e 12-Jul-2009 Cheng Renquan <crquan@gmail.com>

kconfig: make use of menu_get_ext_help in gconfig

Futhermore, gconfig interface lack the "search a symbol" function, do later.

Signed-off-by: Cheng Renquan <crquan@gmail.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
[sam: fix SEGV in gconfig]
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 6bd5999d 12-Jul-2009 Cheng Renquan <crquan@gmail.com>

kconfig: add menu_get_ext_help function to display more information

The three functions are moved from mconf.c, then they can be shared in
all menuconfig & gconfig & xconfig & config.

+void menu_get_ext_help(struct menu *menu, struct gstr *help)
+static void get_prompt_str(struct gstr *r, struct property *prop)
+void get_symbol_str(struct gstr *r, struct symbol *sym)

Signed-off-by: Cheng Renquan <crquan@gmail.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 5a1aa8a1 28-Feb-2008 Roman Zippel <zippel@linux-m68k.org>

kconfig: add named choice group

As choice dependency are now fully checked, it's quite easy to add support
for named choices. This lifts the restriction that a choice value can only
appear once, although it still has to be within the same group,
but multiple choices can be joined by giving them a name.
While at it I cleaned up a little the choice type logic to simplify it a
bit.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 603d4988 02-Feb-2008 Sam Ravnborg <sam@ravnborg.org>

kconfig: ignore select of unknown symbol

We have had warnings for a long time about select of unknow symbol
but the warnings does not really makes sense since we may
select a symbol that is relevant and defined in one
arch but not in another arch.
And as long as we do not use a common set of Kconfig files
for all archs lets just ignore this case.

Previously we have used this to find bad uses of
select but we need a more relaible method to do so.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# f5eaa323 24-Jan-2008 Jan Beulich <jbeulich@novell.com>

kconfig: tristate choices with mixed tristate and boolean values

Change kconfig behavior so that mixing bool and tristate config
settings in a choice is possible and has the desired effect of offering
just the tristate options individually if the choice gets set to M, and
a normal boolean selection if the choice gets set to Y.

Also fix scripts/kconfig/conf's handling of children of choice values -
there may be more than one immediate child, and all of them need to be
processed.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: "Roman Zippel" <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 93449082 13-Jan-2008 Roman Zippel <zippel@linux-m68k.org>

kconfig: environment symbol support

Add the possibility to import a value from the environment into kconfig
via the option syntax. Beside flexibility this has the advantage
providing proper dependencies.
Documented the options syntax.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 7a962923 13-Jan-2008 Roman Zippel <zippel@linux-m68k.org>

kconfig: explicitly introduce expression list

Rename E_CHOICE to E_LIST to explicitly add support for expression
lists. Add a helper macro expr_list_for_each_sym to more easily iterate
over the list.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 01771b0f 11-Jan-2008 EGRY Gabor <gaboregry1@t-online.hu>

kconfig: macro fix in menu.c

This patch removes the indirect I18N support for config file.

Signed-off-by: Egry Gabor <gaboregry1@t-online.hu>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# e8b8c977 19-Oct-2007 Linus Torvalds <torvalds@woody.linux-foundation.org>

Revert "kconfig: tristate choices with mixed tristate and boolean values"

This reverts commit a5bf3d891a6a0fb5aa122792d965e3774108b923.

David Brownell notes that this causes a regression visible in the
drivers/usb/gadget Kconfig file:

"That Kconfig hasn't changed (other than adding new drivers), and it's
worked that way for several years now ... so the issue seems to be
changes in menuconfig/kconfig/etc semantics.

The issue is that when USB_GADGET=m, it's no longer possible to
configure peripheral controller drivers as modules ... the
controller drivers can now only be configured for static linkage.

It should be making a choice of one of the controller drivers which
could work on the target system, and allow that driver to be linked
either as a module (ok iff USB_GADGET=m) or statically."

Reverting this commit resolves the problem, and also fixes a second
problem that David noticed: various dependent options couldn't be enabled.

Tested-and-reported-by: David Brownell <david-b@pacbell.net>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Jan Beulich <jbeulich@novell.com>,
Cc: Andrew Morton <akpm@linux-foundation.org>,
Cc: Sam Ravnborg <sam@ravnborg.org>,
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a5bf3d89 02-Oct-2007 Jan Beulich <jbeulich@novell.com>

kconfig: tristate choices with mixed tristate and boolean values

Change kconfig behavior so that mixing bool and tristate config settings in
a choice is possible and has the desired effect of offering just the
tristate options individually if the choice gets set to M, and a normal
boolean selection if the choice gets set to Y.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 03d29122 20-Jul-2007 Sam Ravnborg <sam@ravnborg.org>

kconfig: attach help text to menus

Roman Zippel wrote:
> A simple example would be
> help texts, right now they are per symbol, but they should really be per
> menu, so archs can provide different help texts for something.

This patch does this and at the same time introduce a few API
funtions used to access the help text.

The relevant api functions are introduced in the various frontends.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# 1e093ecd 30-Apr-2007 Robert P. J. Day <rpjday@mindspring.com>

kconfig: correct minor typo in Kconfig warning message.

Correct a minor spelling mistake in a Kconfig warning message.

Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# f001f7f8 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: warn about leading whitespace for menu prompts

Kconfig does its own indentation of menu prompts, so warn about and ignore
leading whitespace. Remove also a few unnecessary newlines after other
warning prints.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# face4374 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: add defconfig_list/module option

This makes it possible to change two options which were hardcoded sofar.
1. Any symbol can now take the role of CONFIG_MODULES
2. The more useful option is to change the list of default file names,
which kconfig uses to load the base configuration if .config isn't
available.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# f6a88aa8 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: add symbol option config syntax

This adds the general framework to the parser to define options for config
symbols with a syntax like:

config FOO
option bar[="arg"]

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# a02f0570 08-Nov-2005 Roman Zippel <zippel@linux-m68k.org>

[PATCH] kconfig: improve error handling in the parser

Add a few error tokens to the parser to catch common errors and print more
descriptive error messages.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 4cf3cbe2 08-Nov-2005 Roman Zippel <zippel@linux-m68k.org>

[PATCH] kconfig: allow variable argumnts for range

This allows variable arguments in the range option for int and hex config
symbols.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# fb7f6ff6 28-Jul-2005 Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

[PATCH] kconfig: trivial cleanup

Replace all menu_add_prop mimicking menu_add_prompt with the latter func. I've
had to add a return value to menu_add_prompt for one usage.

I've rebuilt scripts/kconfig/zconf.tab.c_shipped by hand to reflect changes
in the source (I've not the same Bison version so regenerating it wouldn't
have been not a good idea), and compared it with what Roman itself did some
time ago, and it's the same.

So I guess this can be finally merged.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 3b9fa093 05-May-2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>

[PATCH] Kconfig i18n support

This patch adds i18n support for make *config, allowing users to have the
config process in their own language.

No printk was harmed in the process, don't worry, so all the bug reports,
kernel messages, etc, remain in english, just the user tools to configure
the kernel are internationalized.

Users not interested in translations can just unset the related LANG,
LC_ALL, etc env variables and have the config process in plain english,
something like:

LANG= make menuconfig

is enough for having the whole config process in english. Or just don't
install any translation file.

Translations for brazilian portuguese are being done by a team of
volunteers at:

http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes

To start the translation process:

make update-po-config

This will generate the pot template named scripts/kconfig/linux.pot,
copy it to, say, ~/es.po, to start the translation for spanish.

To test your translation, as root issue this command:

msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po

Replace "es" with your language code.

Then execute, for instance:

make menuconfig

The current patch doesn't use any optimization to reduce the size of the
generated .mo file, it is possible to use the config option as a key, but
this doesn't prevent the current patch from being used or the translations
done under the current scheme to be in any way lost if we chose to do any
kind of keying.

Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese)
translation effort, Thiago Maciera for helping me with the gconf.cc (QT
frontent) i18n coding and to all the volunteers that are already working on
the first translation, to pt_BR.

I left the question on whether to ship the translations with the stock kernel
sources to be discussed here, please share your suggestions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org
Signed-off-by: Andrew Morton <akpm@osdl.org>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!