linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] kconfig: misc cleanups
@ 2019-12-17  4:14 Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 1/8] kconfig: remove the rootmenu check in menu_add_prop() Masahiro Yamada
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel


Masahiro Yamada (8):
  kconfig: remove the rootmenu check in menu_add_prop()
  kconfig: use parent->dep as the parentdep of 'menu'
  kconfig: drop T_WORD from the RHS of 'prompt' symbol
  kconfig: remove 'prompt' symbol
  kconfig: move prompt handling to menu_add_prompt() from
    menu_add_prop()
  kconfig: remove 'prompt' argument from menu_add_prop()
  kconfig: remove sym from struct property
  kconfig: squash prop_alloc() into menu_add_prop()

 scripts/kconfig/expr.h   |   1 -
 scripts/kconfig/lkc.h    |   1 -
 scripts/kconfig/menu.c   | 103 ++++++++++++++++++++++-----------------
 scripts/kconfig/parser.y |  21 +++-----
 scripts/kconfig/symbol.c |  22 ---------
 5 files changed, 66 insertions(+), 82 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] kconfig: remove the rootmenu check in menu_add_prop()
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu' Masahiro Yamada
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

This reverts commit ba6ff60d5eb4 ("kconfig: don't emit warning upon
rootmenu's prompt redefinition").

At that time, rootmenu.prompt was always set first, then it was set
again if a "mainmenu" statement was specified in the Kconfig file.

This is no longer the case since commit 0724a7c32a54 ("kconfig: Don't
leak main menus during parsing"). Remove the unneeded check.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/menu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index d9d16469859a..b1b1ee8cf987 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -138,7 +138,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct
 			while (isspace(*prompt))
 				prompt++;
 		}
-		if (current_entry->prompt && current_entry != &rootmenu)
+		if (current_entry->prompt)
 			prop_warn(prop, "prompt redefined");
 
 		/* Apply all upper menus' visibilities to actual prompts. */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu'
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 1/8] kconfig: remove the rootmenu check in menu_add_prop() Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  5:55   ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 3/8] kconfig: drop T_WORD from the RHS of 'prompt' symbol Masahiro Yamada
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

In menu_finalize(), the dependency of a menu entry is propagated
downwards.

For the 'menu', ->dep and ->prompt->visible.expr are the same.
Both accumulate the 'depends on' of itself and upper menu entries.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/menu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index b1b1ee8cf987..bbabf0a59ac4 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -326,12 +326,10 @@ void menu_finalize(struct menu *parent)
 			 * choice value symbols.
 			 */
 			parentdep = expr_alloc_symbol(sym);
-		} else if (parent->prompt)
-			/* Menu node for 'menu' */
-			parentdep = parent->prompt->visible.expr;
-		else
-			/* Menu node for 'if' */
+		} else {
+			/* Menu node for 'menu', 'if' */
 			parentdep = parent->dep;
+		}
 
 		/* For each child menu node... */
 		for (menu = parent->list; menu; menu = menu->next) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] kconfig: drop T_WORD from the RHS of 'prompt' symbol
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 1/8] kconfig: remove the rootmenu check in menu_add_prop() Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu' Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 4/8] kconfig: remove " Masahiro Yamada
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

Commit 8636a1f9677d ("treewide: surround Kconfig file paths with double
quotes") killed use-cases to reduce an unquoted string into the 'prompt'
symbol.

Kconfig still allows to use an unquoted string in the context of menu,
source, or prompt.

So, you can omit quoting if the prompt is a single word:

    bool foo

..., but I do not think this is so useful.

Let's require quoting:

    bool "foo"

All the Kconfig files in the kernel are written in this way.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/parser.y | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 86e75ea74731..80585f04f590 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -445,9 +445,7 @@ prompt_stmt_opt:
 	menu_add_prompt(P_PROMPT, $1, $2);
 };
 
