From patchwork Sun Mar 3 04:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13579643 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 824007F; Sun, 3 Mar 2024 04:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438440; cv=none; b=pv1I3dQhlv80NrEBqqiBWjDR273PecfH0fqAxET8gBp0/Su6k4FlvAd1hJjUyZ3kWnPiCtYMU5KAogh0BoCs5fqu0uQ4IMoDJGKCpJip7SguylhH3prMYL5S5iee44o7vEYaB864oNeh12bsKR75GF9yhtTTfkbm0WKGwoHXu5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438440; c=relaxed/simple; bh=Mxd0x4K9NZGsIbjj7+JyTXQS+jqX7z7/GCh2qtsgiqY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=udCM0OeR4eI45p32Mw62yQWR4kM+gf3I1DJjqIOJuZKnf998fiQpAHuBYQB1Vf9eTsgZ44DexeTOo2sMOi/wZbWyAMjH93QF7WGa8NBE7u+VExd3PCiCsBZALQ/CtTEi0vFu4IPo8f7ET4KtN/qL0EFz6aZz6GOSx0DZwWa3ugU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I6/WB8v0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I6/WB8v0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BB65C433F1; Sun, 3 Mar 2024 04:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709438440; bh=Mxd0x4K9NZGsIbjj7+JyTXQS+jqX7z7/GCh2qtsgiqY=; h=From:To:Cc:Subject:Date:From; b=I6/WB8v0xtfAoZ9fO/YJHz0CBTagIz671gnhuLv+pRQSDnvsYOIxdAjZ+RdzKvGpB x/RXj0TYkydoeb1QXSIiPLUnSV8og78DVG6DyWtmP46FrMao3tq3J4iLKsF4BTCF7Z AaruHtJujblerzweEmzLJ3qKv211MKvELXbvr30TrU0H0Fqkg4PC8snPHu8clIvJws GoIWv5B9S6tiqMgiRHU/acj6TecEijtegH3EUe5xaUL2zQWQxojnfThIUEMbLnEPmW VShbeYPr5HvJAslQJJZbU8QZBuX9XLrqkkwwrGSX60vFcSu0dt5mmyT4RlSbtLGVaQ 1mX0uNlNEd0eQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 1/3] kconfig: link menus to a symbol Date: Sun, 3 Mar 2024 13:00:33 +0900 Message-Id: <20240303040035.3450914-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, there is no direct link from (struct symbol *) to (struct menu *). It is still possible to access associated menus through the P_SYMBOL property, because property::menu is the relevant menu entry, but it results in complex code, as seen in get_symbol_str(). Use a linked list for simpler traversal of relevant menus. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/kconfig/expr.h | 5 +++++ scripts/kconfig/menu.c | 4 +++- scripts/kconfig/symbol.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 3bc375f1a1cd..0158f5eac454 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -108,6 +108,9 @@ struct symbol { */ tristate visible; + /* config entries associated with this symbol */ + struct list_head menus; + /* SYMBOL_* flags */ int flags; @@ -222,6 +225,8 @@ struct menu { */ struct symbol *sym; + struct list_head link; /* link to symbol::menus */ + /* * The prompt associated with the node. This holds the prompt for a * symbol as well as the text for a menu or comment, along with the diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 44465945d6b1..571394ed71e0 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -57,8 +57,10 @@ void menu_add_entry(struct symbol *sym) *last_entry_ptr = menu; last_entry_ptr = &menu->next; current_entry = menu; - if (sym) + if (sym) { menu_add_symbol(P_SYMBOL, sym, NULL); + list_add_tail(&menu->link, &sym->menus); + } } struct menu *menu_add_menu(void) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index dd5cf9727a9a..81fe1884ef8a 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -15,18 +15,21 @@ struct symbol symbol_yes = { .name = "y", .curr = { "y", yes }, + .menus = LIST_HEAD_INIT(symbol_yes.menus), .flags = SYMBOL_CONST|SYMBOL_VALID, }; struct symbol symbol_mod = { .name = "m", .curr = { "m", mod }, + .menus = LIST_HEAD_INIT(symbol_mod.menus), .flags = SYMBOL_CONST|SYMBOL_VALID, }; struct symbol symbol_no = { .name = "n", .curr = { "n", no }, + .menus = LIST_HEAD_INIT(symbol_no.menus), .flags = SYMBOL_CONST|SYMBOL_VALID, }; @@ -838,6 +841,7 @@ struct symbol *sym_lookup(const char *name, int flags) symbol->name = new_name; symbol->type = S_UNKNOWN; symbol->flags = flags; + INIT_LIST_HEAD(&symbol->menus); hash_add(sym_hashtable, &symbol->node, hash); From patchwork Sun Mar 3 04:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13579644 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0776E6FD0; Sun, 3 Mar 2024 04:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438442; cv=none; b=G5lT7wY7OCdqo0pBWopFqqtoSTbqmhL814HSfsbI3gmnBs0kDbvhP9o1bDNw09b4lD0M32pS/b4tUsvjShFkFYNB7Q9cQfQuQ9YS8jaajO2y1Hg/KPtrv4jPFdb5cmPAvcx9gqUNpxPHWEtitBkTZR6QlV3aAuURnlfvyaog+kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438442; c=relaxed/simple; bh=lXxv7xJWAlJqvQFRnp9M3lrdj0gJLvlnbtl717FZbxs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ws9+yfcHdEN4gCl8QSiONwaqWLZaqzmzeOGoPMn4sXBMxB3idnBnIVQRqVqReSIPWwFiAqtqxTiPSTSHFLMM1MTZm0r4926hIjLdDs6yxYGxpJwrnXLA392enZbrZ7MPqp/FIriIwB6JB/2JMQxdNaooZXr2ufVplylzsUfDdlo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dh6b+igi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dh6b+igi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95DA0C43390; Sun, 3 Mar 2024 04:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709438441; bh=lXxv7xJWAlJqvQFRnp9M3lrdj0gJLvlnbtl717FZbxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dh6b+igiB4aTOI/O9SivESZbD0SWWk1mtZ1L2TB6N2TI3XDc4hANH0sF17JsujD1E ZtIeIHk2Xf7zSdIMu2BJwVgLXoFn9XrrykXk7Tt4PNGUqvW1Xngj7AvPnuQ+3EJ60S +CbH1k11Sr2fWB8GQHaNHGN+UVbbMeShUlD3aXsSn1gZbhxQ+kCqhhbVnx4VgVYvGe GlhxWnr1pKQLxu4iil7fr146GTyHRviQPtRmuRzafuE0alNRjIQLtW/UnM/E2KSG+i vtMmttld9BZBSouwO9Pf/zx/JP4XK1JG2g/iMLNIJ4VF/Pzc2c1TNv2WxLNg8lLVrX NPp/uMJwCrkEg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/3] kconfig: use linked list in get_symbol_str() to iterate over menus Date: Sun, 3 Mar 2024 13:00:34 +0900 Message-Id: <20240303040035.3450914-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240303040035.3450914-1-masahiroy@kernel.org> References: <20240303040035.3450914-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, get_symbol_str() uses a tricky approach to traverse the associated menus. With relevant menus now linked to the symbol using a linked list, use list_for_each_entry() for iterating on the menus. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/kconfig/menu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 571394ed71e0..840ce642ec43 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -771,6 +771,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, struct list_head *head) { struct property *prop; + struct menu *menu; if (sym && sym->name) { str_printf(r, "Symbol: %s [=%s]\n", sym->name, @@ -787,17 +788,17 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, } /* Print the definitions with prompts before the ones without */ - for_all_properties(sym, prop, P_SYMBOL) { - if (prop->menu->prompt) { - get_def_str(r, prop->menu); - get_prompt_str(r, prop->menu->prompt, head); + list_for_each_entry(menu, &sym->menus, link) { + if (menu->prompt) { + get_def_str(r, menu); + get_prompt_str(r, menu->prompt, head); } } - for_all_properties(sym, prop, P_SYMBOL) { - if (!prop->menu->prompt) { - get_def_str(r, prop->menu); - get_dep_str(r, prop->menu->dep, " Depends on: "); + list_for_each_entry(menu, &sym->menus, link) { + if (!menu->prompt) { + get_def_str(r, menu); + get_dep_str(r, menu->dep, " Depends on: "); } } From patchwork Sun Mar 3 04:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13579645 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E56CE945A; Sun, 3 Mar 2024 04:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438444; cv=none; b=lBOZIhfGsRyuN/RDVYl2IXk5HP0fX8SrRaG69kgolecjuaevVEmohLRBo0lRp4zdEpLHOLDiQAF9YJs3KlNWWfUQ803lpGFb4pXs6J0QHonrK8gSPWY75T+/mJ6PqESU+kKyJNTNADNieDbqzOolbLyDgVm1EAIFrSCedMYQnLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709438444; c=relaxed/simple; bh=b61Pfq2+8r8OGJHhDhI5Mm5KHha8WJXnv9P4YukQfBI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=suq4dTgks5DkwrsJG0I5taTlDDdqn9YBoFmgyH/McMKf590T1J/Pz2Hq8qZWnY6TpnCvLXE7tTCEybIRTQgfV2nf3wB6dCr/Jp+V+SVA42UXoqlHB8jY+nBn80HCvHSfOHlqi6Ns69/uYCqAaE+kJ2S6sH/rrJ6ngrY2odQyRiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MLbbt3NZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MLbbt3NZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B9FEC433C7; Sun, 3 Mar 2024 04:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709438443; bh=b61Pfq2+8r8OGJHhDhI5Mm5KHha8WJXnv9P4YukQfBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLbbt3NZn0xrsQuW9NCvbKNKiSeesbi6x6G29LqmLs3fYnPcVm7MeeqbvRau/8PG3 FwmfASUsLjng7lF3Fkjctm2zv9ZxrWz0v22602HMBVOhdmNtKpFfseGvkR0cxti8bK RPJhTsci3ncZ2rDYkW9bKDRCewOWaHQxCHrmMLfNk9nxgxd/9ZsspeMzlT1axf5NgP Gnqs5OFFGwLQe2pi1hrAgCS8nWR1gu7/mXxE5Puxw38GVX9h3AbyKtWH8MX7qPO9Tu McpIzOkvHW9c+YYNd4jg65rXTrzHxZx5ehM48GDVJIxMCL9fFzTNxK/EK3dYi4xGOv 5ba1zvvnbJDrA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Jonathan Corbet , Nathan Chancellor , Nicolas Schier , linux-doc@vger.kernel.org Subject: [PATCH 3/3] kconfig: remove named choice support Date: Sun, 3 Mar 2024 13:00:35 +0900 Message-Id: <20240303040035.3450914-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240303040035.3450914-1-masahiroy@kernel.org> References: <20240303040035.3450914-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 5a1aa8a1aff6 ("kconfig: add named choice group") did not provide enough explanation. A use case was found in another project [1], but this has never been used in the kernel. [1]: https://lore.kernel.org/all/201012150034.01356.yann.morin.1998@anciens.enib.fr/ Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Documentation/kbuild/kconfig-language.rst | 6 +----- scripts/kconfig/parser.y | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index 0135905c0aa3..79ac2e8184f6 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -393,7 +393,7 @@ of C0, which doesn't depend on M:: choices:: - "choice" [symbol] + "choice" "endchoice" @@ -412,10 +412,6 @@ the kernel, but all drivers can be compiled as modules. A choice accepts another option "optional", which allows to set the choice to 'n' and no entry needs to be selected. -If no [symbol] is associated with a choice, then you can not have multiple -definitions of that choice. If a [symbol] is associated to the choice, -then you may define the same choice (i.e. with the same entries) in another -place. comment:: diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index b505e43e0d02..22f616334585 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -94,7 +94,7 @@ struct menu *current_menu, *current_entry; %type if_expr %type end %type if_entry menu_entry choice_entry -%type word_opt assign_val +%type assign_val %type assign_op %destructor { @@ -222,13 +222,12 @@ config_option: T_MODULES T_EOL /* choice entry */ -choice: T_CHOICE word_opt T_EOL +choice: T_CHOICE T_EOL { - struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); + struct symbol *sym = sym_lookup(NULL, SYMBOL_CHOICE); sym->flags |= SYMBOL_NO_WRITE; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); - free($2); printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno); }; @@ -449,9 +448,6 @@ symbol: nonconst_symbol | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } ; -word_opt: /* empty */ { $$ = NULL; } - | T_WORD - /* assignment statement */ assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }