Skip to content

Commit face437

Browse files
Roman ZippelSam Ravnborg
authored andcommitted
kconfig: add defconfig_list/module option
This makes it possible to change two options which were hardcoded sofar. 1. Any symbol can now take the role of CONFIG_MODULES 2. The more useful option is to change the list of default file names, which kconfig uses to load the base configuration if .config isn't available. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent f6a88aa commit face437

8 files changed

Lines changed: 61 additions & 24 deletions

File tree

‎init/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
config DEFCONFIG_LIST
2+
string
3+
option defconfig_list
4+
default "/lib/modules/$UNAME_RELEASE/.config"
5+
default "/etc/kernel-config"
6+
default "/boot/config-$UNAME_RELEASE"
7+
default "arch/$ARCH/defconfig"
8+
19
menu "Code maturity level options"
210

311
config EXPERIMENTAL

‎scripts/kconfig/confdata.c‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ const char conf_def_filename[] = ".config";
2525

2626
const char conf_defname[] = "arch/$ARCH/defconfig";
2727

28-
const char *conf_confnames[] = {
29-
".config",
30-
"/lib/modules/$UNAME_RELEASE/.config",
31-
"/etc/kernel-config",
32-
"/boot/config-$UNAME_RELEASE",
33-
conf_defname,
34-
NULL,
35-
};
36-
3728
static void conf_warning(const char *fmt, ...)
3829
{
3930
va_list ap;
@@ -98,16 +89,21 @@ int conf_read_simple(const char *name, int def)
9889
if (name) {
9990
in = zconf_fopen(name);
10091
} else {
101-
const char **names = conf_confnames;
102-
name = *names++;
103-
if (!name)
104-
return 1;
92+
struct property *prop;
93+
94+
name = conf_def_filename;
10595
in = zconf_fopen(name);
10696
if (in)
10797
goto load;
10898
sym_change_count++;
109-
while ((name = *names++)) {
110-
name = conf_expand_value(name);
99+
if (!sym_defconfig_list)
100+
return 1;
101+
102+
for_all_defaults(sym_defconfig_list, prop) {
103+
if (expr_calc_value(prop->visible.expr) == no ||
104+
prop->expr->type != E_SYMBOL)
105+
continue;
106+
name = conf_expand_value(prop->expr->left.sym->name);
111107
in = zconf_fopen(name);
112108
if (in) {
113109
printf(_("#\n"

‎scripts/kconfig/expr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct file *lookup_file(const char *name);
156156

157157
extern struct symbol symbol_yes, symbol_no, symbol_mod;
158158
extern struct symbol *modules_sym;
159+
extern struct symbol *sym_defconfig_list;
159160
extern int cdebug;
160161
struct expr *expr_alloc_symbol(struct symbol *sym);
161162
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);

‎scripts/kconfig/lkc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const char *str_get(struct gstr *gs);
104104
/* symbol.c */
105105
void sym_init(void);
106106
void sym_clear_all_valid(void);
107+
void sym_set_all_changed(void);
107108
void sym_set_changed(struct symbol *sym);
108109
struct symbol *sym_check_deps(struct symbol *sym);
109110
struct property *prop_alloc(enum prop_type type, struct symbol *sym);

‎scripts/kconfig/menu.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
154154

155155
void menu_add_option(int token, char *arg)
156156
{
157+
struct property *prop;
158+
159+
switch (token) {
160+
case T_OPT_MODULES:
161+
prop = prop_alloc(P_DEFAULT, modules_sym);
162+
prop->expr = expr_alloc_symbol(current_entry->sym);
163+
break;
164+
case T_OPT_DEFCONFIG_LIST:
165+
if (!sym_defconfig_list)
166+
sym_defconfig_list = current_entry->sym;
167+
else if (sym_defconfig_list != current_entry->sym)
168+
zconf_error("trying to redefine defconfig symbol");
169+
break;
170+
}
157171
}
158172

159173
static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)

‎scripts/kconfig/symbol.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct symbol symbol_yes = {
3131
};
3232

3333
int sym_change_count;
34+
struct symbol *sym_defconfig_list;
3435
struct symbol *modules_sym;
3536
tristate modules_val;
3637

@@ -352,10 +353,13 @@ void sym_calc_value(struct symbol *sym)
352353
sym->curr.val = sym_calc_choice(sym);
353354
sym_validate_range(sym);
354355

355-
if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
356+
if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
356357
sym_set_changed(sym);
357-
if (modules_sym == sym)
358-
modules_val = modules_sym->curr.tri;
358+
if (modules_sym == sym) {
359+
sym_set_all_changed();
360+
modules_val = modules_sym->curr.tri;
361+
}
362+
}
359363

360364
if (sym_is_choice(sym)) {
361365
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
@@ -449,11 +453,8 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
449453
}
450454

451455
sym->def[S_DEF_USER].tri = val;
452-
if (oldval != val) {
456+
if (oldval != val)
453457
sym_clear_all_valid();
454-
if (sym == modules_sym)
455-
sym_set_all_changed();
456-
}
457458

458459
return true;
459460
}

‎scripts/kconfig/zconf.tab.c_shipped‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,9 @@ void conf_parse(const char *name)
21122112

21132113
sym_init();
21142114
menu_init();
2115-
modules_sym = sym_lookup("MODULES", 0);
2115+
modules_sym = sym_lookup(NULL, 0);
2116+
modules_sym->type = S_BOOLEAN;
2117+
modules_sym->flags |= SYMBOL_AUTO;
21162118
rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
21172119

21182120
#if YYDEBUG
@@ -2122,6 +2124,12 @@ void conf_parse(const char *name)
21222124
zconfparse();
21232125
if (zconfnerrs)
21242126
exit(1);
2127+
if (!modules_sym->prop) {
2128+
struct property *prop;
2129+
2130+
prop = prop_alloc(P_DEFAULT, modules_sym);
2131+
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
2132+
}
21252133
menu_finalize(&rootmenu);
21262134
for_all_symbols(i, sym) {
21272135
sym_check_deps(sym);

‎scripts/kconfig/zconf.y‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ void conf_parse(const char *name)
481481

482482
sym_init();
483483
menu_init();
484-
modules_sym = sym_lookup("MODULES", 0);
484+
modules_sym = sym_lookup(NULL, 0);
485+
modules_sym->type = S_BOOLEAN;
486+
modules_sym->flags |= SYMBOL_AUTO;
485487
rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
486488

487489
#if YYDEBUG
@@ -491,6 +493,12 @@ void conf_parse(const char *name)
491493
zconfparse();
492494
if (zconfnerrs)
493495
exit(1);
496+
if (!modules_sym->prop) {
497+
struct property *prop;
498+
499+
prop = prop_alloc(P_DEFAULT, modules_sym);
500+
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
501+
}
494502
menu_finalize(&rootmenu);
495503
for_all_symbols(i, sym) {
496504
sym_check_deps(sym);

0 commit comments

Comments
 (0)