From: Roman Zippel <zippel@linux-m68k.org>

When a boolean choice value has a dependency of 'm' it can be shortly
treated as a tristate symbol.  This fixes this and also add a small
optimization to precompute the value of the module symbol instead of
checking it all the time.


---

 25-akpm/scripts/kconfig/confdata.c |    2 ++
 25-akpm/scripts/kconfig/symbol.c   |   26 +++++++++++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff -puN scripts/kconfig/confdata.c~config-choice-fix scripts/kconfig/confdata.c
--- 25/scripts/kconfig/confdata.c~config-choice-fix	Tue Mar 16 18:21:34 2004
+++ 25-akpm/scripts/kconfig/confdata.c	Tue Mar 16 18:21:34 2004
@@ -229,6 +229,8 @@ int conf_read(const char *name)
 	}
 	fclose(in);
 
+	if (modules_sym)
+		sym_calc_value(modules_sym);
 	for_all_symbols(i, sym) {
 		sym_calc_value(sym);
 		if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
diff -puN scripts/kconfig/symbol.c~config-choice-fix scripts/kconfig/symbol.c
--- 25/scripts/kconfig/symbol.c~config-choice-fix	Tue Mar 16 18:21:34 2004
+++ 25-akpm/scripts/kconfig/symbol.c	Tue Mar 16 18:21:34 2004
@@ -31,6 +31,7 @@ struct symbol symbol_yes = {
 
 int sym_change_count;
 struct symbol *modules_sym;
+tristate modules_val;
 
 void sym_add_default(struct symbol *sym, const char *def)
 {
@@ -79,11 +80,8 @@ enum symbol_type sym_get_type(struct sym
 	if (type == S_TRISTATE) {
 		if (sym_is_choice_value(sym) && sym->visible == yes)
 			type = S_BOOLEAN;
-		else {
-			sym_calc_value(modules_sym);
-			if (modules_sym->curr.tri == no)
-				type = S_BOOLEAN;
-		}
+		else if (modules_val == no)
+			type = S_BOOLEAN;
 	}
 	return type;
 }
@@ -153,6 +151,8 @@ static void sym_calc_visibility(struct s
 		prop->visible.tri = expr_calc_value(prop->visible.expr);
 		tri = E_OR(tri, prop->visible.tri);
 	}
+	if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
+		tri = yes;
 	if (sym->visible != tri) {
 		sym->visible = tri;
 		sym_set_changed(sym);
@@ -162,6 +162,8 @@ static void sym_calc_visibility(struct s
 	tri = no;
 	if (sym->rev_dep.expr)
 		tri = expr_calc_value(sym->rev_dep.expr);
+	if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
+		tri = yes;
 	if (sym->rev_dep.tri != tri) {
 		sym->rev_dep.tri = tri;
 		sym_set_changed(sym);
@@ -268,14 +270,8 @@ void sym_calc_value(struct symbol *sym)
 				newval.tri = expr_calc_value(prop->expr);
 			}
 		}
-		if (sym_get_type(sym) == S_BOOLEAN) {
-			if (newval.tri == mod)
-				newval.tri = yes;
-			if (sym->visible == mod)
-				sym->visible = yes;
-			if (sym->rev_dep.tri == mod)
-				sym->rev_dep.tri = yes;
-		}
+		if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
+			newval.tri = yes;
 		break;
 	case S_STRING:
 	case S_HEX:
@@ -307,6 +303,8 @@ void sym_calc_value(struct symbol *sym)
 
 	if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
 		sym_set_changed(sym);
+	if (modules_sym == sym)
+		modules_val = modules_sym->curr.tri;
 
 	if (sym_is_choice(sym)) {
 		int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
@@ -327,6 +325,8 @@ void sym_clear_all_valid(void)
 	for_all_symbols(i, sym)
 		sym->flags &= ~SYMBOL_VALID;
 	sym_change_count++;
+	if (modules_sym)
+		sym_calc_value(modules_sym);
 }
 
 void sym_set_changed(struct symbol *sym)

_