diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2010-07-31 17:35:32 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-08-03 07:49:32 -0400 |
commit | c252147de68cf58ba601278481e473dab432cee4 (patch) | |
tree | d69910edf4c8fe795788aac65fb0e7d320b64c68 /scripts/kconfig | |
parent | 0748cb3e1fbd89c03a98c15e91ad65797981de77 (diff) |
kconfig: refactor code in symbol.c
Move logic to determine default for a choice to
a separate function.
No functional changes.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/lkc.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 46 |
2 files changed, 34 insertions, 13 deletions
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index ce6549cdaccf..755b8190eb64 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -126,6 +126,7 @@ void sym_init(void); | |||
126 | void sym_clear_all_valid(void); | 126 | void sym_clear_all_valid(void); |
127 | void sym_set_all_changed(void); | 127 | void sym_set_all_changed(void); |
128 | void sym_set_changed(struct symbol *sym); | 128 | void sym_set_changed(struct symbol *sym); |
129 | struct symbol *sym_choice_default(struct symbol *sym); | ||
129 | struct symbol *sym_check_deps(struct symbol *sym); | 130 | struct symbol *sym_check_deps(struct symbol *sym); |
130 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); | 131 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); |
131 | struct symbol *prop_get_symbol(struct property *prop); | 132 | struct symbol *prop_get_symbol(struct property *prop); |
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; |