aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ee5fe943d58d..07597611cc50 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void))
812{ 812{
813 conf_changed_callback = fn; 813 conf_changed_callback = fn;
814} 814}
815
816
817void conf_set_all_new_symbols(enum conf_def_mode mode)
818{
819 struct symbol *sym, *csym;
820 struct property *prop;
821 struct expr *e;
822 int i, cnt, def;
823
824 for_all_symbols(i, sym) {
825 if (sym_has_value(sym))
826 continue;
827 switch (sym_get_type(sym)) {
828 case S_BOOLEAN:
829 case S_TRISTATE:
830 switch (mode) {
831 case def_yes:
832 sym->def[S_DEF_USER].tri = yes;
833 break;
834 case def_mod:
835 sym->def[S_DEF_USER].tri = mod;
836 break;
837 case def_no:
838 sym->def[S_DEF_USER].tri = no;
839 break;
840 case def_random:
841 sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
842 break;
843 default:
844 continue;
845 }
846 if (!sym_is_choice(sym) || mode != def_random)
847 sym->flags |= SYMBOL_DEF_USER;
848 break;
849 default:
850 break;
851 }
852
853 }
854
855 if (modules_sym)
856 sym_calc_value(modules_sym);
857
858 if (mode != def_random)
859 return;
860
861 for_all_symbols(i, csym) {
862 if (sym_has_value(csym) || !sym_is_choice(csym))
863 continue;
864
865 sym_calc_value(csym);
866 prop = sym_get_choice_prop(csym);
867 def = -1;
868 while (1) {
869 cnt = 0;
870 expr_list_for_each_sym(prop->expr, e, sym) {
871 if (sym->visible == no)
872 continue;
873 if (def == cnt++) {
874 csym->def[S_DEF_USER].val = sym;
875 break;
876 }
877 }
878 if (def >= 0 || cnt < 2)
879 break;
880 def = (rand() % cnt) + 1;
881 }
882 csym->flags |= SYMBOL_DEF_USER;
883 }
884}