-prompt:	  T_WORD
-	| T_WORD_QUOTE
-;
+prompt:	  T_WORD_QUOTE
 
 end:	  T_ENDMENU T_EOL	{ $$ = "menu"; }
 	| T_ENDCHOICE T_EOL	{ $$ = "choice"; current_choice_menu = NULL; }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] kconfig: remove 'prompt' symbol
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
                   ` (2 preceding siblings ...)
  2019-12-17  4:14 ` [PATCH 3/8] kconfig: drop T_WORD from the RHS of 'prompt' symbol Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 5/8] kconfig: move prompt handling to menu_add_prompt() from menu_add_prop() Masahiro Yamada
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

Now that 'prompt' is only reduced from T_WORD_QUOTE without any action,
use T_WORD_QUOTE directly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/parser.y | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 80585f04f590..40e46996e6a5 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -93,7 +93,6 @@ static struct menu *current_choice_menu;
 %left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL
 %nonassoc T_NOT
 
-%type <string> prompt
 %type <symbol> nonconst_symbol
 %type <symbol> symbol
 %type <type> type logic_type default
@@ -116,7 +115,7 @@ input: mainmenu_stmt stmt_list | stmt_list;
 
 /* mainmenu entry */
 
-mainmenu_stmt: T_MAINMENU prompt T_EOL
+mainmenu_stmt: T_MAINMENU T_WORD_QUOTE T_EOL
 {
 	menu_add_prompt(P_MENU, $2, NULL);
 };
@@ -184,7 +183,7 @@ config_option: type prompt_stmt_opt T_EOL
 		$1);
 };
 
