diff options
-rw-r--r-- | scripts/kconfig/confdata.c | 70 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 9 |
2 files changed, 79 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 | |||
817 | void 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 | } | ||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 96521cb087ec..4a9af6f7886b 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -42,6 +42,14 @@ extern "C" { | |||
42 | #define TF_PARAM 0x0002 | 42 | #define TF_PARAM 0x0002 |
43 | #define TF_OPTION 0x0004 | 43 | #define TF_OPTION 0x0004 |
44 | 44 | ||
45 | enum conf_def_mode { | ||
46 | def_default, | ||
47 | def_yes, | ||
48 | def_mod, | ||
49 | def_no, | ||
50 | def_random | ||
51 | }; | ||
52 | |||
45 | #define T_OPT_MODULES 1 | 53 | #define T_OPT_MODULES 1 |
46 | #define T_OPT_DEFCONFIG_LIST 2 | 54 | #define T_OPT_DEFCONFIG_LIST 2 |
47 | #define T_OPT_ENV 3 | 55 | #define T_OPT_ENV 3 |
@@ -69,6 +77,7 @@ const char *conf_get_configname(void); | |||
69 | char *conf_get_default_confname(void); | 77 | char *conf_get_default_confname(void); |
70 | void sym_set_change_count(int count); | 78 | void sym_set_change_count(int count); |
71 | void sym_add_change_count(int count); | 79 | void sym_add_change_count(int count); |
80 | void conf_set_all_new_symbols(enum conf_def_mode mode); | ||
72 | 81 | ||
73 | /* kconfig_load.c */ | 82 | /* kconfig_load.c */ |
74 | void kconfig_load(void); | 83 | void kconfig_load(void); |