Skip to content

Commit c39afe6

Browse files
joshtriplettmasahir0y
authored andcommitted
kconfig: Add make mod2noconfig to disable module options
When converting a modular kernel to a monolithic kernel, once the kernel works without loading any modules, this helps to quickly disable all the modules before turning off module support entirely. Refactor conf_rewrite_mod_or_yes to a more general conf_rewrite_tristates that accepts an old and new state. Signed-off-by: Josh Triplett <[email protected]> Tested-by: Björn Töpel <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent d58071a commit c39afe6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

scripts/kconfig/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ localyesconfig localmodconfig: $(obj)/conf
6969
# deprecated for external use
7070
simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
7171
alldefconfig randconfig listnewconfig olddefconfig syncconfig \
72-
helpnewconfig yes2modconfig mod2yesconfig
72+
helpnewconfig yes2modconfig mod2yesconfig mod2noconfig
7373

7474
PHONY += $(simple-targets)
7575

@@ -134,6 +134,7 @@ help:
134134
@echo ' randconfig - New config with random answer to all options'
135135
@echo ' yes2modconfig - Change answers from yes to mod if possible'
136136
@echo ' mod2yesconfig - Change answers from mod to yes if possible'
137+
@echo ' mod2noconfig - Change answers from mod to no if possible'
137138
@echo ' listnewconfig - List new options'
138139
@echo ' helpnewconfig - List new options and help text'
139140
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their'

scripts/kconfig/conf.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum input_mode {
3535
olddefconfig,
3636
yes2modconfig,
3737
mod2yesconfig,
38+
mod2noconfig,
3839
};
3940
static enum input_mode input_mode = oldaskconfig;
4041
static int input_mode_opt;
@@ -163,8 +164,6 @@ enum conf_def_mode {
163164
def_default,
164165
def_yes,
165166
def_mod,
166-
def_y2m,
167-
def_m2y,
168167
def_no,
169168
def_random
170169
};
@@ -302,12 +301,10 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode)
302301
return has_changed;
303302
}
304303

305-
static void conf_rewrite_mod_or_yes(enum conf_def_mode mode)
304+
static void conf_rewrite_tristates(tristate old_val, tristate new_val)
306305
{
307306
struct symbol *sym;
308307
int i;
309-
tristate old_val = (mode == def_y2m) ? yes : mod;
310-
tristate new_val = (mode == def_y2m) ? mod : yes;
311308

312309
for_all_symbols(i, sym) {
313310
if (sym_get_type(sym) == S_TRISTATE &&
@@ -685,6 +682,7 @@ static const struct option long_opts[] = {
685682
{"olddefconfig", no_argument, &input_mode_opt, olddefconfig},
686683
{"yes2modconfig", no_argument, &input_mode_opt, yes2modconfig},
687684
{"mod2yesconfig", no_argument, &input_mode_opt, mod2yesconfig},
685+
{"mod2noconfig", no_argument, &input_mode_opt, mod2noconfig},
688686
{NULL, 0, NULL, 0}
689687
};
690688

@@ -713,6 +711,7 @@ static void conf_usage(const char *progname)
713711
printf(" --randconfig New config with random answer to all options\n");
714712
printf(" --yes2modconfig Change answers from yes to mod if possible\n");
715713
printf(" --mod2yesconfig Change answers from mod to yes if possible\n");
714+
printf(" --mod2noconfig Change answers from mod to no if possible\n");
716715
printf(" (If none of the above is given, --oldaskconfig is the default)\n");
717716
}
718717

@@ -788,6 +787,7 @@ int main(int ac, char **av)
788787
case olddefconfig:
789788
case yes2modconfig:
790789
case mod2yesconfig:
790+
case mod2noconfig:
791791
conf_read(NULL);
792792
break;
793793
case allnoconfig:
@@ -862,10 +862,13 @@ int main(int ac, char **av)
862862
case savedefconfig:
863863
break;
864864
case yes2modconfig:
865-
conf_rewrite_mod_or_yes(def_y2m);
865+
conf_rewrite_tristates(yes, mod);
866866
break;
867867
case mod2yesconfig:
868-
conf_rewrite_mod_or_yes(def_m2y);
868+
conf_rewrite_tristates(mod, yes);
869+
break;
870+
case mod2noconfig:
871+
conf_rewrite_tristates(mod, no);
869872
break;
870873
case oldaskconfig:
871874
rootEntry = &rootmenu;

0 commit comments

Comments
 (0)