kconfig: link menus to a symbol
Subsystems (3)
PATCH 1/3 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.
---
scripts/kconfig/expr.h | 5 +++++ scripts/kconfig/menu.c | 4 +++- scripts/kconfig/symbol.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-)
scripts/kconfig/expr.h +5 -0
@@ -108,6 +108,9 @@ struct symbol {*/ tristate visible; +/* config entries associated with this symbol */ +struct list_head menus; +/* SYMBOL_* flags */ int flags;
@@ -222,6 +225,8 @@ struct menu {*/ struct symbol *sym; +struct list_head link;/* link to symbol::menus */ +/* * The prompt associated with the node. This holds the prompt for a * symbol as well as the text for a menu or comment, along with the
scripts/kconfig/menu.c +3 -1
@@ -57,8 +57,10 @@ void menu_add_entry(struct symbol *sym) *last_entry_ptr = menu; last_entry_ptr = &menu->next; current_entry = menu; -if (sym) +if (sym) {menu_add_symbol (P_SYMBOL , sym,NULL ); +list_add_tail (&menu->link, &sym->menus); + } }struct menu *menu_add_menu (void )
scripts/kconfig/symbol.c +4 -0
@@ -15,18 +15,21 @@struct symbol symbol_yes = { .name ="y" , .curr = {"y" , yes }, + .menus =LIST_HEAD_INIT (symbol_yes.menus), .flags =SYMBOL_CONST |SYMBOL_VALID , };struct symbol symbol_mod = { .name ="m" , .curr = {"m" , mod }, + .menus =LIST_HEAD_INIT (symbol_mod.menus), .flags =SYMBOL_CONST |SYMBOL_VALID , };struct symbol symbol_no = { .name ="n" , .curr = {"n" , no }, + .menus =LIST_HEAD_INIT (symbol_no.menus), .flags =SYMBOL_CONST |SYMBOL_VALID , };
@@ -838,6 +841,7 @@ struct symbol *sym_lookup(const char *name, int flags) symbol->name = new_name; symbol->type =S_UNKNOWN ; symbol->flags = flags; +INIT_LIST_HEAD (&symbol->menus);hash_add (sym_hashtable, &symbol->node, hash);
Signature · 1 line
2.40.1
PATCH 2/3 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.
---
scripts/kconfig/menu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
scripts/kconfig/menu.c +9 -8
@@ -771,6 +771,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, struct list_head *head) {struct property *prop; +struct menu *menu;if (sym && sym->name) { str_printf(r, "Symbol: %s [=%s]\n", sym->name,
@@ -787,17 +788,17 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, }/* Print the definitions with prompts before the ones without */ - for_all_properties(sym, prop, P_SYMBOL) { -if (prop->menu->prompt) { -get_def_str (r, prop->menu); -get_prompt_str (r, prop->menu->prompt, head); +list_for_each_entry (menu, &sym->menus, link) { +if (menu->prompt) { +get_def_str (r, menu); +get_prompt_str (r, menu->prompt, head); } } - for_all_properties(sym, prop, P_SYMBOL) { -if (!prop->menu->prompt) { -get_def_str (r, prop->menu); -get_dep_str (r, prop->menu->dep," Depends on: " ); +list_for_each_entry (menu, &sym->menus, link) { +if (!menu->prompt) { +get_def_str (r, menu); +get_dep_str (r, menu->dep," Depends on: " ); } }
Signature · 1 line
2.40.1
Re: [PATCH 2/3] kconfig: use linked list in get_symbol_str() to iterate over menus
Quoted 12 lines · On Sun, Mar 03, 2024 at 01:00:34PM +0900 Masahiro Yamada wrote:
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 <[email protected]>---
scripts/kconfig/menu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
PATCH 3/3 kconfig: remove named choice support
In reply to Masahiro YamadaCommit 5a1aa8a1aff6 ("kconfig: add named choice group") did not provide enough explanation. A use case was found in another project [1], but this has never been used in the kernel.
[1]: https://lore.kernel.org/all/[email protected]/
---
Documentation/kbuild/kconfig-language.rst | 6 +----- scripts/kconfig/parser.y | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-)
Documentation/kbuild/kconfig-language.rst +1 -5
@@ -393,7 +393,7 @@ of C0, which doesn't depend on M:: choices:: - "choice" [symbol] + "choice" <choice options> <choice block> "endchoice"
@@ -412,10 +412,6 @@ the kernel, but all drivers can be compiled as modules. A choice accepts another option "optional", which allows to set the choice to 'n' and no entry needs to be selected. -If no [symbol] is associated with a choice, then you can not have multiple -definitions of that choice. If a [symbol] is associated to the choice, -then you may define the same choice (i.e. with the same entries) in another -place. comment::
scripts/kconfig/parser.y +3 -7
@@ -94,7 +94,7 @@ struct menu *current_menu, *current_entry; %type <expr> if_expr %type <string> end %type <menu> if_entry menu_entry choice_entry -%type <string> word_opt assign_val +%type <string> assign_val %type <flavor> assign_op %destructor {
@@ -222,13 +222,12 @@ config_option: T_MODULES T_EOL /* choice entry */ -choice: T_CHOICE word_opt T_EOL +choice: T_CHOICE T_EOL { - struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); + struct symbol *sym = sym_lookup(NULL, SYMBOL_CHOICE); sym->flags |= SYMBOL_NO_WRITE; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); - free($2); printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno); };
@@ -449,9 +448,6 @@ symbol: nonconst_symbol | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } ; -word_opt: /* empty */ { $$ = NULL; } - | T_WORD - /* assignment statement */ assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
Signature · 1 line
2.40.1
Re: [PATCH 3/3] kconfig: remove named choice support
Quoted 4 lines · On Sun, Mar 03, 2024 at 01:00:35PM +0900 Masahiro Yamada wrote:
Commit
5a1aa8a1aff6("kconfig: add named choice group") did not provide enough explanation. A use case was found in another project [1], but this has never been used in the kernel.
Quoted 9 lines
[1]: https://lore.kernel.org/all/[email protected]/
Signed-off-by Masahiro Yamada <[email protected]>---
Documentation/kbuild/kconfig-language.rst | 6 +----- scripts/kconfig/parser.y | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-)
Quoted 9 lines · On Sun, Mar 03, 2024 at 01:00:33PM +0900 Masahiro Yamada wrote:
Currently, there is no direct link from (struct symbol *) to (struct menu *).
It is still possible to access associated menus through the
P_SYMBOLproperty, becauseproperty::menuis the relevant menu entry, but it results in complex code, as seen inget_symbol_str().Use a linked list for simpler traversal of relevant menus.
Quoted 7 lines
Signed-off-by Masahiro Yamada <[email protected]>---
scripts/kconfig/expr.h | 5 +++++ scripts/kconfig/menu.c | 4 +++- scripts/kconfig/symbol.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-)
Thanks, the whole series looks good to me.