-config_option: T_PROMPT prompt if_expr T_EOL
+config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
 {
 	menu_add_prompt(P_PROMPT, $2, $3);
 	printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
@@ -276,7 +275,7 @@ choice_option_list:
 	| choice_option_list help
 ;
 
-choice_option: T_PROMPT prompt if_expr T_EOL
+choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
 {
 	menu_add_prompt(P_PROMPT, $2, $3);
 	printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
@@ -345,7 +344,7 @@ if_stmt: if_entry stmt_list if_end
 
 /* menu entry */
 
-menu: T_MENU prompt T_EOL
+menu: T_MENU T_WORD_QUOTE T_EOL
 {
 	menu_add_entry(NULL);
 	menu_add_prompt(P_MENU, $2, NULL);
@@ -374,7 +373,7 @@ menu_option_list:
 	| menu_option_list depends
 ;
 
-source_stmt: T_SOURCE prompt T_EOL
+source_stmt: T_SOURCE T_WORD_QUOTE T_EOL
 {
 	printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
 	zconf_nextfile($2);
@@ -383,7 +382,7 @@ source_stmt: T_SOURCE prompt T_EOL
 
 /* comment entry */
 
-comment: T_COMMENT prompt T_EOL
+comment: T_COMMENT T_WORD_QUOTE T_EOL
 {
 	menu_add_entry(NULL);
 	menu_add_prompt(P_COMMENT, $2, NULL);
@@ -440,13 +439,11 @@ visible: T_VISIBLE if_expr T_EOL
 
 prompt_stmt_opt:
 	  /* empty */
-	| prompt if_expr
+	| T_WORD_QUOTE if_expr
 {
 	menu_add_prompt(P_PROMPT, $1, $2);
 };
 
-prompt:	  T_WORD_QUOTE
-
 end:	  T_ENDMENU T_EOL	{ $$ = "menu"; }
 	| T_ENDCHOICE T_EOL	{ $$ = "choice"; current_choice_menu = NULL; }
 	| T_ENDIF T_EOL		{ $$ = "if"; }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] kconfig: move prompt handling to menu_add_prompt() from menu_add_prop()
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
                   ` (3 preceding siblings ...)
  2019-12-17  4:14 ` [PATCH 4/8] kconfig: remove " Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 6/8] kconfig: remove 'prompt' argument " Masahiro Yamada
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

menu_add_prompt() is the only function that calls menu_add_prop() with
non-NULL prompt.

So, the code inside the if-conditional block of menu_add_prop() can be
moved to menu_add_prompt().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/menu.c | 70 ++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 36 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index bbabf0a59ac4..45daece8d983 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -132,53 +132,51 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct
 	prop->expr = expr;
 	prop->visible.expr = dep;
 
-	if (prompt) {
-		if (isspace(*prompt)) {
-			prop_warn(prop, "leading whitespace ignored");
-			while (isspace(*prompt))
-				prompt++;
-		}
-		if (current_entry->prompt)
-			prop_warn(prop, "prompt redefined");
+	return prop;
+}
 
-		/* Apply all upper menus' visibilities to actual prompts. */
-		if(type == P_PROMPT) {
-			struct menu *menu = current_entry;
+struct property *menu_add_prompt(enum prop_type type, char *prompt,
+				 struct expr *dep)
+{
+	struct property *prop = menu_add_prop(type, prompt, NULL, dep);
 
-			while ((menu = menu->parent) != NULL) {
-				struct expr *dup_expr;
+	if (isspace(*prompt)) {
+		prop_warn(prop, "leading whitespace ignored");
+		while (isspace(*prompt))
+			prompt++;
+	}
+	if (current_entry->prompt)
+		prop_warn(prop, "prompt redefined");
 
-				if (!menu->visibility)
-					continue;
-				/*
-				 * Do not add a reference to the
-				 * menu's visibility expression but
-				 * use a copy of it.  Otherwise the
-				 * expression reduction functions
-				 * will modify expressions that have
-				 * multiple references which can
-				 * cause unwanted side effects.
-				 */
-				dup_expr = expr_copy(menu->visibility);
+	/* Apply all upper menus' visibilities to actual prompts. */
+	if (type == P_PROMPT) {
+		struct menu *menu = current_entry;
 
-				prop->visible.expr
-					= expr_alloc_and(prop->visible.expr,
-							 dup_expr);
-			}
-		}
+		while ((menu = menu->parent) != NULL) {
+			struct expr *dup_expr;
 
-		current_entry->prompt = prop;
+			if (!menu->visibility)
+				continue;
+			/*
+			 * Do not add a reference to the menu's visibility
+			 * expression but use a copy of it. Otherwise the
+			 * expression reduction functions will modify
+			 * expressions that have multiple references which
+			 * can cause unwanted side effects.
+			 */
+			dup_expr = expr_copy(menu->visibility);
+
+			prop->visible.expr = expr_alloc_and(prop->visible.expr,
+							    dup_expr);
+		}
 	}
+
+	current_entry->prompt = prop;
 	prop->text = prompt;
 
 	return prop;
 }
 
-struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
-{
-	return menu_add_prop(type, prompt, NULL, dep);
-}
-
 void menu_add_visibility(struct expr *expr)
 {
 	current_entry->visibility = expr_alloc_and(current_entry->visibility,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] kconfig: remove 'prompt' argument from menu_add_prop()
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
                   ` (4 preceding siblings ...)
  2019-12-17  4:14 ` [PATCH 5/8] kconfig: move prompt handling to menu_add_prompt() from menu_add_prop() Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 7/8] kconfig: remove sym from struct property Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 8/8] kconfig: squash prop_alloc() into menu_add_prop() Masahiro Yamada
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

This function does not use the 'prompt' argument.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/menu.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 45daece8d983..5a43784ded2c 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -124,7 +124,8 @@ void menu_set_type(int type)
 		sym_type_name(sym->type), sym_type_name(type));
 }
 
-static struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
+static struct property *menu_add_prop(enum prop_type type, struct expr *expr,
+				      struct expr *dep)
 {
 	struct property *prop = prop_alloc(type, current_entry->sym);
 
@@ -138,7 +139,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct
 struct property *menu_add_prompt(enum prop_type type, char *prompt,
 				 struct expr *dep)
 {
-	struct property *prop = menu_add_prop(type, prompt, NULL, dep);
+	struct property *prop = menu_add_prop(type, NULL, dep);
 
 	if (isspace(*prompt)) {
 		prop_warn(prop, "leading whitespace ignored");
@@ -185,12 +186,12 @@ void menu_add_visibility(struct expr *expr)
 
 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
 {
-	menu_add_prop(type, NULL, expr, dep);
+	menu_add_prop(type, expr, dep);
 }
 
 void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
 {
-	menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
+	menu_add_prop(type, expr_alloc_symbol(sym), dep);
 }
 
 void menu_add_option_modules(void)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] kconfig: remove sym from struct property
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
                   ` (5 preceding siblings ...)
  2019-12-17  4:14 ` [PATCH 6/8] kconfig: remove 'prompt' argument " Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  2019-12-17  4:14 ` [PATCH 8/8] kconfig: squash prop_alloc() into menu_add_prop() Masahiro Yamada
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

struct property can reference to the symbol that it is associated with
by prop->menu->sym.

Fix up the one usage of prop->sym, and remove sym from struct property.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/expr.h   | 1 -
 scripts/kconfig/parser.y | 2 +-
 scripts/kconfig/symbol.c | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 017843c9a4f4..6e102a3b8bd5 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -191,7 +191,6 @@ enum prop_type {
 
 struct property {
 	struct property *next;     /* next property - null if last */
-	struct symbol *sym;        /* the symbol for which the property is associated */
 	enum prop_type type;       /* type of property */
 	const char *text;          /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
 	struct expr_value visible;
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 40e46996e6a5..d5c41a5c370c 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -671,7 +671,7 @@ static void print_symbol(FILE *out, struct menu *menu)
 			break;
 		case P_SYMBOL:
 			fputs( "  symbol ", out);
-			fprintf(out, "%s\n", prop->sym->name);
+			fprintf(out, "%s\n", prop->menu->sym->name);
 			break;
 		default:
 			fprintf(out, "  unknown prop %d!\n", prop->type);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index f56eec5ea4c7..dbc5365d8bbc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1281,7 +1281,6 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
 	prop = xmalloc(sizeof(*prop));
 	memset(prop, 0, sizeof(*prop));
 	prop->type = type;
-	prop->sym = sym;
 	prop->file = current_file;
 	prop->lineno = zconf_lineno();
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] kconfig: squash prop_alloc() into menu_add_prop()
  2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
                   ` (6 preceding siblings ...)
  2019-12-17  4:14 ` [PATCH 7/8] kconfig: remove sym from struct property Masahiro Yamada
@ 2019-12-17  4:14 ` Masahiro Yamada
  7 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  4:14 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Ulf Magnusson, Masahiro Yamada, linux-kernel

prop_alloc() is only called from menu_add_prop(). Squash it.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/lkc.h    |  1 -
 scripts/kconfig/menu.c   | 18 +++++++++++++++++-
 scripts/kconfig/symbol.c | 21 ---------------------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 4fb16f316626..73d3f01f1736 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -112,7 +112,6 @@ struct symbol *sym_choice_default(struct symbol *sym);
 struct property *sym_get_range_prop(struct symbol *sym);
 const char *sym_get_string_default(struct symbol *sym);
 struct symbol *sym_check_deps(struct symbol *sym);
-struct property *prop_alloc(enum prop_type type, struct symbol *sym);
 struct symbol *prop_get_symbol(struct property *prop);
 
 static inline tristate sym_get_tristate_value(struct symbol *sym)
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 5a43784ded2c..8b772ced755d 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -127,12 +127,28 @@ void menu_set_type(int type)
 static struct property *menu_add_prop(enum prop_type type, struct expr *expr,
 				      struct expr *dep)
 {
-	struct property *prop = prop_alloc(type, current_entry->sym);
+	struct property *prop;
 
+	prop = xmalloc(sizeof(*prop));
+	memset(prop, 0, sizeof(*prop));
+	prop->type = type;
+	prop->file = current_file;
+	prop->lineno = zconf_lineno();
 	prop->menu = current_entry;
 	prop->expr = expr;
 	prop->visible.expr = dep;
 
+	/* append property to the prop list of symbol */
+	if (current_entry->sym) {
+		struct property **propp;
+
+		for (propp = &current_entry->sym->prop;
+		     *propp;
+		     propp = &(*propp)->next)
+			;
+		*propp = prop;
+	}
+
 	return prop;
 }
 
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index dbc5365d8bbc..8d38b700b314 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1273,27 +1273,6 @@ struct symbol *sym_check_deps(struct symbol *sym)
 	return sym2;
 }
 
-struct property *prop_alloc(enum prop_type type, struct symbol *sym)
-{
-	struct property *prop;
-	struct property **propp;
-
-	prop = xmalloc(sizeof(*prop));
-	memset(prop, 0, sizeof(*prop));
-	prop->type = type;
-	prop->file = current_file;
-	prop->lineno = zconf_lineno();
-
-	/* append property to the prop list of symbol */
-	if (sym) {
-		for (propp = &sym->prop; *propp; propp = &(*propp)->next)
-			;
-		*propp = prop;
-	}
-
-	return prop;
-}
-
 struct symbol *prop_get_symbol(struct property *prop)
 {
 	if (prop->expr && (prop->expr->type == E_SYMBOL ||
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu'
  2019-12-17  4:14 ` [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu' Masahiro Yamada
@ 2019-12-17  5:55   ` Masahiro Yamada
  0 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2019-12-17  5:55 UTC (permalink / raw)
  To: Linux Kbuild mailing list; +Cc: Ulf Magnusson, Linux Kernel Mailing List

On Tue, Dec 17, 2019 at 1:14 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> In menu_finalize(), the dependency of a menu entry is propagated
> downwards.
>
> For the 'menu', ->dep and ->prompt->visible.expr are the same.

Just for clarification, this means
parent->dep and parent->prompt->visible.expr
have the same expression.

expr_eq(parent->dep, parent->prompt->visible.expr)
should return 1.



> Both accumulate the 'depends on' of itself and upper menu entries.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/kconfig/menu.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
> index b1b1ee8cf987..bbabf0a59ac4 100644
> --- a/scripts/kconfig/menu.c
> +++ b/scripts/kconfig/menu.c
> @@ -326,12 +326,10 @@ void menu_finalize(struct menu *parent)
>                          * choice value symbols.
>                          */
>                         parentdep = expr_alloc_symbol(sym);
> -               } else if (parent->prompt)
> -                       /* Menu node for 'menu' */
> -                       parentdep = parent->prompt->visible.expr;
> -               else
> -                       /* Menu node for 'if' */
> +               } else {
> +                       /* Menu node for 'menu', 'if' */
>                         parentdep = parent->dep;
> +               }
>
>                 /* For each child menu node... */
>                 for (menu = parent->list; menu; menu = menu->next) {
> --
> 2.17.1
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-17  5:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17  4:14 [PATCH 0/8] kconfig: misc cleanups Masahiro Yamada
2019-12-17  4:14 ` [PATCH 1/8] kconfig: remove the rootmenu check in menu_add_prop() Masahiro Yamada
2019-12-17  4:14 ` [PATCH 2/8] kconfig: use parent->dep as the parentdep of 'menu' Masahiro Yamada
2019-12-17  5:55   ` Masahiro Yamada
2019-12-17  4:14 ` [PATCH 3/8] kconfig: drop T_WORD from the RHS of 'prompt' symbol Masahiro Yamada
2019-12-17  4:14 ` [PATCH 4/8] kconfig: remove " Masahiro Yamada
2019-12-17  4:14 ` [PATCH 5/8] kconfig: move prompt handling to menu_add_prompt() from menu_add_prop() Masahiro Yamada
2019-12-17  4:14 ` [PATCH 6/8] kconfig: remove 'prompt' argument " Masahiro Yamada
2019-12-17  4:14 ` [PATCH 7/8] kconfig: remove sym from struct property Masahiro Yamada
2019-12-17  4:14 ` [PATCH 8/8] kconfig: squash prop_alloc() into menu_add_prop() Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).