]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - scripts/kconfig/confdata.c
hugetlbfs read() support
[linux-2.6-omap-h63xx.git] / scripts / kconfig / confdata.c
index 140742ebd73c9b959e779db0b14e75ba5837f6c1..b2913e9da495bf921b9d004012adef18996f4efa 100644 (file)
@@ -100,7 +100,7 @@ int conf_read_simple(const char *name, int def)
                in = zconf_fopen(name);
                if (in)
                        goto load;
-               sym_change_count++;
+               sym_add_change_count(1);
                if (!sym_defconfig_list)
                        return 1;
 
@@ -312,7 +312,7 @@ int conf_read(const char *name)
        struct expr *e;
        int i, flags;
 
-       sym_change_count = 0;
+       sym_set_change_count(0);
 
        if (conf_read_simple(name, S_DEF_USER))
                return 1;
@@ -341,30 +341,45 @@ int conf_read(const char *name)
                conf_unsaved++;
                /* maybe print value in verbose mode... */
        sym_ok:
+               if (!sym_is_choice(sym))
+                       continue;
+               /* The choice symbol only has a set value (and thus is not new)
+                * if all its visible childs have values.
+                */
+               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;
+               sym->flags &= flags | ~SYMBOL_DEF_USER;
+       }
+
+       for_all_symbols(i, sym) {
                if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
-                       if (sym->visible == no)
+                       /* Reset values of generates values, so they'll appear
+                        * as new, if they should become visible, but that
+                        * doesn't quite work if the Kconfig and the saved
+                        * configuration disagree.
+                        */
+                       if (sym->visible == no && !conf_unsaved)
                                sym->flags &= ~SYMBOL_DEF_USER;
                        switch (sym->type) {
                        case S_STRING:
                        case S_INT:
                        case S_HEX:
-                               if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val))
-                                       sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
+                               /* Reset a string value if it's out of range */
+                               if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
+                                       break;
+                               sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
+                               conf_unsaved++;
+                               break;
                        default:
                                break;
                        }
                }
-               if (!sym_is_choice(sym))
-                       continue;
-               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;
-               sym->flags &= flags | ~SYMBOL_DEF_USER;
        }
 
-       sym_change_count += conf_warnings || conf_unsaved;
+       sym_add_change_count(conf_warnings || conf_unsaved);
 
        return 0;
 }
@@ -528,7 +543,7 @@ int conf_write(const char *name)
                 "# configuration written to %s\n"
                 "#\n"), newname);
 
-       sym_change_count = 0;
+       sym_set_change_count(0);
 
        return 0;
 }
@@ -766,7 +781,29 @@ int conf_write_autoconf(void)
        return 0;
 }
 
+static int sym_change_count;
+static void (*conf_changed_callback)(void);
+
+void sym_set_change_count(int count)
+{
+       int _sym_change_count = sym_change_count;
+       sym_change_count = count;
+       if (conf_changed_callback &&
+           (bool)_sym_change_count != (bool)count)
+               conf_changed_callback();
+}
+
+void sym_add_change_count(int count)
+{
+       sym_set_change_count(count + sym_change_count);
+}
+
 bool conf_get_changed(void)
 {
        return sym_change_count;
 }
+
+void conf_set_changed_callback(void (*fn)(void))
+{
+       conf_changed_callback = fn;
+}