diff options
Diffstat (limited to 'scripts/kconfig/symbol.c')
-rw-r--r-- | scripts/kconfig/symbol.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index bc1e1584e2da..0a013ab3ae27 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -226,22 +226,18 @@ static void sym_calc_visibility(struct symbol *sym) | |||
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | static struct symbol *sym_calc_choice(struct symbol *sym) | 229 | /* |
230 | * Find the default symbol for a choice. | ||
231 | * First try the default values for the choice symbol | ||
232 | * Next locate the first visible choice value | ||
233 | * Return NULL if none was found | ||
234 | */ | ||
235 | struct symbol *sym_choice_default(struct symbol *sym) | ||
230 | { | 236 | { |
231 | struct symbol *def_sym; | 237 | struct symbol *def_sym; |
232 | struct property *prop; | 238 | struct property *prop; |
233 | struct expr *e; | 239 | struct expr *e; |
234 | 240 | ||
235 | /* first calculate all choice values' visibilities */ | ||
236 | prop = sym_get_choice_prop(sym); | ||
237 | expr_list_for_each_sym(prop->expr, e, def_sym) | ||
238 | sym_calc_visibility(def_sym); | ||
239 | |||
240 | /* is the user choice visible? */ | ||
241 | def_sym = sym->def[S_DEF_USER].val; | ||
242 | if (def_sym && def_sym->visible != no) | ||
243 | return def_sym; | ||
244 | |||
245 | /* any of the defaults visible? */ | 241 | /* any of the defaults visible? */ |
246 | for_all_defaults(sym, prop) { | 242 | for_all_defaults(sym, prop) { |
247 | prop->visible.tri = expr_calc_value(prop->visible.expr); | 243 | prop->visible.tri = expr_calc_value(prop->visible.expr); |
@@ -258,11 +254,35 @@ static struct symbol *sym_calc_choice(struct symbol *sym) | |||
258 | if (def_sym->visible != no) | 254 | if (def_sym->visible != no) |
259 | return def_sym; | 255 | return def_sym; |
260 | 256 | ||
261 | /* no choice? reset tristate value */ | 257 | /* failed to locate any defaults */ |
262 | sym->curr.tri = no; | ||
263 | return NULL; | 258 | return NULL; |
264 | } | 259 | } |
265 | 260 | ||
261 | static struct symbol *sym_calc_choice(struct symbol *sym) | ||
262 | { | ||
263 | struct symbol *def_sym; | ||
264 | struct property *prop; | ||
265 | struct expr *e; | ||
266 | |||
267 | /* first calculate all choice values' visibilities */ | ||
268 | prop = sym_get_choice_prop(sym); | ||
269 | expr_list_for_each_sym(prop->expr, e, def_sym) | ||
270 | sym_calc_visibility(def_sym); | ||
271 | |||
272 | /* is the user choice visible? */ | ||
273 | def_sym = sym->def[S_DEF_USER].val; | ||
274 | if (def_sym && def_sym->visible != no) | ||
275 | return def_sym; | ||
276 | |||
277 | def_sym = sym_choice_default(sym); | ||
278 | |||
279 | if (def_sym == NULL) | ||
280 | /* no choice? reset tristate value */ | ||
281 | sym->curr.tri = no; | ||
282 | |||
283 | return def_sym; | ||
284 | } | ||
285 | |||
266 | void sym_calc_value(struct symbol *sym) | 286 | void sym_calc_value(struct symbol *sym) |
267 | { | 287 | { |
268 | struct symbol_value newval, oldval; | 288 | struct symbol_value newval, oldval; |