Skip to content

Commit f5eaa32

Browse files
Jan Beulichsravnborg
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. 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>
1 parent 1a3fb6d commit f5eaa32

3 files changed

Lines changed: 45 additions & 7 deletions

File tree

‎scripts/kconfig/conf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ static int conf_choice(struct menu *menu)
400400
continue;
401401
}
402402
sym_set_choice_value(sym, child->sym);
403-
if (child->list) {
403+
for (child = child->list; child; child = child->next) {
404404
indent += 2;
405-
conf(child->list);
405+
conf(child);
406406
indent -= 2;
407407
}
408408
return 1;

‎scripts/kconfig/expr.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,18 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
10341034
expr_print(e->left.expr, fn, data, E_NOT);
10351035
break;
10361036
case E_EQUAL:
1037-
fn(data, e->left.sym, e->left.sym->name);
1037+
if (e->left.sym->name)
1038+
fn(data, e->left.sym, e->left.sym->name);
1039+
else
1040+
fn(data, NULL, "<choice>");
10381041
fn(data, NULL, "=");
10391042
fn(data, e->right.sym, e->right.sym->name);
10401043
break;
10411044
case E_UNEQUAL:
1042-
fn(data, e->left.sym, e->left.sym->name);
1045+
if (e->left.sym->name)
1046+
fn(data, e->left.sym, e->left.sym->name);
1047+
else
1048+
fn(data, NULL, "<choice>");
10431049
fn(data, NULL, "!=");
10441050
fn(data, e->right.sym, e->right.sym->name);
10451051
break;

‎scripts/kconfig/menu.c‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,11 @@ void menu_finalize(struct menu *parent)
242242
for (menu = parent->list; menu; menu = menu->next) {
243243
if (menu->sym) {
244244
current_entry = parent;
245-
menu_set_type(menu->sym->type);
245+
if (sym->type == S_UNKNOWN)
246+
menu_set_type(menu->sym->type);
246247
current_entry = menu;
247-
menu_set_type(sym->type);
248+
if (menu->sym->type == S_UNKNOWN)
249+
menu_set_type(sym->type);
248250
break;
249251
}
250252
}
@@ -329,7 +331,37 @@ void menu_finalize(struct menu *parent)
329331
"values not supported");
330332
}
331333
current_entry = menu;
332-
menu_set_type(sym->type);
334+
if (menu->sym->type == S_UNKNOWN)
335+
menu_set_type(sym->type);
336+
/* Non-tristate choice values of tristate choices must
337+
* depend on the choice being set to Y. The choice
338+
* values' dependencies were propagated to their
339+
* properties above, so the change here must be re-
340+
* propagated. */
341+
if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
342+
basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
343+
basedep = expr_alloc_and(basedep, menu->dep);
344+
basedep = expr_eliminate_dups(basedep);
345+
menu->dep = basedep;
346+
for (prop = menu->sym->prop; prop; prop = prop->next) {
347+
if (prop->menu != menu)
348+
continue;
349+
dep = expr_alloc_and(expr_copy(basedep),
350+
prop->visible.expr);
351+
dep = expr_eliminate_dups(dep);
352+
dep = expr_trans_bool(dep);
353+
prop->visible.expr = dep;
354+
if (prop->type == P_SELECT) {
355+
struct symbol *es = prop_get_symbol(prop);
356+
dep2 = expr_alloc_symbol(menu->sym);
357+
dep = expr_alloc_and(dep2,
358+
expr_copy(dep));
359+
dep = expr_alloc_or(es->rev_dep.expr, dep);
360+
dep = expr_eliminate_dups(dep);
361+
es->rev_dep.expr = dep;
362+
}
363+
}
364+
}
333365
menu_add_symbol(P_CHOICE, sym, NULL);
334366
prop = sym_get_choice_prop(sym);
335367
for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)

0 commit comments

Comments
 (0)