aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kbuild/kconfig-language.txt1
-rw-r--r--scripts/kconfig/conf.c2
-rw-r--r--scripts/kconfig/confdata.c27
-rw-r--r--scripts/kconfig/expr.c44
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/lkc.h7
-rw-r--r--scripts/kconfig/menu.c15
-rw-r--r--scripts/kconfig/nconf.c10
-rw-r--r--scripts/kconfig/symbol.c8
9 files changed, 84 insertions, 33 deletions
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 2fe93ca7c77c..5b9b1be6fde2 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -112,7 +112,6 @@ applicable everywhere (see syntax).
112 (no prompts anywhere) and for symbols with no dependencies. 112 (no prompts anywhere) and for symbols with no dependencies.
113 That will limit the usefulness but on the other hand avoid 113 That will limit the usefulness but on the other hand avoid
114 the illegal configurations all over. 114 the illegal configurations all over.
115 kconfig should one day warn about such things.
116 115
117- numerical ranges: "range" <symbol> <symbol> ["if" <expr>] 116- numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
118 This allows to limit the range of possible input values for int 117 This allows to limit the range of possible input values for int
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 5459a38be866..659326c3e895 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -529,8 +529,6 @@ int main(int ac, char **av)
529 } 529 }
530 break; 530 break;
531 case savedefconfig: 531 case savedefconfig:
532 conf_read(NULL);
533 break;
534 case silentoldconfig: 532 case silentoldconfig:
535 case oldaskconfig: 533 case oldaskconfig:
536 case oldconfig: 534 case oldconfig:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 9df80114b47b..61c35bf2d9cb 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -440,12 +440,11 @@ static void conf_write_string(bool headerfile, const char *name,
440 fputs("\"\n", out); 440 fputs("\"\n", out);
441} 441}
442 442
443static void conf_write_symbol(struct symbol *sym, enum symbol_type type, 443static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
444 FILE *out, bool write_no)
445{ 444{
446 const char *str; 445 const char *str;
447 446
448 switch (type) { 447 switch (sym->type) {
449 case S_BOOLEAN: 448 case S_BOOLEAN:
450 case S_TRISTATE: 449 case S_TRISTATE:
451 switch (sym_get_tristate_value(sym)) { 450 switch (sym_get_tristate_value(sym)) {
@@ -532,7 +531,7 @@ int conf_write_defconfig(const char *filename)
532 goto next_menu; 531 goto next_menu;
533 } 532 }
534 } 533 }
535 conf_write_symbol(sym, sym->type, out, true); 534 conf_write_symbol(sym, out, true);
536 } 535 }
537next_menu: 536next_menu:
538 if (menu->list != NULL) { 537 if (menu->list != NULL) {
@@ -561,7 +560,6 @@ int conf_write(const char *name)
561 const char *basename; 560 const char *basename;
562 const char *str; 561 const char *str;
563 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; 562 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
564 enum symbol_type type;
565 time_t now; 563 time_t now;
566 int use_timestamp = 1; 564 int use_timestamp = 1;
567 char *env; 565 char *env;
@@ -633,14 +631,8 @@ int conf_write(const char *name)
633 if (!(sym->flags & SYMBOL_WRITE)) 631 if (!(sym->flags & SYMBOL_WRITE))
634 goto next; 632 goto next;
635 sym->flags &= ~SYMBOL_WRITE; 633 sym->flags &= ~SYMBOL_WRITE;
636 type = sym->type;
637 if (type == S_TRISTATE) {
638 sym_calc_value(modules_sym);
639 if (modules_sym->curr.tri == no)
640 type = S_BOOLEAN;
641 }
642 /* Write config symbol to file */ 634 /* Write config symbol to file */
643 conf_write_symbol(sym, type, out, true); 635 conf_write_symbol(sym, out, true);
644 } 636 }
645 637
646next: 638next:
@@ -833,8 +825,7 @@ int conf_write_autoconf(void)
833 " * Automatically generated C config: don't edit\n" 825 " * Automatically generated C config: don't edit\n"
834 " * %s\n" 826 " * %s\n"
835 " * %s" 827 " * %s"
836 " */\n" 828 " */\n",
837 "#define AUTOCONF_INCLUDED\n",
838 rootmenu.prompt->text, ctime(&now)); 829 rootmenu.prompt->text, ctime(&now));
839 830
840 for_all_symbols(i, sym) { 831 for_all_symbols(i, sym) {
@@ -843,7 +834,7 @@ int conf_write_autoconf(void)
843 continue; 834 continue;
844 835
845 /* write symbol to config file */ 836 /* write symbol to config file */
846 conf_write_symbol(sym, sym->type, out, false); 837 conf_write_symbol(sym, out, false);
847 838
848 /* update autoconf and tristate files */ 839 /* update autoconf and tristate files */
849 switch (sym->type) { 840 switch (sym->type) {
@@ -946,7 +937,7 @@ static void randomize_choice_values(struct symbol *csym)
946 int cnt, def; 937 int cnt, def;
947 938
948 /* 939 /*
949 * If choice is mod then we may have more items slected 940 * If choice is mod then we may have more items selected
950 * and if no then no-one. 941 * and if no then no-one.
951 * In both cases stop. 942 * In both cases stop.
952 */ 943 */
@@ -1042,10 +1033,10 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1042 1033
1043 /* 1034 /*
1044 * We have different type of choice blocks. 1035 * We have different type of choice blocks.
1045 * If curr.tri equal to mod then we can select several 1036 * If curr.tri equals to mod then we can select several
1046 * choice symbols in one block. 1037 * choice symbols in one block.
1047 * In this case we do nothing. 1038 * In this case we do nothing.
1048 * If curr.tri equal yes then only one symbol can be 1039 * If curr.tri equals yes then only one symbol can be
1049 * selected in a choice block and we set it to yes, 1040 * selected in a choice block and we set it to yes,
1050 * and the rest to no. 1041 * and the rest to no.
1051 */ 1042 */
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 330e7c0048a8..001003452f68 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
64 return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; 64 return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
65} 65}
66 66
67struct expr *expr_copy(struct expr *org) 67struct expr *expr_copy(const struct expr *org)
68{ 68{
69 struct expr *e; 69 struct expr *e;
70 70
@@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
1013#endif 1013#endif
1014} 1014}
1015 1015
1016static inline struct expr *
1017expr_get_leftmost_symbol(const struct expr *e)
1018{
1019
1020 if (e == NULL)
1021 return NULL;
1022
1023 while (e->type != E_SYMBOL)
1024 e = e->left.expr;
1025
1026 return expr_copy(e);
1027}
1028
1029/*
1030 * Given expression `e1' and `e2', returns the leaf of the longest
1031 * sub-expression of `e1' not containing 'e2.
1032 */
1033struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
1034{
1035 struct expr *ret;
1036
1037 switch (e1->type) {
1038 case E_OR:
1039 return expr_alloc_and(
1040 expr_simplify_unmet_dep(e1->left.expr, e2),
1041 expr_simplify_unmet_dep(e1->right.expr, e2));
1042 case E_AND: {
1043 struct expr *e;
1044 e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
1045 e = expr_eliminate_dups(e);
1046 ret = (!expr_eq(e, e1)) ? e1 : NULL;
1047 expr_free(e);
1048 break;
1049 }
1050 default:
1051 ret = e1;
1052 break;
1053 }
1054
1055 return expr_get_leftmost_symbol(ret);
1056}
1057
1016void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) 1058void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
1017{ 1059{
1018 if (!e) { 1060 if (!e) {
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index e57826ced380..3d238db49764 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -192,7 +192,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
192struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); 192struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
193struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); 193struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
194struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); 194struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
195struct expr *expr_copy(struct expr *org); 195struct expr *expr_copy(const struct expr *org);
196void expr_free(struct expr *e); 196void expr_free(struct expr *e);
197int expr_eq(struct expr *e1, struct expr *e2); 197int expr_eq(struct expr *e1, struct expr *e2);
198void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); 198void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
@@ -207,6 +207,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
207struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); 207struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
208void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); 208void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
209struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); 209struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
210struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
210 211
211void expr_fprint(struct expr *e, FILE *out); 212void expr_fprint(struct expr *e, FILE *out);
212struct gstr; /* forward */ 213struct gstr; /* forward */
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 3f7240df0f3b..febf0c94d558 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -14,6 +14,7 @@
14static inline const char *gettext(const char *txt) { return txt; } 14static inline const char *gettext(const char *txt) { return txt; }
15static inline void textdomain(const char *domainname) {} 15static inline void textdomain(const char *domainname) {}
16static inline void bindtextdomain(const char *name, const char *dir) {} 16static inline void bindtextdomain(const char *name, const char *dir) {}
17static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
17#endif 18#endif
18 19
19#ifdef __cplusplus 20#ifdef __cplusplus
@@ -67,10 +68,12 @@ struct kconf_id {
67 enum symbol_type stype; 68 enum symbol_type stype;
68}; 69};
69 70
71#ifdef YYDEBUG
72extern int zconfdebug;
73#endif
74
70int zconfparse(void); 75int zconfparse(void);
71void zconfdump(FILE *out); 76void zconfdump(FILE *out);
72
73extern int zconfdebug;
74void zconf_starthelp(void); 77void zconf_starthelp(void);
75FILE *zconf_fopen(const char *name); 78FILE *zconf_fopen(const char *name);
76void zconf_initscan(const char *name); 79void zconf_initscan(const char *name);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 5f77dcb8977e..5fdf10dc1d8a 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -203,7 +203,7 @@ void menu_add_option(int token, char *arg)
203 } 203 }
204} 204}
205 205
206static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) 206static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
207{ 207{
208 return sym2->type == S_INT || sym2->type == S_HEX || 208 return sym2->type == S_INT || sym2->type == S_HEX ||
209 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); 209 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
@@ -221,6 +221,15 @@ static void sym_check_prop(struct symbol *sym)
221 prop_warn(prop, 221 prop_warn(prop,
222 "default for config symbol '%s'" 222 "default for config symbol '%s'"
223 " must be a single symbol", sym->name); 223 " must be a single symbol", sym->name);
224 if (prop->expr->type != E_SYMBOL)
225 break;
226 sym2 = prop_get_symbol(prop);
227 if (sym->type == S_HEX || sym->type == S_INT) {
228 if (!menu_validate_number(sym, sym2))
229 prop_warn(prop,
230 "'%s': number is invalid",
231 sym->name);
232 }
224 break; 233 break;
225 case P_SELECT: 234 case P_SELECT:
226 sym2 = prop_get_symbol(prop); 235 sym2 = prop_get_symbol(prop);
@@ -240,8 +249,8 @@ static void sym_check_prop(struct symbol *sym)
240 if (sym->type != S_INT && sym->type != S_HEX) 249 if (sym->type != S_INT && sym->type != S_HEX)
241 prop_warn(prop, "range is only allowed " 250 prop_warn(prop, "range is only allowed "
242 "for int or hex symbols"); 251 "for int or hex symbols");
243 if (!menu_range_valid_sym(sym, prop->expr->left.sym) || 252 if (!menu_validate_number(sym, prop->expr->left.sym) ||
244 !menu_range_valid_sym(sym, prop->expr->right.sym)) 253 !menu_validate_number(sym, prop->expr->right.sym))
245 prop_warn(prop, "range is invalid"); 254 prop_warn(prop, "range is invalid");
246 break; 255 break;
247 default: 256 default:
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 272a987f23e0..db56377393d7 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -248,7 +248,7 @@ search_help[] = N_(
248"Only relevant lines are shown.\n" 248"Only relevant lines are shown.\n"
249"\n\n" 249"\n\n"
250"Search examples:\n" 250"Search examples:\n"
251"Examples: USB = > find all symbols containing USB\n" 251"Examples: USB => find all symbols containing USB\n"
252" ^USB => find all symbols starting with USB\n" 252" ^USB => find all symbols starting with USB\n"
253" USB$ => find all symbols ending with USB\n" 253" USB$ => find all symbols ending with USB\n"
254"\n"); 254"\n");
@@ -1266,9 +1266,13 @@ static void conf_choice(struct menu *menu)
1266 if (child->sym == sym_get_choice_value(menu->sym)) 1266 if (child->sym == sym_get_choice_value(menu->sym))
1267 item_make(child, ':', "<X> %s", 1267 item_make(child, ':', "<X> %s",
1268 _(menu_get_prompt(child))); 1268 _(menu_get_prompt(child)));
1269 else 1269 else if (child->sym)
1270 item_make(child, ':', " %s", 1270 item_make(child, ':', " %s",
1271 _(menu_get_prompt(child))); 1271 _(menu_get_prompt(child)));
1272 else
1273 item_make(child, ':', "*** %s ***",
1274 _(menu_get_prompt(child)));
1275
1272 if (child->sym == active){ 1276 if (child->sym == active){
1273 last_top_row = top_row(curses_menu); 1277 last_top_row = top_row(curses_menu);
1274 selected_index = i; 1278 selected_index = i;
@@ -1334,7 +1338,7 @@ static void conf_choice(struct menu *menu)
1334 break; 1338 break;
1335 1339
1336 child = item_data(); 1340 child = item_data();
1337 if (!child || !menu_is_visible(child)) 1341 if (!child || !menu_is_visible(child) || !child->sym)
1338 continue; 1342 continue;
1339 switch (res) { 1343 switch (res) {
1340 case ' ': 1344 case ' ':
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index af6e9f3de950..a796c95fe8a0 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -351,12 +351,16 @@ void sym_calc_value(struct symbol *sym)
351 } 351 }
352 calc_newval: 352 calc_newval:
353 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { 353 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
354 struct expr *e;
355 e = expr_simplify_unmet_dep(sym->rev_dep.expr,
356 sym->dir_dep.expr);
354 fprintf(stderr, "warning: ("); 357 fprintf(stderr, "warning: (");
355 expr_fprint(sym->rev_dep.expr, stderr); 358 expr_fprint(e, stderr);
356 fprintf(stderr, ") selects %s which has unmet direct dependencies (", 359 fprintf(stderr, ") selects %s which has unmet direct dependencies (",
357 sym->name); 360 sym->name);
358 expr_fprint(sym->dir_dep.expr, stderr); 361 expr_fprint(sym->dir_dep.expr, stderr);
359 fprintf(stderr, ")\n"); 362 fprintf(stderr, ")\n");
363 expr_free(e);
360 } 364 }
361 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); 365 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
362 } 366 }
@@ -686,7 +690,7 @@ const char *sym_get_string_default(struct symbol *sym)
686 switch (sym->type) { 690 switch (sym->type) {
687 case S_BOOLEAN: 691 case S_BOOLEAN:
688 case S_TRISTATE: 692 case S_TRISTATE:
689 /* The visibility imay limit the value from yes => mod */ 693 /* The visibility may limit the value from yes => mod */
690 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); 694 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
691 break; 695 break;
692 default: 696 default: