diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2008-05-06 04:55:55 +0200 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-07-25 22:12:48 +0200 |
commit | dc7862e5a65b9b9e0aad448398b4f652c49c9350 (patch) | |
tree | 321c974ea47d99c5d03303cb5d3187b1ecf6ed81 /scripts/kconfig/confdata.c | |
parent | a717417e7f96ad2c6c3d80cdd0836e49597399a3 (diff) |
kconfig: set all new symbols automatically
Add conf_set_all_new_symbols() which set all symbols (which don't have a
value yet) to a specifed value.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r-- | scripts/kconfig/confdata.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index ee5fe943d58..07597611cc5 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void)) { conf_changed_callback = fn; } + + +void conf_set_all_new_symbols(enum conf_def_mode mode) +{ + struct symbol *sym, *csym; + struct property *prop; + struct expr *e; + int i, cnt, def; + + for_all_symbols(i, sym) { + if (sym_has_value(sym)) + continue; + switch (sym_get_type(sym)) { + case S_BOOLEAN: + case S_TRISTATE: + switch (mode) { + case def_yes: + sym->def[S_DEF_USER].tri = yes; + break; + case def_mod: + sym->def[S_DEF_USER].tri = mod; + break; + case def_no: + sym->def[S_DEF_USER].tri = no; + break; + case def_random: + sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); + break; + default: + continue; + } + if (!sym_is_choice(sym) || mode != def_random) + sym->flags |= SYMBOL_DEF_USER; + break; + default: + break; + } + + } + + if (modules_sym) + sym_calc_value(modules_sym); + + if (mode != def_random) + return; + + for_all_symbols(i, csym) { + if (sym_has_value(csym) || !sym_is_choice(csym)) + continue; + + sym_calc_value(csym); + prop = sym_get_choice_prop(csym); + def = -1; + while (1) { + cnt = 0; + expr_list_for_each_sym(prop->expr, e, sym) { + if (sym->visible == no) + continue; + if (def == cnt++) { + csym->def[S_DEF_USER].val = sym; + break; + } + } + if (def >= 0 || cnt < 2) + break; + def = (rand() % cnt) + 1; + } + csym->flags |= SYMBOL_DEF_USER; + } +} |