Skip to content

Commit a5bf3d8

Browse files
Jan BeulichSam Ravnborg
authored andcommitted
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 <[email protected]> Cc: Roman Zippel <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sam Ravnborg <[email protected]>
1 parent 7747f96 commit a5bf3d8

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

scripts/kconfig/menu.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,23 @@ void menu_finalize(struct menu *parent)
235235
sym = parent->sym;
236236
if (parent->list) {
237237
if (sym && sym_is_choice(sym)) {
238-
/* find the first choice value and find out choice type */
238+
/* find out choice type */
239+
enum symbol_type type = S_UNKNOWN;
240+
239241
for (menu = parent->list; menu; menu = menu->next) {
240-
if (menu->sym) {
241-
current_entry = parent;
242-
menu_set_type(menu->sym->type);
243-
current_entry = menu;
244-
menu_set_type(sym->type);
245-
break;
242+
if (menu->sym && menu->sym->type != S_UNKNOWN) {
243+
if (type == S_UNKNOWN)
244+
type = menu->sym->type;
245+
if (type != S_BOOLEAN)
246+
break;
247+
if (menu->sym->type == S_TRISTATE) {
248+
type = S_TRISTATE;
249+
break;
250+
}
246251
}
247252
}
253+
current_entry = parent;
254+
menu_set_type(type);
248255
parentdep = expr_alloc_symbol(sym);
249256
} else if (parent->prompt)
250257
parentdep = parent->prompt->visible.expr;
@@ -253,7 +260,16 @@ void menu_finalize(struct menu *parent)
253260

254261
for (menu = parent->list; menu; menu = menu->next) {
255262
basedep = expr_transform(menu->dep);
256-
basedep = expr_alloc_and(expr_copy(parentdep), basedep);
263+
dep = parentdep;
264+
if (sym && sym_is_choice(sym) && menu->sym) {
265+
enum symbol_type type = menu->sym->type;
266+
267+
if (type == S_UNKNOWN)
268+
type = sym->type;
269+
if (type != S_TRISTATE)
270+
dep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
271+
}
272+
basedep = expr_alloc_and(expr_copy(dep), basedep);
257273
basedep = expr_eliminate_dups(basedep);
258274
menu->dep = basedep;
259275
if (menu->sym)
@@ -326,7 +342,8 @@ void menu_finalize(struct menu *parent)
326342
"values not supported");
327343
}
328344
current_entry = menu;
329-
menu_set_type(sym->type);
345+
if (menu->sym->type == S_UNKNOWN)
346+
menu_set_type(sym->type);
330347
menu_add_symbol(P_CHOICE, sym, NULL);
331348
prop = sym_get_choice_prop(sym);
332349
for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)

0 commit comments

Comments
 (0)