aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/conf.c154
1 files changed, 68 insertions, 86 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda63136ae68..bd2a27e1967a 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -76,7 +76,6 @@ static void check_stdin(void)
76static int conf_askvalue(struct symbol *sym, const char *def) 76static int conf_askvalue(struct symbol *sym, const char *def)
77{ 77{
78 enum symbol_type type = sym_get_type(sym); 78 enum symbol_type type = sym_get_type(sym);
79 tristate val;
80 79
81 if (!sym_has_value(sym)) 80 if (!sym_has_value(sym))
82 printf(_("(NEW) ")); 81 printf(_("(NEW) "));
@@ -92,15 +91,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
92 } 91 }
93 92
94 switch (input_mode) { 93 switch (input_mode) {
95 case set_no:
96 case set_mod:
97 case set_yes:
98 case set_random:
99 if (sym_has_value(sym)) {
100 printf("%s\n", def);
101 return 0;
102 }
103 break;
104 case ask_new: 94 case ask_new:
105 case ask_silent: 95 case ask_silent:
106 if (sym_has_value(sym)) { 96 if (sym_has_value(sym)) {
@@ -128,52 +118,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
128 default: 118 default:
129 ; 119 ;
130 } 120 }
131 switch (input_mode) {
132 case set_yes:
133 if (sym_tristate_within_range(sym, yes)) {
134 line[0] = 'y';
135 line[1] = '\n';
136 line[2] = 0;
137 break;
138 }
139 case set_mod:
140 if (type == S_TRISTATE) {
141 if (sym_tristate_within_range(sym, mod)) {
142 line[0] = 'm';
143 line[1] = '\n';
144 line[2] = 0;
145 break;
146 }
147 } else {
148 if (sym_tristate_within_range(sym, yes)) {
149 line[0] = 'y';
150 line[1] = '\n';
151 line[2] = 0;
152 break;
153 }
154 }
155 case set_no:
156 if (sym_tristate_within_range(sym, no)) {
157 line[0] = 'n';
158 line[1] = '\n';
159 line[2] = 0;
160 break;
161 }
162 case set_random:
163 do {
164 val = (tristate)(rand() % 3);
165 } while (!sym_tristate_within_range(sym, val));
166 switch (val) {
167 case no: line[0] = 'n'; break;
168 case mod: line[0] = 'm'; break;
169 case yes: line[0] = 'y'; break;
170 }
171 line[1] = '\n';
172 line[2] = 0;
173 break;
174 default:
175 break;
176 }
177 printf("%s", line); 121 printf("%s", line);
178 return 1; 122 return 1;
179} 123}
@@ -374,16 +318,12 @@ static int conf_choice(struct menu *menu)
374 else 318 else
375 continue; 319 continue;
376 break; 320 break;
377 case set_random:
378 if (is_new)
379 def = (rand() % cnt) + 1;
380 case set_default: 321 case set_default:
381 case set_yes:
382 case set_mod:
383 case set_no:
384 cnt = def; 322 cnt = def;
385 printf("%d\n", cnt); 323 printf("%d\n", cnt);
386 break; 324 break;
325 default:
326 break;
387 } 327 }
388 328
389 conf_childs: 329 conf_childs:
@@ -494,6 +434,43 @@ static void check_conf(struct menu *menu)
494 check_conf(child); 434 check_conf(child);
495} 435}
496 436
437static void conf_do_update(void)
438{
439 /* Update until a loop caused no more changes */
440 do {
441 conf_cnt = 0;
442 check_conf(&rootmenu);
443 } while (conf_cnt);
444}
445
446static int conf_silent_update(void)
447{
448 const char *name;
449
450 if (conf_get_changed()) {
451 name = getenv("KCONFIG_NOSILENTUPDATE");
452 if (name && *name) {
453 fprintf(stderr,
454 _("\n*** Kernel configuration requires explicit update.\n\n"));
455 return 1;
456 }
457 conf_do_update();
458 }
459 return 0;
460}
461
462static int conf_update(void)
463{
464 rootEntry = &rootmenu;
465 conf(&rootmenu);
466 if (input_mode == ask_all) {
467 input_mode = ask_silent;
468 valid_stdin = 1;
469 }
470 conf_do_update();
471 return 0;
472}
473
497int main(int ac, char **av) 474int main(int ac, char **av)
498{ 475{
499 int opt; 476 int opt;
@@ -599,36 +576,41 @@ int main(int ac, char **av)
599 default: 576 default:
600 break; 577 break;
601 } 578 }
579 switch (input_mode) {
580 case set_no:
581 conf_set_all_new_symbols(def_no);
582 break;
583 case set_yes:
584 conf_set_all_new_symbols(def_yes);
585 break;
586 case set_mod:
587 conf_set_all_new_symbols(def_mod);
588 break;
589 case set_random:
590 conf_set_all_new_symbols(def_random);
591 break;
592 case ask_silent:
593 if (conf_silent_update())
594 exit(1);
595 break;
596 case ask_new:
597 case ask_all:
598 case set_default:
599 if (conf_update())
600 exit(1);
601 break;
602 }
602 603
603 if (input_mode != ask_silent) { 604 if (conf_get_changed() && conf_write(NULL)) {
604 rootEntry = &rootmenu;
605 conf(&rootmenu);
606 if (input_mode == ask_all) {
607 input_mode = ask_silent;
608 valid_stdin = 1;
609 }
610 } else if (conf_get_changed()) {
611 name = getenv("KCONFIG_NOSILENTUPDATE");
612 if (name && *name) {
613 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
614 return 1;
615 }
616 } else
617 goto skip_check;
618
619 do {
620 conf_cnt = 0;
621 check_conf(&rootmenu);
622 } while (conf_cnt);
623 if (conf_write(NULL)) {
624 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 605 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
625 return 1; 606 exit(1);
626 } 607 }
627skip_check: 608 /* ask_silent is used during the build so we shall update autoconf.
609 * All other commands are only used to generate a config.
610 */
628 if (input_mode == ask_silent && conf_write_autoconf()) { 611 if (input_mode == ask_silent && conf_write_autoconf()) {
629 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 612 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
630 return 1; 613 return 1;
631 } 614 }
632
633 return 0; 615 return 0;
634} 616}