kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG
[carl9170fw.git] / config / confdata.c
index 7a2bc8fc85658581bf83d931dee22c69249fce9b..b0f134fa0f603c76372a6be9788137504af0c1ee 100644 (file)
@@ -288,8 +288,6 @@ load:
        for_all_symbols(i, sym) {
                sym->flags |= SYMBOL_CHANGED;
                sym->flags &= ~(def_flags|SYMBOL_VALID);
-               if (sym_is_choice(sym))
-                       sym->flags |= def_flags;
                switch (sym->type) {
                case S_INT:
                case S_HEX:
@@ -379,13 +377,13 @@ setsym:
                        case mod:
                                if (cs->def[def].tri == yes) {
                                        conf_warning("%s creates inconsistent choice state", sym->name);
-                                       cs->flags &= ~def_flags;
                                }
                                break;
                        case yes:
                                if (cs->def[def].tri != no)
                                        conf_warning("override: %s changes choice state", sym->name);
                                cs->def[def].val = sym;
+                               cs->flags |= def_flags;
                                break;
                        }
                        cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
@@ -837,6 +835,8 @@ int conf_write(const char *name)
                        sym_calc_value(sym);
                        if (!(sym->flags & SYMBOL_WRITE))
                                goto next;
+                       if (sym_is_choice_value(sym) && !menu_is_visible(menu->parent))
+                               goto next;
                        sym->flags &= ~SYMBOL_WRITE;
 
                        conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
@@ -1140,6 +1140,7 @@ static void randomize_choice_values(struct symbol *csym)
                else {
                        sym->def[S_DEF_USER].tri = no;
                }
+               sym->flags &= ~(SYMBOL_VALID);
        }
        csym->flags |= SYMBOL_DEF_USER;
        /* clear VALID to get value calculated */
@@ -1172,7 +1173,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
        int i, cnt;
 
        for_all_symbols(i, sym) {
-               if (sym_has_value(sym))
+               if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
                        continue;
                switch (sym_get_type(sym)) {
                case S_BOOLEAN:
@@ -1188,7 +1189,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
                                sym->def[S_DEF_USER].tri = no;
                                break;
                        case def_random:
-                               cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
+                               cnt = sym->type == S_TRISTATE ? 3 : 2;
                                sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
                                break;
                        default: