Skip to content

Commit e049221

Browse files
committed
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 <[email protected]> Reviewed-by: Nicolas Schier <[email protected]>
1 parent 50a3399 commit e049221

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Diff for: scripts/kconfig/expr.h

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ struct symbol {
108108
*/
109109
tristate visible;
110110

111+
/* config entries associated with this symbol */
112+
struct list_head menus;
113+
111114
/* SYMBOL_* flags */
112115
int flags;
113116

@@ -222,6 +225,8 @@ struct menu {
222225
*/
223226
struct symbol *sym;
224227

228+
struct list_head link; /* link to symbol::menus */
229+
225230
/*
226231
* The prompt associated with the node. This holds the prompt for a
227232
* symbol as well as the text for a menu or comment, along with the

Diff for: scripts/kconfig/menu.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ void menu_add_entry(struct symbol *sym)
5757
*last_entry_ptr = menu;
5858
last_entry_ptr = &menu->next;
5959
current_entry = menu;
60-
if (sym)
60+
if (sym) {
6161
menu_add_symbol(P_SYMBOL, sym, NULL);
62+
list_add_tail(&menu->link, &sym->menus);
63+
}
6264
}
6365

6466
struct menu *menu_add_menu(void)

Diff for: scripts/kconfig/symbol.c

+4
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515
struct symbol symbol_yes = {
1616
.name = "y",
1717
.curr = { "y", yes },
18+
.menus = LIST_HEAD_INIT(symbol_yes.menus),
1819
.flags = SYMBOL_CONST|SYMBOL_VALID,
1920
};
2021

2122
struct symbol symbol_mod = {
2223
.name = "m",
2324
.curr = { "m", mod },
25+
.menus = LIST_HEAD_INIT(symbol_mod.menus),
2426
.flags = SYMBOL_CONST|SYMBOL_VALID,
2527
};
2628

2729
struct symbol symbol_no = {
2830
.name = "n",
2931
.curr = { "n", no },
32+
.menus = LIST_HEAD_INIT(symbol_no.menus),
3033
.flags = SYMBOL_CONST|SYMBOL_VALID,
3134
};
3235

@@ -838,6 +841,7 @@ struct symbol *sym_lookup(const char *name, int flags)
838841
symbol->name = new_name;
839842
symbol->type = S_UNKNOWN;
840843
symbol->flags = flags;
844+
INIT_LIST_HEAD(&symbol->menus);
841845

842846
hash_add(sym_hashtable, &symbol->node, hash);
843847

0 commit comments

Comments
 (0)