hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/scripts/kconfig/conf.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3
- * Released under the terms of the GNU GPL v2.0.
44 */
55
66 #include <ctype.h>
....@@ -32,7 +32,10 @@
3232 defconfig,
3333 savedefconfig,
3434 listnewconfig,
35
+ helpnewconfig,
3536 olddefconfig,
37
+ yes2modconfig,
38
+ mod2yesconfig,
3639 };
3740 static enum input_mode input_mode = oldaskconfig;
3841
....@@ -90,7 +93,7 @@
9093 line[0] = '\n';
9194 line[1] = 0;
9295
93
- if (!sym_is_changable(sym)) {
96
+ if (!sym_is_changeable(sym)) {
9497 printf("%s\n", def);
9598 line[0] = '\n';
9699 line[1] = 0;
....@@ -234,7 +237,7 @@
234237
235238 sym = menu->sym;
236239 is_new = !sym_has_value(sym);
237
- if (sym_is_changable(sym)) {
240
+ if (sym_is_changeable(sym)) {
238241 conf_sym(menu);
239242 sym_calc_value(sym);
240243 switch (sym_get_tristate_value(sym)) {
....@@ -418,7 +421,7 @@
418421
419422 sym = menu->sym;
420423 if (sym && !sym_has_value(sym)) {
421
- if (sym_is_changable(sym) ||
424
+ if (sym_is_changeable(sym) ||
422425 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
423426 if (input_mode == listnewconfig) {
424427 if (sym->name) {
....@@ -434,6 +437,11 @@
434437 printf("%s%s=%s\n", CONFIG_, sym->name, str);
435438 }
436439 }
440
+ } else if (input_mode == helpnewconfig) {
441
+ printf("-----\n");
442
+ print_help(menu);
443
+ printf("-----\n");
444
+
437445 } else {
438446 if (!conf_cnt++)
439447 printf("*\n* Restart config...\n*\n");
....@@ -451,7 +459,7 @@
451459 {"oldaskconfig", no_argument, NULL, oldaskconfig},
452460 {"oldconfig", no_argument, NULL, oldconfig},
453461 {"syncconfig", no_argument, NULL, syncconfig},
454
- {"defconfig", optional_argument, NULL, defconfig},
462
+ {"defconfig", required_argument, NULL, defconfig},
455463 {"savedefconfig", required_argument, NULL, savedefconfig},
456464 {"allnoconfig", no_argument, NULL, allnoconfig},
457465 {"allyesconfig", no_argument, NULL, allyesconfig},
....@@ -459,13 +467,10 @@
459467 {"alldefconfig", no_argument, NULL, alldefconfig},
460468 {"randconfig", no_argument, NULL, randconfig},
461469 {"listnewconfig", no_argument, NULL, listnewconfig},
470
+ {"helpnewconfig", no_argument, NULL, helpnewconfig},
462471 {"olddefconfig", no_argument, NULL, olddefconfig},
463
- /*
464
- * oldnoconfig is an alias of olddefconfig, because people already
465
- * are dependent on its behavior(sets new symbols to their default
466
- * value but not 'n') with the counter-intuitive name.
467
- */
468
- {"oldnoconfig", no_argument, NULL, olddefconfig},
472
+ {"yes2modconfig", no_argument, NULL, yes2modconfig},
473
+ {"mod2yesconfig", no_argument, NULL, mod2yesconfig},
469474 {NULL, 0, NULL, 0}
470475 };
471476
....@@ -475,12 +480,12 @@
475480 printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
476481 printf("[option] is _one_ of the following:\n");
477482 printf(" --listnewconfig List new options\n");
483
+ printf(" --helpnewconfig List new options and help text\n");
478484 printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
479485 printf(" --oldconfig Update a configuration using a provided .config as base\n");
480486 printf(" --syncconfig Similar to oldconfig but generates configuration in\n"
481487 " include/{generated/,config/}\n");
482488 printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n");
483
- printf(" --oldnoconfig An alias of olddefconfig\n");
484489 printf(" --defconfig <file> New config with default defined in <file>\n");
485490 printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
486491 printf(" --allnoconfig New config where all options are answered with no\n");
....@@ -488,6 +493,8 @@
488493 printf(" --allmodconfig New config where all options are answered with mod\n");
489494 printf(" --alldefconfig New config with all symbols set to default\n");
490495 printf(" --randconfig New config with random answer to all options\n");
496
+ printf(" --yes2modconfig Change answers from yes to mod if possible\n");
497
+ printf(" --mod2yesconfig Change answers from mod to yes if possible\n");
491498 }
492499
493500 int main(int ac, char **av)
....@@ -495,7 +502,6 @@
495502 const char *progname = av[0];
496503 int opt;
497504 const char *name, *defconfig_file = NULL /* gcc uninit */;
498
- struct stat tmpstat;
499505 int no_conf_write = 0;
500506
501507 tty_stdio = isatty(0) && isatty(1);
....@@ -551,7 +557,10 @@
551557 case allmodconfig:
552558 case alldefconfig:
553559 case listnewconfig:
560
+ case helpnewconfig:
554561 case olddefconfig:
562
+ case yes2modconfig:
563
+ case mod2yesconfig:
555564 break;
556565 case '?':
557566 conf_usage(progname);
....@@ -567,23 +576,9 @@
567576 name = av[optind];
568577 conf_parse(name);
569578 //zconfdump(stdout);
570
- if (sync_kconfig) {
571
- name = conf_get_configname();
572
- if (stat(name, &tmpstat)) {
573
- fprintf(stderr, "***\n"
574
- "*** Configuration file \"%s\" not found!\n"
575
- "***\n"
576
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
577
- "*** \"make menuconfig\" or \"make xconfig\").\n"
578
- "***\n", name);
579
- exit(1);
580
- }
581
- }
582579
583580 switch (input_mode) {
584581 case defconfig:
585
- if (!defconfig_file)
586
- defconfig_file = conf_get_default_confname();
587582 if (conf_read(defconfig_file)) {
588583 fprintf(stderr,
589584 "***\n"
....@@ -598,7 +593,10 @@
598593 case oldaskconfig:
599594 case oldconfig:
600595 case listnewconfig:
596
+ case helpnewconfig:
601597 case olddefconfig:
598
+ case yes2modconfig:
599
+ case mod2yesconfig:
602600 conf_read(NULL);
603601 break;
604602 case allnoconfig:
....@@ -672,6 +670,12 @@
672670 break;
673671 case savedefconfig:
674672 break;
673
+ case yes2modconfig:
674
+ conf_rewrite_mod_or_yes(def_y2m);
675
+ break;
676
+ case mod2yesconfig:
677
+ conf_rewrite_mod_or_yes(def_m2y);
678
+ break;
675679 case oldaskconfig:
676680 rootEntry = &rootmenu;
677681 conf(&rootmenu);
....@@ -679,6 +683,7 @@
679683 /* fall through */
680684 case oldconfig:
681685 case listnewconfig:
686
+ case helpnewconfig:
682687 case syncconfig:
683688 /* Update until a loop caused no more changes */
684689 do {
....@@ -697,7 +702,7 @@
697702 defconfig_file);
698703 return 1;
699704 }
700
- } else if (input_mode != listnewconfig) {
705
+ } else if (input_mode != listnewconfig && input_mode != helpnewconfig) {
701706 if (!no_conf_write && conf_write(NULL)) {
702707 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
703708 exit(1);