Add module_name Kconfig shortcut
Subsystems (3)
PATCH 1/1 Add module_name Kconfig shortcut
As correctly noticed in bug 11446 (http://bugzilla.kernel.org/show_bug.cgi?id=11446)
"To compile this driver as a module, blah-blah" boilerplate is being copy-pasted to death with slight variations.
Add Kconfig token "module_name" to supply module's name. Example:
config FOO tristate "foo" module_name foo ---help--- foo
Print module's name as following on menuconfigs help screen (press 'h'):
Module name: foo
8139too driver converted to show real-life example.
P.S.: menuconfig only, no checking wrt modular/standalone code et al.
---
drivers/net/Kconfig | 4 scripts/kconfig/expr.h | 4 scripts/kconfig/lkc.h | 1 scripts/kconfig/mconf.c | 2 scripts/kconfig/menu.c | 8 scripts/kconfig/symbol.c | 2 scripts/kconfig/zconf.gperf | 1 scripts/kconfig/zconf.hash.c_shipped | 184 ++++++----- scripts/kconfig/zconf.tab.c_shipped | 539 ++++++++++++++++++----------------- scripts/kconfig/zconf.y | 12 10 files changed, 404 insertions(+), 353 deletions(-)
drivers/net/Kconfig +1 -3
@@ -1549,14 +1549,12 @@ config 8139TOO depends on NET_PCI && PCI select CRC32 select MII + module_name 8139too ---help--- This is a driver for the Fast Ethernet PCI network cards based on the RTL 8129/8130/8139 chips. If you have one of those, say Y and read the Ethernet-HOWTO <http://www.tldp.org/docs.html#howto>. - To compile this driver as a module, choose M here: the module - will be called 8139too. This is recommended. - config 8139TOO_PIO bool "Use PIO instead of MMIO" default y
scripts/kconfig/expr.h +3 -1
@@ -107,7 +107,8 @@ struct symbol {enum prop_type {P_UNKNOWN ,P_PROMPT ,P_COMMENT ,P_MENU ,P_DEFAULT ,P_CHOICE , -P_SELECT ,P_RANGE ,P_ENV +P_SELECT ,P_RANGE ,P_ENV , +P_MODULE_NAME , };struct property {
@@ -115,6 +116,7 @@ struct property {struct symbol *sym;enum prop_type type;const char *text; +char *module_name;struct expr_value visible;struct expr *expr;struct menu *menu;
scripts/kconfig/lkc.h +1 -0
@@ -95,6 +95,7 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct exprvoid menu_add_expr (enum prop_type type,struct expr *expr,struct expr *dep);void menu_add_symbol (enum prop_type type,struct symbol *sym,struct expr *dep);void menu_add_option (int token,char *arg); +void menu_add_module_name (char *module_name);void menu_finalize (struct menu *parent);void menu_set_type (int type);
scripts/kconfig/mconf.c +2 -0
@@ -320,6 +320,8 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym)bool hit;struct property *prop; + for_all_properties(sym, prop, P_MODULE_NAME) +str_printf (r,_ ("Module name: %s\n\n" ), prop->module_name);if (sym && sym->name)str_printf (r,"Symbol: %s [=%s]\n" , sym->name,sym_get_string_value (sym));
scripts/kconfig/menu.c +8 -0
@@ -178,6 +178,14 @@ void menu_add_option(int token, char *arg) } } +void menu_add_module_name (char *module_name) +{ +struct property *prop; + + prop =prop_alloc (P_MODULE_NAME , current_entry->sym); + prop->module_name =strdup (module_name); +} +static int menu_range_valid_sym (struct symbol *sym,struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX ||
scripts/kconfig/symbol.c +2 -0
@@ -937,6 +937,8 @@ const char *prop_get_type_name(enum prop_type type)return "select" ;case P_RANGE :return "range" ; +case P_MODULE_NAME : +return "module_name" ;case P_UNKNOWN :break ; }
scripts/kconfig/zconf.gperf +1 -0
@@ -41,4 +41,5 @@ on, T_ON, TF_PARAM modules, T_OPT_MODULES, TF_OPTION defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION env, T_OPT_ENV, TF_OPTION +module_name, T_MODULE_NAME, TF_COMMAND %%
scripts/kconfig/zconf.hash.c_shipped +95 -89
259 lines not on this page · raw message
scripts/kconfig/zconf.tab.c_shipped +279 -260
873 lines not on this page · raw message
scripts/kconfig/zconf.y +12 -0
@@ -72,6 +72,7 @@ static struct menu *current_menu, *current_entry; %token <id>T_RANGE %token <id>T_OPTION %token <id>T_ON +%token <id>T_MODULE_NAME %token <string> T_WORD %token <string> T_WORD_QUOTE %token T_UNEQUAL
@@ -90,6 +91,7 @@ static struct menu *current_menu, *current_entry; %type <expr> if_expr %type <id> end %type <id> option_name +%type <string> module_name %type <menu> if_entry menu_entry choice_entry %type <string> symbol_option_arg word_opt
@@ -217,6 +219,12 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; +config_option: T_MODULE_NAME module_name T_EOL +{ + menu_add_module_name($2); + printd(DEBUG_PARSE, "%s:%d:module_name\n", zconf_curname(), zconf_lineno()); +}; + symbol_option: T_OPTION symbol_option_list T_EOL ;
@@ -461,6 +469,10 @@ symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } word_opt: /* empty */ { $$ = NULL; } | T_WORD +; + +module_name: T_WORD { $$ = $1 } +; %%
Quoted 12 lines · Alexey Dobriyan
As correctly noticed in bug 11446 (http://bugzilla.kernel.org/show_bug.cgi?id=11446)
"To compile this driver as a module, blah-blah" boilerplate is being copy-pasted to death with slight variations.Add
Kconfigtoken "module_name" to supply module's name. Example:config FOO tristate "foo" module_name foo ---help--- foo
Quoted 7 lines
Print module's name as following on menuconfigs help screen (press 'h'):
Module name: foo
8139too driver converted to show real-life example.
P.S.: menuconfig only, no checking wrt modular/standalone code et al.
Hi Alexey.
This is a baby step towards moving simple module stuff to Kconfig. This is the way we want to go when someone cooks up proper support for that.
But we should do it in one go so when someone decide to visit the 8139too driver then they can do a full conversion to the "keep all module definition in Kconfig" in one step.
Please see a few mails from Roman Zippel outlining his ideas. I do not recall the details but I do recall that he suggested to name the source files in Kconfig.
And when we do it we shall at least support it in menuconfig and xconfig. config and gconfig can come later.
config and gconfig shall at least generate a correct config but may not show all relavent info.
Sam