sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / scripts / kconfig / confdata.c
index 497a19e..b55e72f 100644 (file)
@@ -41,6 +41,13 @@ const char *conf_get_configname(void)
        return name ? name : ".config";
 }
 
+const char *conf_get_autoconfig_name(void)
+{
+       char *name = getenv("KCONFIG_AUTOCONFIG");
+
+       return name ? name : "include/config/auto.conf";
+}
+
 static char *conf_expand_value(const char *in)
 {
        struct symbol *sym;
@@ -223,7 +230,7 @@ load:
                        if (def == S_DEF_USER) {
                                sym = sym_find(line + 9);
                                if (!sym) {
-                                       conf_warning("trying to assign nonexistent symbol %s", line + 9);
+                                       sym_add_change_count(1);
                                        break;
                                }
                        } else {
@@ -262,7 +269,7 @@ load:
                        if (def == S_DEF_USER) {
                                sym = sym_find(line + 7);
                                if (!sym) {
-                                       conf_warning("trying to assign nonexistent symbol %s", line + 7);
+                                       sym_add_change_count(1);
                                        break;
                                }
                        } else {
@@ -312,7 +319,7 @@ load:
 
 int conf_read(const char *name)
 {
-       struct symbol *sym;
+       struct symbol *sym, *choice_sym;
        struct property *prop;
        struct expr *e;
        int i, flags;
@@ -353,9 +360,9 @@ int conf_read(const char *name)
                 */
                prop = sym_get_choice_prop(sym);
                flags = sym->flags;
-               for (e = prop->expr; e; e = e->left.expr)
-                       if (e->right.sym->visible != no)
-                               flags &= e->right.sym->flags;
+               expr_list_for_each_sym(prop->expr, e, choice_sym)
+                       if (choice_sym->visible != no)
+                               flags &= choice_sym->flags;
                sym->flags &= flags | ~SYMBOL_DEF_USER;
        }
 
@@ -553,17 +560,16 @@ int conf_write(const char *name)
        return 0;
 }
 
-int conf_split_config(void)
+static int conf_split_config(void)
 {
-       char *name, path[128];
+       const char *name;
+       char path[128];
        char *s, *d, c;
        struct symbol *sym;
        struct stat sb;
        int res, i, fd;
 
-       name = getenv("KCONFIG_AUTOCONFIG");
-       if (!name)
-               name = "include/config/auto.conf";
+       name = conf_get_autoconfig_name();
        conf_read_simple(name, S_DEF_AUTO);
 
        if (chdir("include/config"))
@@ -670,7 +676,7 @@ int conf_write_autoconf(void)
 {
        struct symbol *sym;
        const char *str;
-       char *name;
+       const char *name;
        FILE *out, *out_h;
        time_t now;
        int i, l;
@@ -773,9 +779,7 @@ int conf_write_autoconf(void)
                name = "include/linux/autoconf.h";
        if (rename(".tmpconfig.h", name))
                return 1;
-       name = getenv("KCONFIG_AUTOCONFIG");
-       if (!name)
-               name = "include/config/auto.conf";
+       name = conf_get_autoconfig_name();
        /*
         * This must be the last step, kbuild has a dependency on auto.conf
         * and this marks the successful completion of the previous steps.
@@ -812,3 +816,93 @@ 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;
+               }
+
+       }
+
+       sym_clear_all_valid();
+
+       if (mode != def_random)
+               return;
+       /*
+        * We have different type of choice blocks.
+        * If curr.tri equal to mod then we can select several
+        * choice symbols in one block.
+        * In this case we do nothing.
+        * If curr.tri equal yes then only one symbol can be
+        * selected in a choice block and we set it to yes,
+        * and the rest to no.
+        */
+       for_all_symbols(i, csym) {
+               if (sym_has_value(csym) || !sym_is_choice(csym))
+                       continue;
+
+               sym_calc_value(csym);
+
+               if (csym->curr.tri != yes)
+                       continue;
+
+               prop = sym_get_choice_prop(csym);
+
+               /* count entries in choice block */
+               cnt = 0;
+               expr_list_for_each_sym(prop->expr, e, sym)
+                       cnt++;
+
+               /*
+                * find a random value and set it to yes,
+                * set the rest to no so we have only one set
+                */
+               def = (rand() % cnt);
+
+               cnt = 0;
+               expr_list_for_each_sym(prop->expr, e, sym) {
+                       if (def == cnt++) {
+                               sym->def[S_DEF_USER].tri = yes;
+                               csym->def[S_DEF_USER].val = sym;
+                       }
+                       else {
+                               sym->def[S_DEF_USER].tri = no;
+                       }
+               }
+               csym->flags |= SYMBOL_DEF_USER;
+               /* clear VALID to get value calculated */
+               csym->flags &= ~(SYMBOL_VALID);
+       }
+}