From patchwork Tue Jun 11 17:55:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694078 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 63F1F5C8EF; Tue, 11 Jun 2024 17:56:02 +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=1718128562; cv=none; b=FIp2IbSymY1bGzh82wkpN4BOuI20UkZcteI8B1U6onsr1BpGQ62oEwdX2cZUsT3OnrK3+vGIpc0pN+R+JZQBa0vFnjiH+xk6x1FcEq/DCvd5QpK85WiOBZUDvoO/TWGiS++8YApfXV825dELYwNqWGcYKwjuDDVHvC4bhtCTwPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128562; c=relaxed/simple; bh=GAF8ysZjcl8Pyp7JrwXDuhYLpidrAnZjl20cqs4nMoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Az9SL8c5MWdNoTHn4HwrvZ/9SHvcQsfLkogkNXeLeY1sReHxlSQb9H3CJ2yGAfN4uMYS0zlofErm+9aWGJRqQNbwEmoR8Pjm/xit4NkXMLj+P42ziDUr89nk8a//h293PkPzMD9vyEhocE0FASz32a6LV0g4YjQlkb0rprTupLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WvWR6h5c; 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="WvWR6h5c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33A73C4AF1C; Tue, 11 Jun 2024 17:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128561; bh=GAF8ysZjcl8Pyp7JrwXDuhYLpidrAnZjl20cqs4nMoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WvWR6h5cbXcaWPrB7UY3qFLDFMuo2WYZX7F/rJpMr3UuM0ruagWgaEGxqbXBjzCBV npl6OZpe5q+SB2LgNQPqHacP+BSNUcM3mVrKp1GmfSYL6UzZarn84YOvzCZyV+LjGK u1twpscq54KcDqS3kPQS6rkACV2JTxxes746ivY28gDPCokxcQXvnoKi99K4+qbRy7 gmUD1etk8cFv1TinNQCq8hf+VVsIq6BJxPvhCOlPfJYgPBwSSjJRG5A/kMTRy4tdc3 GwSif/BU17sfDi7Xfobn+/j2hFX9pVSpj6xY67oWfeUXR+7q08LGEzT0MGQ80e+41z PWFuUE1lbPJxQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 01/16] kconfig: remove unneeded code in expr_compare_type() Date: Wed, 12 Jun 2024 02:55:10 +0900 Message-ID: <20240611175536.3518179-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The condition (t2 == 0) never becomes true because the zero value (i.e., E_NONE) is only used as a dummy type for prevtoken. It can be passed to t1, but not to t2. The caller of this function only checks expr_compare_type() > 0. Therefore, the distinction between 0 and -1 is unnecessary. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index fcc190b67b6f..31737b2cb8e2 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1096,11 +1096,8 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) case E_OR: if (t2 == E_LIST) return 1; - case E_LIST: - if (t2 == 0) - return 1; default: - return -1; + break; } return 0; } From patchwork Tue Jun 11 17:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694079 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 3C1F26BFD5; Tue, 11 Jun 2024 17:56:03 +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=1718128563; cv=none; b=erYmBmavanIvnDjKp6ALxTtJVAKvqkQvXr9Kmse0TM9vbj++Agmpd6+yr8yagw+pG05Ikms0fQuerk6d2uzyqZPyCH5iDBYr6UgySPclOBGvVzk12VgPpenITtLDbsS8SnM2Z/B+Hn+sLsnDVz9GpcFvP5zG1Z2Exy6Ll7zHgak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128563; c=relaxed/simple; bh=Il2IBkyPBNx4lEb9nfcAhP52gScXtLIKtiTPj1sRzy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jab7CgMxdHBLEGSisEwufDMqQ1MxwM+FS+s03y2qIftDRNyJWvpUrOf5kQoFe4K+g79uXQK4JDrxZIRd2BP93++PErkOEnqakVTS6uwVI7SHsM1DE21lZrznhzWlt2fwwlciwBSCbargi1ZAJxok+SxpzKKuh51kwpcjFtU2m0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pksLM9/2; 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="pksLM9/2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6166AC32786; Tue, 11 Jun 2024 17:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128563; bh=Il2IBkyPBNx4lEb9nfcAhP52gScXtLIKtiTPj1sRzy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pksLM9/2wl6MgTyi+GkZPXyHQpUzbQTo3iHzZEn07BE4Gm6vWPfD8sAOPBmd09GJp hs3id94yKPxzhEds9gJZLgjc5J0RStTLNTRNsMBzJDWzsIR5Cz4h5x6MMK3OyX/r/o E85wOn+xVQXfvYRFHJRrFzaQ0MSuINOchkuH4h/Nz4+/bzQtn7dbyWmteCT23OedXf vqXtihOI5/S3WyhuaXxXQa19WU6ryhVxZbeLFL8+HA9XpAYrQ8HVzjyYTD+K8i6uSP wcuCrP1Jl0KhTASznEX166Sg2fhBYuL7+rs/f0PlqW7oBwKBCNkpuHci0GXhVlLX+X Ma7Xx/NMCSkCw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 02/16] kconfig: add fallthrough comments to expr_compare_type() Date: Wed, 12 Jun 2024 02:55:11 +0900 Message-ID: <20240611175536.3518179-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Clarify the missing 'break' is intentional. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 31737b2cb8e2..bea82d5cac83 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1083,19 +1083,24 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) case E_GTH: if (t2 == E_EQUAL || t2 == E_UNEQUAL) return 1; + /* fallthrough */ case E_EQUAL: case E_UNEQUAL: if (t2 == E_NOT) return 1; + /* fallthrough */ case E_NOT: if (t2 == E_AND) return 1; + /* fallthrough */ case E_AND: if (t2 == E_OR) return 1; + /* fallthrough */ case E_OR: if (t2 == E_LIST) return 1; + /* fallthrough */ default: break; } From patchwork Tue Jun 11 17:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694080 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 896E874079; Tue, 11 Jun 2024 17:56:04 +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=1718128564; cv=none; b=n5ERZT0L7Mgp20/dSwwjOlWLTTMc1QG4bYFlLXXwvUel+0mTjpRSArl+i1MrVHRu545eurMWqdRReqXN+U5HJlDI/CzVB3xgIQEauZGozExkShxf+sX3ydxRDYODgBLfjoi0yNgjnG0thgh1sChi3yvlPDYBr7EQYAJGUTsorQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128564; c=relaxed/simple; bh=yfQDTv6MlSf5SMz6cU5RG7DZF8B3ediOPWStjd9jKHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qXXXN8hrOvEinsxi9XZvFW3s2nLVORs5UAIDgDCYlMjmhx1CzUAbTBm8cRFcE2dnsMawTtEPLVvBa29ijpnMc2z/UoHibJdzUAMgNz7O2HBPHHmzmsUPNog5IJfjGDpAaoxl+u2a7V0s+gfS1v+Yt+BFULNPqc9muGj/pG0dSIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MJHBlzd7; 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="MJHBlzd7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86090C32786; Tue, 11 Jun 2024 17:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128564; bh=yfQDTv6MlSf5SMz6cU5RG7DZF8B3ediOPWStjd9jKHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJHBlzd7GRDkeW5TrONfyrguc5P8LYHCa6QgXmjxaYh/JugFGq3yOej4lhEcbQTDm vBTa5IoDNXxjfgXYe5uUgobqoi8FRd37MsHJMTGIoAFBpxD9jUsFiXKMZ0LlYt/bPO FPETvjVVjyT1dQ2huwmUG6L0jh3rqU1wHtbTUURd6NoJnlrdjz232aZjIk6EcyeP// 7uUr6hUQkZ1gS4IshsLmAkMemWZ/iqOQSVkuk0a+nR76Qu1TAlSY91dV05JXr7ru7N rLvj1x5fCzeXEbLcbraVGDf1CUPUupNpcGKA5mkQkcV5qBqbrxcTzEEoH4HdHTl0BQ wjQOaWAOh9LGg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 03/16] kconfig: introduce choice_set_value() helper Date: Wed, 12 Jun 2024 02:55:12 +0900 Message-ID: <20240611175536.3518179-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-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, sym_set_tristate_value() is used to set 'y' to a choice member, which is confusing because it not only sets 'y' to the given symbol but also tweaks flags of other symbols as a side effect. Add a dedicated function for setting the value of the given choice. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 2 +- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/mconf.c | 2 +- scripts/kconfig/nconf.c | 2 +- scripts/kconfig/symbol.c | 62 +++++++++++++++++++++++++------------ 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index cf8193fc00fc..5dbdd9459f21 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -507,7 +507,7 @@ static void conf_choice(struct menu *menu) print_help(child); continue; } - sym_set_tristate_value(child->sym, yes); + choice_set_value(menu, child->sym); return; } } diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index c663fd8b35d2..1221709efac1 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -28,6 +28,7 @@ bool sym_dep_errors(void); enum symbol_type sym_get_type(struct symbol *sym); bool sym_tristate_within_range(struct symbol *sym,tristate tri); bool sym_set_tristate_value(struct symbol *sym,tristate tri); +void choice_set_value(struct menu *choice, struct symbol *sym); tristate sym_toggle_tristate_value(struct symbol *sym); bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_within_range(struct symbol *sym, const char *str); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index e6227af51658..03709eb734ae 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -636,7 +636,7 @@ static void conf_choice(struct menu *menu) if (!child->sym) break; - sym_set_tristate_value(child->sym, yes); + choice_set_value(menu, child->sym); } return; case 1: diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index addc89ee61d4..eb5fc3ccaf9d 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1331,7 +1331,7 @@ static void conf_choice(struct menu *menu) case ' ': case 10: case KEY_RIGHT: - sym_set_tristate_value(child->sym, yes); + choice_set_value(menu, child->sym); return; case 'h': case '?': diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index eaff7ac496bd..8df0a75f40b9 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -516,8 +516,6 @@ bool sym_tristate_within_range(struct symbol *sym, tristate val) return false; if (sym->visible <= sym->rev_dep.tri) return false; - if (sym_is_choice_value(sym) && sym->visible == yes) - return val == yes; return val >= sym->rev_dep.tri && val <= sym->visible; } @@ -532,23 +530,6 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) sym->flags |= SYMBOL_DEF_USER; sym_set_changed(sym); } - /* - * setting a choice value also resets the new flag of the choice - * symbol and all other choice values. - */ - if (sym_is_choice_value(sym) && val == yes) { - struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); - struct property *prop; - struct expr *e; - - cs->def[S_DEF_USER].val = sym; - cs->flags |= SYMBOL_DEF_USER; - prop = sym_get_choice_prop(cs); - for (e = prop->expr; e; e = e->left.expr) { - if (e->right.sym->visible != no) - e->right.sym->flags |= SYMBOL_DEF_USER; - } - } sym->def[S_DEF_USER].tri = val; if (oldval != val) @@ -557,10 +538,53 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) return true; } +/** + * choice_set_value - set the user input to a choice + * + * @choice: menu entry for the choice + * @sym: selected symbol + */ +void choice_set_value(struct menu *choice, struct symbol *sym) +{ + struct menu *menu; + bool changed = false; + + menu_for_each_sub_entry(menu, choice) { + tristate val; + + if (!menu->sym) + continue; + + if (menu->sym->visible == no) + continue; + + val = menu->sym == sym ? yes : no; + + if (menu->sym->curr.tri != val) + changed = true; + + menu->sym->def[S_DEF_USER].tri = val; + menu->sym->flags |= SYMBOL_DEF_USER; + } + + choice->sym->def[S_DEF_USER].val = sym; + choice->sym->flags |= SYMBOL_DEF_USER; + + if (changed) + sym_clear_all_valid(); +} + tristate sym_toggle_tristate_value(struct symbol *sym) { + struct menu *choice; tristate oldval, newval; + choice = sym_get_choice_menu(sym); + if (choice) { + choice_set_value(choice, sym); + return yes; + } + oldval = newval = sym_get_tristate_value(sym); do { switch (newval) { From patchwork Tue Jun 11 17:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694081 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 D1102762C9; Tue, 11 Jun 2024 17:56:05 +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=1718128565; cv=none; b=m/tZUe2KHIykmyWV2/eQyiQOXtRKRNsyNiWkbP1lmBI6b0LZ1Ew97wAV4AynsQkHsn1ar6Kt21Mv0mSjEniKXaxywJMzhL4AD96o+sROhnpdXJoD4JlwC61VxIy+CCUXzYAcSzkmMm7Ec30L8y0Zg3Y0tYMx93vg4suQQeKHa4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128565; c=relaxed/simple; bh=GdpFQ2McrR/oLioUGmh3pnwOEGIEtoCNFgyLhOS3wZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i7ZsHx7m8Ai6QASVyfW1cV5vvPJ+uMkugucbKrcQrGv2gDadlD5v/TNDADF+8jhFkGyGPHGkCiZsLBl9d6rZJnvkCFp7n4gVY1nv4kKPQzkgnZD5Ymc4kjOI4WxLjjv2YdHbQWCEUqNNn/POoBVcJzZjQ1Jx3wSfvQyIMigQVt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gJwFIeFU; 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="gJwFIeFU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB052C2BD10; Tue, 11 Jun 2024 17:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128565; bh=GdpFQ2McrR/oLioUGmh3pnwOEGIEtoCNFgyLhOS3wZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gJwFIeFU1wi9wP5Ac6HoVINEy7rT73wDzM0Ig/EV+9dDQxsHi8caPtpkyzuZeBRd1 ZOP3oNZnBerwz7L2omev4PkxllCWNrtj93yKFwi5uX7iQwmyvXT69GbEaOdrJPToO4 W9cXfRnNDrT9HVFYIqkocek/g7mGPANigbX8rwUhxs2H7pnUygwaz3+vLVQYAxjWrZ ELw2Z59ph8XLm4G7HSZbB6H2IRY/mtr4KLPk5FWMihKoQ/D6gQAXOuw/xIbHbbZwHG 3WLAkul6HCr2X51PQJTX34fY01lto3z3zFqDZ5oEK2zYe/kaaRQ6Un534GLXUtv58H +Q3tMKkT1k18A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 04/16] kconfig: remember the current choice while parsing the choice block Date: Wed, 12 Jun 2024 02:55:13 +0900 Message-ID: <20240611175536.3518179-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of the boolean flag, it will be more useful to remember the current choice being parsed. Signed-off-by: Masahiro Yamada --- scripts/kconfig/parser.y | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 8adb2f70121e..20538e1d3788 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -28,9 +28,7 @@ static void zconf_error(const char *err, ...); static bool zconf_endtoken(const char *tokenname, const char *expected_tokenname); -struct menu *current_menu, *current_entry; - -static bool inside_choice = false; +struct menu *current_menu, *current_entry, *current_choice; %} @@ -147,7 +145,7 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL config_stmt: config_entry_start config_option_list { - if (inside_choice) { + if (current_choice) { if (!current_entry->prompt) { fprintf(stderr, "%s:%d: error: choice member must have a prompt\n", current_entry->filename, current_entry->lineno); @@ -256,12 +254,12 @@ choice_entry: choice choice_option_list $$ = menu_add_menu(); - inside_choice = true; + current_choice = current_entry; }; choice_end: end { - inside_choice = false; + current_choice = NULL; if (zconf_endtoken($1, "choice")) { menu_end_menu(); From patchwork Tue Jun 11 17:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694082 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 A345378C79; Tue, 11 Jun 2024 17:56:06 +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=1718128566; cv=none; b=FL/JBtpVR/EosJigh0DOwLmkPRdQZPb7dHPiIZ/E9uv8vTz5/MnNkCEfOxr8LTaehgz7mz09sgYXwDbBWoYxgjM/jN3XJU7tUtKZJ2ar823GdRykaZitFzhd3lOQl/Q1Vj/uImgTx+1kUOxS1sYKwSrjM9I1fDt9mS5xABmuBiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128566; c=relaxed/simple; bh=qcBiO8SNAAfZtzQky9fVy54pHt8w/K87uRJ98NXalMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HxkAI8eyybnvYGYeudjTEMRmxPtoNNIKXq2En3jx7/n9Fq3ec/FkNVcVOLWKW3RlnRLfLGBH+ufP4/MQZRooA7zwhVDYRVDjgJ/kYtJfAHjNupabq6zvlaEcrSYz7Y7XhJDdAsjDVBaHgGQc9/nBJiY0+ANZPCPcCQ6qDsMA5Mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eCZ9YV+6; 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="eCZ9YV+6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFBBAC4AF49; Tue, 11 Jun 2024 17:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128566; bh=qcBiO8SNAAfZtzQky9fVy54pHt8w/K87uRJ98NXalMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCZ9YV+6vzdNEbWMyFBCo5Nm3G/q9xWLYSSS2LhhR55+FkesjxOmlmKiFPa/cC5AT mC8PJn2mdJXba5LRSwoMhJJRPIFPk2Jj7hLCe/gl4Tg1XZ16dcPeo5RFKnAbMXPv9n nJXSApDGUvK+peCbOALN1/YvhRFaUgm2wLFzODuilKjW0T4AYOLl6tIvuONXGYFzVW aZeAWyv95tJ3Gl/Q56sT8nbtTfCPS0scdv50mrulYXzIXYmhr/AVeyC3rrvkmPoBIN PIoyPJ0zJkWBVVLr2AeJ9sa4Rnl8vgAzET+Ez4hVmB1DlkxeHJf9x2VAOz/P7Gvglt caZxLIfNNUvzg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 05/16] kconfig: import list_move() and list_move_tail() Date: Wed, 12 Jun 2024 02:55:14 +0900 Message-ID: <20240611175536.3518179-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Import list_move() and list_move_tail() from include/linux/list.h. These will be used in the next commit. Signed-off-by: Masahiro Yamada --- scripts/kconfig/list.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h index 882859ddf9f4..7008243f48a8 100644 --- a/scripts/kconfig/list.h +++ b/scripts/kconfig/list.h @@ -127,6 +127,29 @@ static inline void list_del(struct list_head *entry) entry->prev = LIST_POISON2; } +/** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ +static inline void list_move(struct list_head *list, struct list_head *head) +{ + __list_del_entry(list); + list_add(list, head); +} + +/** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ +static inline void list_move_tail(struct list_head *list, + struct list_head *head) +{ + __list_del_entry(list); + list_add_tail(list, head); +} + /** * list_is_head - tests whether @list is the list @head * @list: the entry to test From patchwork Tue Jun 11 17:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694083 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 1DB8B74079; Tue, 11 Jun 2024 17:56:07 +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=1718128568; cv=none; b=fngyft65cVCnauaDcxH9RYDfs/G5JSA95jqjRGKThMYXXmKnUYSoBch99RX7hwJu9X8uaGibg8mwvvDczduGAkg4rYd/qjL0Vr3fz7EXx3PstHeRudnoUP1enMw/ynu1DLdoxKoAAU0wFtVV5AR/3hOm+Zu+UyoetDIX9hMb3So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128568; c=relaxed/simple; bh=zrTBUnF4HfSxUYrDoB9vKX6e+xSiccO/5kgVgT45GPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AJgHba2NQvZgl6i5MmmiBYSW/VfJicBCa2bkm8BFyQtJAa4l1nN8PPnjlhGpj9khYivocdBIEAT4W2Z4m6wWQoU1rawmeFmyXtx3hw3AR71hx1cwboLWmZP3ETJ1QclA8xiLahIJLqsAK9e2xexqhP9Az2JV+cby0n3SoaEGNII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YFvRCEjc; 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="YFvRCEjc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEBE3C4AF1C; Tue, 11 Jun 2024 17:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128567; bh=zrTBUnF4HfSxUYrDoB9vKX6e+xSiccO/5kgVgT45GPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YFvRCEjcmRvL0WbERtTBOMalKSNCNdZ2PWPg0KIWIO/0K+n7sXeXP7zFO35Y3TkpV ZFynYwVM8HGAlaZJj6RAKXFS2AiJv6rhAPxkS2LvKYp6kTYeIItCIFq+LSfOpqJ4wB R0JNry3YUg7wUHWXJUpalqbL3HEIQ1ST9/xXPfXEhhBsmxshb3IIP2SyEIaT9ZTOex 2J65ZTxRNc0khQ0qlngF1fToCaBpwQvNJvn88u9nBfjK3bu9OyBKxgftEr5RugWuFb XyNdJh/giGk7Iuy2U7SEVm331GV4PuqIHtyBEBZ50SUbiXDEUCi4urLdN16f9Otb7v wmCN+rlz06T7Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 06/16] kconfig: refactor choice value calculation Date: Wed, 12 Jun 2024 02:55:15 +0900 Message-ID: <20240611175536.3518179-7-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Handling choices has always been in a PITA in Kconfig. For example, fixes and reverts were repeated for randconfig with KCONFIG_ALLCONFIG: - 422c809f03f0 ("kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG") - 23a5dfdad22a ("Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"") - 8357b48549e1 ("kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG") - 490f16171119 ("Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"") As these commits pointed out, randconfig does not randomize choices when KCONFIG_ALLCONFIG is used. This issue still remains. [Test Case] choice prompt "choose" config A bool "A" config B bool "B" endchoice $ echo > all.config $ make KCONFIG_ALLCONFIG=1 randconfig The output is always as follows: CONFIG_A=y # CONFIG_B is not set Not only randconfig, but other all*config variants are broken with KCONFIG_ALLCONFIG. With the same Kconfig, $ echo '# CONFIG_A is not set' > all.config $ make KCONFIG_ALLCONFIG=1 allyesconfig You will get this: CONFIG_A=y # CONFIG_B is not set This is incorrect because it does not respect all.config. The correct output should be: # CONFIG_A is not set CONFIG_B=y To handle user inputs more accurately, this commit refactors the code based on the following principles: - When a user value is given, Kconfig must set it immediately. Do not defer it by setting SYMBOL_NEED_SET_CHOICE_VALUES. - The SYMBOL_DEF_USER flag must not be cleared, unless a new config file is loaded. Kconfig must not forget user inputs. In addition, user values for choices must be managed with priority. If user inputs conflict within a choice block, the newest value wins. The values given by randconfig have lower priority than explicit user inputs. This commit implements it by using a linked list. Every time a choice block gets a new input, it is moved to the top of the list. Let me explain how it works. Let's say, we have a choice block that consists of three symbols: A, B, and C. Initially, the linked list looks like this: A(=?) --> B(=?) --> C(=?) Say, '# CONFIG_B is not set' is specified by KCONFIG_ALLCONFIG. B is set to 'n', and moved to the top of the linked list: B(=n) --> A(=?) --> C(=?) The randconfig shuffles the symbols without a user value. So, you will get: B(=n) --> A(=y) --> C(=y) or B(=n) --> C(=y) --> A(=y) When calculating the output, the linked list is traversed. The first visible symbol with =y is taken. You will get either CONFIG_A=y or CONFIG_C=y with equal probability. As another example, let's say the .config with the following content is loaded: CONFIG_B=y CONFIG_C=y The linked list will become: C(=y) --> B(=y) --> A(=?) Please note the last one is prioritized when a decision conflicts in the same file. This is reasonable behavior because merge_config.sh appends config fragments to the existing .config file. So, the output will be CONFIG_C=y if C is visible, but otherwise CONFIG_B=y. This is different from the former implementation; previously, Kconfig forgot CONFIG_B=y when CONFIG_C=y appeared later in the same file. In the new implementation, Kconfig remembers both CONFIG_B=y and CONFIG_C=y, prioritizing the former. If C is hidden due to unmet dependency, CONFIG_B=y arises as the second best. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 131 +++++++++++++++----------------- scripts/kconfig/confdata.c | 54 +++----------- scripts/kconfig/expr.h | 12 ++- scripts/kconfig/lkc.h | 7 +- scripts/kconfig/menu.c | 17 +---- scripts/kconfig/parser.y | 4 + scripts/kconfig/symbol.c | 149 ++++++++++++++++++++++--------------- 7 files changed, 177 insertions(+), 197 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 5dbdd9459f21..1c59998a62f7 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -114,41 +114,54 @@ static void set_randconfig_seed(void) srand(seed); } -static void randomize_choice_values(struct symbol *csym) +/** + * randomize_choice_values - randomize choice block + * + * @choice: menu entry for the choice + */ +static void randomize_choice_values(struct menu *choice) { - struct property *prop; - struct symbol *sym; - struct expr *e; - int cnt, def; - - prop = sym_get_choice_prop(csym); - - /* count entries in choice block */ - cnt = 0; - expr_list_for_each_sym(prop->expr, e, sym) - cnt++; + struct menu *menu; + int x; + int cnt = 0; /* - * find a random value and set it to yes, - * set the rest to no so we have only one set + * First, count the number of symbols to randomize. If sym_has_value() + * is true, it was specified by KCONFIG_ALLCONFIG. It needs to be + * respected. */ - def = rand() % cnt; + menu_for_each_sub_entry(menu, choice) { + struct symbol *sym = menu->sym; - cnt = 0; - expr_list_for_each_sym(prop->expr, e, sym) { - if (def == cnt++) { - sym->def[S_DEF_USER].tri = yes; - csym->def[S_DEF_USER].val = sym; - } else { - sym->def[S_DEF_USER].tri = no; - } - sym->flags |= SYMBOL_DEF_USER; - /* clear VALID to get value calculated */ - sym->flags &= ~SYMBOL_VALID; + if (sym && !sym_has_value(sym)) + cnt++; + } + + while (cnt > 0) { + x = rand() % cnt; + + menu_for_each_sub_entry(menu, choice) { + struct symbol *sym = menu->sym; + + if (sym && !sym_has_value(sym)) + x--; + + if (x < 0) { + sym->def[S_DEF_USER].tri = yes; + sym->flags |= SYMBOL_DEF_USER; + /* + * Move the selected item to the _tail_ because + * this needs to have a lower priority than the + * user input from KCONFIG_ALLCONFIG. + */ + list_move_tail(&sym->choice_link, + &choice->choice_members); + + break; + } + } + cnt--; } - csym->flags |= SYMBOL_DEF_USER; - /* clear VALID to get value calculated */ - csym->flags &= ~SYMBOL_VALID; } enum conf_def_mode { @@ -159,9 +172,9 @@ enum conf_def_mode { def_random }; -static bool conf_set_all_new_symbols(enum conf_def_mode mode) +static void conf_set_all_new_symbols(enum conf_def_mode mode) { - struct symbol *sym, *csym; + struct menu *menu; int cnt; /* * can't go as the default in switch-case below, otherwise gcc whines @@ -170,7 +183,6 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) int pby = 50; /* probability of bool = y */ int pty = 33; /* probability of tristate = y */ int ptm = 33; /* probability of tristate = m */ - bool has_changed = false; if (mode == def_random) { int n, p[3]; @@ -217,14 +229,21 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) } } - for_all_symbols(sym) { + menu_for_each_entry(menu) { + struct symbol *sym = menu->sym; tristate val; - if (sym_has_value(sym) || sym->flags & SYMBOL_VALID || - (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)) + if (!sym || !menu->prompt || sym_has_value(sym) || + (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) || + sym_is_choice_value(sym)) continue; - has_changed = true; + if (sym_is_choice(sym)) { + if (mode == def_random) + randomize_choice_values(menu); + continue; + } + switch (mode) { case def_yes: val = yes; @@ -251,34 +270,10 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode) continue; } sym->def[S_DEF_USER].tri = val; - - if (!(sym_is_choice(sym) && mode == def_random)) - sym->flags |= SYMBOL_DEF_USER; + sym->flags |= SYMBOL_DEF_USER; } sym_clear_all_valid(); - - if (mode != def_random) { - for_all_symbols(csym) { - if ((sym_is_choice(csym) && !sym_has_value(csym)) || - sym_is_choice_value(csym)) - csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; - } - } - - for_all_symbols(csym) { - if (sym_has_value(csym) || !sym_is_choice(csym)) - continue; - - sym_calc_value(csym); - if (mode == def_random) - randomize_choice_values(csym); - else - set_all_choice_values(csym); - has_changed = true; - } - - return has_changed; } static void conf_rewrite_tristates(tristate old_val, tristate new_val) @@ -429,10 +424,9 @@ static void conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; - bool is_new; + bool is_new = false; sym = menu->sym; - is_new = !sym_has_value(sym); while (1) { int cnt, def; @@ -456,8 +450,10 @@ static void conf_choice(struct menu *menu) printf("%*c", indent, ' '); printf(" %d. %s (%s)", cnt, menu_get_prompt(child), child->sym->name); - if (!sym_has_value(child->sym)) + if (!sym_has_value(child->sym)) { + is_new = true; printf(" (NEW)"); + } printf("\n"); } printf("%*schoice", indent - 1, ""); @@ -586,9 +582,7 @@ static void check_conf(struct menu *menu) return; sym = menu->sym; - if (sym && !sym_has_value(sym) && - (sym_is_changeable(sym) || sym_is_choice(sym))) { - + if (sym && !sym_has_value(sym) && sym_is_changeable(sym)) { switch (input_mode) { case listnewconfig: if (sym->name) @@ -804,8 +798,7 @@ int main(int ac, char **av) conf_set_all_new_symbols(def_default); break; case randconfig: - /* Really nothing to do in this loop */ - while (conf_set_all_new_symbols(def_random)) ; + conf_set_all_new_symbols(def_random); break; case defconfig: conf_set_all_new_symbols(def_default); diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 1ac7fc9ad756..05823f85402a 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -382,10 +382,7 @@ int conf_read_simple(const char *name, int def) def_flags = SYMBOL_DEF << def; for_all_symbols(sym) { - sym->flags |= SYMBOL_CHANGED; sym->flags &= ~(def_flags|SYMBOL_VALID); - if (sym_is_choice(sym)) - sym->flags |= def_flags; switch (sym->type) { case S_INT: case S_HEX: @@ -399,6 +396,8 @@ int conf_read_simple(const char *name, int def) } while (getline_stripped(&line, &line_asize, in) != -1) { + struct menu *choice; + conf_lineno++; if (!line[0]) /* blank line */ @@ -460,15 +459,14 @@ int conf_read_simple(const char *name, int def) if (conf_set_sym_val(sym, def, def_flags, val)) continue; - if (sym && sym_is_choice_value(sym)) { - struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); - if (sym->def[def].tri == yes) { - if (cs->def[def].tri != no) - conf_warning("override: %s changes choice state", sym->name); - cs->def[def].val = sym; - cs->def[def].tri = yes; - } - } + /* + * If this is a choice member, give it the highest priority. + * If conflicting CONFIG options are given from an input file, + * the last one wins. + */ + choice = sym_get_choice_menu(sym); + if (choice) + list_move(&sym->choice_link, &choice->choice_members); } free(line); fclose(in); @@ -514,18 +512,6 @@ int conf_read(const char *name) /* maybe print value in verbose mode... */ } - for_all_symbols(sym) { - if (sym_has_value(sym) && !sym_is_choice_value(sym)) { - /* Reset values of generates values, so they'll appear - * as new, if they should become visible, but that - * doesn't quite work if the Kconfig and the saved - * configuration disagree. - */ - if (sym->visible == no && !conf_unsaved) - sym->flags &= ~SYMBOL_DEF_USER; - } - } - if (conf_warnings || conf_unsaved) conf_set_changed(true); @@ -1146,23 +1132,3 @@ void conf_set_changed_callback(void (*fn)(bool)) { conf_changed_callback = fn; } - -void set_all_choice_values(struct symbol *csym) -{ - struct property *prop; - struct symbol *sym; - struct expr *e; - - prop = sym_get_choice_prop(csym); - - /* - * Set all non-assinged choice values to no - */ - expr_list_for_each_sym(prop->expr, e, sym) { - if (!sym_has_value(sym)) - sym->def[S_DEF_USER].tri = no; - } - csym->flags |= SYMBOL_DEF_USER; - /* clear VALID to get value calculated */ - csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES); -} diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 7c0c242318bc..7acf27a4f454 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -73,6 +73,8 @@ enum { * Represents a configuration symbol. * * Choices are represented as a special kind of symbol with null name. + * + * @choice_link: linked to menu::choice_members */ struct symbol { /* link node for the hash table */ @@ -110,6 +112,8 @@ struct symbol { /* config entries associated with this symbol */ struct list_head menus; + struct list_head choice_link; + /* SYMBOL_* flags */ int flags; @@ -133,7 +137,6 @@ struct symbol { #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ -#define SYMBOL_CHANGED 0x0400 /* ? */ #define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ @@ -145,9 +148,6 @@ struct symbol { #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ -/* choice values need to be set before calculating this symbol value */ -#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 - #define SYMBOL_MAXLENGTH 256 /* A property represent the config options that can be associated @@ -204,6 +204,8 @@ struct property { * for all front ends). Each symbol, menu, etc. defined in the Kconfig files * gets a node. A symbol defined in multiple locations gets one node at each * location. + * + * @choice_members: list of choice members with priority. */ struct menu { /* The next menu node at the same level */ @@ -223,6 +225,8 @@ struct menu { struct list_head link; /* link to symbol::menus */ + struct list_head choice_members; + /* * 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/lkc.h b/scripts/kconfig/lkc.h index 64dfc354dd5c..bdd37a16b040 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -40,7 +40,6 @@ void zconf_nextfile(const char *name); /* confdata.c */ extern struct gstr autoconf_cmd; const char *conf_get_configname(void); -void set_all_choice_values(struct symbol *csym); /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) @@ -121,11 +120,7 @@ static inline tristate sym_get_tristate_value(struct symbol *sym) return sym->curr.tri; } - -static inline struct symbol *sym_get_choice_value(struct symbol *sym) -{ - return (struct symbol *)sym->curr.val; -} +struct symbol *sym_get_choice_value(struct symbol *sym); static inline bool sym_is_choice(struct symbol *sym) { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index bf5dcc05350b..170a269a8d7c 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -591,7 +591,6 @@ bool menu_is_empty(struct menu *menu) bool menu_is_visible(struct menu *menu) { - struct menu *child; struct symbol *sym; tristate visible; @@ -610,21 +609,7 @@ bool menu_is_visible(struct menu *menu) } else visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr); - if (visible != no) - return true; - - if (!sym || sym_get_tristate_value(menu->sym) == no) - return false; - - for (child = menu->list; child; child = child->next) { - if (menu_is_visible(child)) { - if (sym) - sym->flags |= SYMBOL_DEF_USER; - return true; - } - } - - return false; + return visible != no; } const char *menu_get_prompt(struct menu *menu) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 20538e1d3788..9d58544b0255 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -157,6 +157,9 @@ config_stmt: config_entry_start config_option_list current_entry->filename, current_entry->lineno); yynerrs++; } + + list_add_tail(¤t_entry->sym->choice_link, + ¤t_choice->choice_members); } printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); @@ -240,6 +243,7 @@ choice: T_CHOICE T_EOL menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); menu_set_type(S_BOOLEAN); + INIT_LIST_HEAD(¤t_entry->choice_members); printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno); }; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 8df0a75f40b9..e59f2d2ce4e6 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -188,7 +188,6 @@ static void sym_set_changed(struct symbol *sym) { struct menu *menu; - sym->flags |= SYMBOL_CHANGED; list_for_each_entry(menu, &sym->menus, link) menu->flags |= MENU_CHANGED; } @@ -282,36 +281,90 @@ struct symbol *sym_choice_default(struct symbol *sym) return NULL; } -static struct symbol *sym_calc_choice(struct symbol *sym) +/* + * sym_calc_choice - calculate symbol values in a choice + * + * @choice: a menu of the choice + * + * Return: a chosen symbol + */ +static struct symbol *sym_calc_choice(struct menu *choice) { - struct symbol *def_sym; - struct property *prop; - struct expr *e; - int flags; + struct symbol *res = NULL; + struct symbol *sym; + struct menu *menu; - /* first calculate all choice values' visibilities */ - flags = sym->flags; - prop = sym_get_choice_prop(sym); - expr_list_for_each_sym(prop->expr, e, def_sym) { - sym_calc_visibility(def_sym); - if (def_sym->visible != no) - flags &= def_sym->flags; + /* Traverse the list of choice members in the priority order. */ + list_for_each_entry(sym, &choice->choice_members, choice_link) { + sym_calc_visibility(sym); + if (sym->visible == no) + continue; + + /* The first visible symble with the user value 'y'. */ + if (sym_has_value(sym) && sym->def[S_DEF_USER].tri == yes) { + res = sym; + break; + } } - sym->flags &= flags | ~SYMBOL_DEF_USER; + /* If 'y' is not found in the user input, try the default */ + if (!res) { + res = sym_choice_default(choice->sym); + if (res && sym_has_value(res) && res->def[S_DEF_USER].tri == no) + res = NULL; + } - /* is the user choice visible? */ - def_sym = sym->def[S_DEF_USER].val; - if (def_sym && def_sym->visible != no) - return def_sym; + /* Still not found. Pick up the first visible, user-unspecified symbol. */ + if (!res) { + menu_for_each_sub_entry(menu, choice) { + sym = menu->sym; - def_sym = sym_choice_default(sym); + if (!sym || sym->visible == no || sym_has_value(sym)) + continue; - if (def_sym == NULL) - /* no choice? reset tristate value */ - sym->curr.tri = no; + res = sym; + break; + } + } - return def_sym; + /* Still not found. Pick up the first visible symbol. */ + if (!res) { + menu_for_each_sub_entry(menu, choice) { + sym = menu->sym; + + if (!sym || sym->visible == no) + continue; + + res = sym; + break; + } + } + + menu_for_each_sub_entry(menu, choice) { + tristate val; + + sym = menu->sym; + + if (!sym || sym->visible == no) + continue; + + val = sym == res ? yes : no; + + if (sym->curr.tri != val) + sym_set_changed(sym); + + sym->curr.tri = val; + sym->flags |= SYMBOL_VALID | SYMBOL_WRITE; + } + + return res; +} + +struct symbol *sym_get_choice_value(struct symbol *sym) +{ + struct menu *menu = list_first_entry(&sym->menus, struct menu, link); + + return sym_calc_choice(menu); } static void sym_warn_unmet_dep(struct symbol *sym) @@ -347,7 +400,6 @@ void sym_calc_value(struct symbol *sym) { struct symbol_value newval, oldval; struct property *prop; - struct expr *e; if (!sym) return; @@ -355,13 +407,6 @@ void sym_calc_value(struct symbol *sym) if (sym->flags & SYMBOL_VALID) return; - if (sym_is_choice_value(sym) && - sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) { - sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES; - prop = sym_get_choice_prop(sym); - sym_calc_value(prop_get_symbol(prop)); - } - sym->flags |= SYMBOL_VALID; oldval = sym->curr; @@ -400,9 +445,11 @@ void sym_calc_value(struct symbol *sym) switch (sym_get_type(sym)) { case S_BOOLEAN: case S_TRISTATE: - if (sym_is_choice_value(sym) && sym->visible == yes) { - prop = sym_get_choice_prop(sym); - newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; + struct menu *choice_menu = sym_get_choice_menu(sym); + + if (choice_menu) { + sym_calc_choice(choice_menu); + newval.tri = sym->curr.tri; } else { if (sym->visible != no) { /* if the symbol is visible use the user value @@ -461,8 +508,6 @@ void sym_calc_value(struct symbol *sym) } sym->curr = newval; - if (sym_is_choice(sym) && newval.tri == yes) - sym->curr.val = sym_calc_choice(sym); sym_validate_range(sym); if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { @@ -473,23 +518,8 @@ void sym_calc_value(struct symbol *sym) } } - if (sym_is_choice(sym)) { - struct symbol *choice_sym; - - prop = sym_get_choice_prop(sym); - expr_list_for_each_sym(prop->expr, e, choice_sym) { - if ((sym->flags & SYMBOL_WRITE) && - choice_sym->visible != no) - choice_sym->flags |= SYMBOL_WRITE; - if (sym->flags & SYMBOL_CHANGED) - sym_set_changed(choice_sym); - } - + if (sym_is_choice(sym)) sym->flags &= ~SYMBOL_WRITE; - } - - if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) - set_all_choice_values(sym); } void sym_clear_all_valid(void) @@ -523,15 +553,15 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) { tristate oldval = sym_get_tristate_value(sym); - if (oldval != val && !sym_tristate_within_range(sym, val)) + if (!sym_tristate_within_range(sym, val)) return false; - if (!(sym->flags & SYMBOL_DEF_USER)) { + if (!(sym->flags & SYMBOL_DEF_USER) || sym->def[S_DEF_USER].tri != val) { + sym->def[S_DEF_USER].tri = val; sym->flags |= SYMBOL_DEF_USER; sym_set_changed(sym); } - sym->def[S_DEF_USER].tri = val; if (oldval != val) sym_clear_all_valid(); @@ -565,10 +595,13 @@ void choice_set_value(struct menu *choice, struct symbol *sym) menu->sym->def[S_DEF_USER].tri = val; menu->sym->flags |= SYMBOL_DEF_USER; - } - choice->sym->def[S_DEF_USER].val = sym; - choice->sym->flags |= SYMBOL_DEF_USER; + /* + * Now, the user has explicitly enabled or disabled this symbol, + * it should be given the highest priority + */ + list_move(&menu->sym->choice_link, &choice->choice_members); + } if (changed) sym_clear_all_valid(); From patchwork Tue Jun 11 17:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694084 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 2AD2D80607; Tue, 11 Jun 2024 17:56:08 +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=1718128569; cv=none; b=JiXf0Zhl49hvtBPTAnQZXFXTaEmldw/9+EjzJrMTSnwB7VU7La3d6iGaSuN8vhETc5EF0XrO6+wz6QuFa6qgD6k4z727hhIeCyNBmhL6NCl/rs1i0dEYPTNdwGkqpf9D+yPUOccGTmWST9oZCax7N+R+4hnqsZTr9n1ArR2UHOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128569; c=relaxed/simple; bh=SqoXWXIq3NVYSHdK3EzSYWYwGR6/kM2HqUcSteYpPys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DWO0snW0s+IC4nc+pA3/dQaG3mUzN2ewdhou5ZX1JxjsZsPCfGz4U2jwdeL+0/xMNoqnbFFChnFBRohu3Q7jygjmO8dyShhvEodjIahmLrQobThofauq0w4EPrnwS2+kyita7NgLp4eAh1eNVD+l0OtxdH3lx33dgtdrXpLVCW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eyYKPjoX; 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="eyYKPjoX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BAA0C4AF48; Tue, 11 Jun 2024 17:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128568; bh=SqoXWXIq3NVYSHdK3EzSYWYwGR6/kM2HqUcSteYpPys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eyYKPjoXfYapr6xq/o7PfPg3munTJZnbFpb+GW2jOZ1fOAd2hy3tOoGzwi8MMA2uL laf1lBT/PfE3We6bFTxZJPyE9TNJ4ShdWcSC5P0GLFmpt3CNv7adI3ycxXVjTJ4Ro7 dFiZR317qGKol4fyg9kQSAoLU/bRIriUf37WATXXcD24JCtWGnmtWMRbORLp2hlqnX y8I5AJ2quKbYt8T0eKucrPIHv387Es4aoNlcCv3DyPdBZWjIRUOnrJ+iUUR4C9ZzvT culzoMLkm+CLadotH0KY2zFosBuk/y/IOXV8cjxbf1RXoj6Wjv7P8kCrvEVhT5kv+w eDiP1S5hnBx3g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 07/16] kconfig: remove sym_get_choice_value() Date: Wed, 12 Jun 2024 02:55:16 +0900 Message-ID: <20240611175536.3518179-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 sym_get_choice_value(menu->sym) is equivalent to sym_calc_choice(menu). Convert all call sites of sym_get_choice_value() and then remove it. Signed-off-by: Masahiro Yamada --- scripts/kconfig/conf.c | 6 ++---- scripts/kconfig/gconf.c | 2 +- scripts/kconfig/lkc.h | 3 +-- scripts/kconfig/mconf.c | 6 +++--- scripts/kconfig/nconf.c | 6 +++--- scripts/kconfig/symbol.c | 9 +-------- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 1c59998a62f7..3d7d454c54da 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -422,17 +422,15 @@ static int conf_sym(struct menu *menu) static void conf_choice(struct menu *menu) { - struct symbol *sym, *def_sym; + struct symbol *def_sym; struct menu *child; bool is_new = false; - sym = menu->sym; - while (1) { int cnt, def; printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); - def_sym = sym_get_choice_value(sym); + def_sym = sym_calc_choice(menu); cnt = def = 0; line[0] = 0; for (child = menu->list; child; child = child->next) { diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 380421a5cfb2..6b50e25133e3 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1054,7 +1054,7 @@ static gchar **fill_row(struct menu *menu) if (sym_is_choice(sym)) { // parse childs for getting final value struct menu *child; - struct symbol *def_sym = sym_get_choice_value(sym); + struct symbol *def_sym = sym_calc_choice(menu); struct menu *def_menu = NULL; for (child = menu->list; child; child = child->next) { diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index bdd37a16b040..d820272a85fb 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -110,6 +110,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help); /* symbol.c */ void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); +struct symbol *sym_calc_choice(struct menu *choice); 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); @@ -120,8 +121,6 @@ static inline tristate sym_get_tristate_value(struct symbol *sym) return sym->curr.tri; } -struct symbol *sym_get_choice_value(struct symbol *sym); - static inline bool sym_is_choice(struct symbol *sym) { /* A choice is a symbol with no name */ diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 03709eb734ae..4a0a97bb342f 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -514,7 +514,7 @@ static void build_conf(struct menu *menu) type = sym_get_type(sym); if (sym_is_choice(sym)) { - struct symbol *def_sym = sym_get_choice_value(sym); + struct symbol *def_sym = sym_calc_choice(menu); struct menu *def_menu = NULL; child_count++; @@ -600,7 +600,7 @@ static void conf_choice(struct menu *menu) struct menu *child; struct symbol *active; - active = sym_get_choice_value(menu->sym); + active = sym_calc_choice(menu); while (1) { int res; int selected; @@ -619,7 +619,7 @@ static void conf_choice(struct menu *menu) item_set_data(child); if (child->sym == active) item_set_selected(1); - if (child->sym == sym_get_choice_value(menu->sym)) + if (child->sym == sym_calc_choice(menu)) item_set_tag('X'); } dialog_clear(); diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index eb5fc3ccaf9d..1456e24969aa 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -815,7 +815,7 @@ static void build_conf(struct menu *menu) type = sym_get_type(sym); if (sym_is_choice(sym)) { - struct symbol *def_sym = sym_get_choice_value(sym); + struct symbol *def_sym = sym_calc_choice(menu); struct menu *def_menu = NULL; child_count++; @@ -1239,7 +1239,7 @@ static void conf_choice(struct menu *menu) .pattern = "", }; - active = sym_get_choice_value(menu->sym); + active = sym_calc_choice(menu); /* this is mostly duplicated from the conf() function. */ while (!global_exit) { reset_menu(); @@ -1248,7 +1248,7 @@ static void conf_choice(struct menu *menu) if (!show_all_items && !menu_is_visible(child)) continue; - if (child->sym == sym_get_choice_value(menu->sym)) + if (child->sym == sym_calc_choice(menu)) item_make(child, ':', " %s", menu_get_prompt(child)); else if (child->sym) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index e59f2d2ce4e6..b2fdae15f367 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -288,7 +288,7 @@ struct symbol *sym_choice_default(struct symbol *sym) * * Return: a chosen symbol */ -static struct symbol *sym_calc_choice(struct menu *choice) +struct symbol *sym_calc_choice(struct menu *choice) { struct symbol *res = NULL; struct symbol *sym; @@ -360,13 +360,6 @@ static struct symbol *sym_calc_choice(struct menu *choice) return res; } -struct symbol *sym_get_choice_value(struct symbol *sym) -{ - struct menu *menu = list_first_entry(&sym->menus, struct menu, link); - - return sym_calc_choice(menu); -} - static void sym_warn_unmet_dep(struct symbol *sym) { struct gstr gs = str_new(); From patchwork Tue Jun 11 17:55:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694085 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 C2A665B05E; Tue, 11 Jun 2024 17:56:10 +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=1718128570; cv=none; b=tJkuv4L4jqaNGFTjLFNRORZzZFsa5QWwpsEWSnoUpUGMuxVlgw/mhbW8ycr9s4ubVUKY+4CjQhhJ/9m5sW4J2OjM/YsHyZA4VfnYNmPEuFn+oOVmRZH4Vlba+tehdSd9f06Q8Jtb+2GIr9GsmaiaSh0YHA4AvFkHdXBDPa60dtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128570; c=relaxed/simple; bh=x/4XpM89xtG/46/uay0k335CF5phqgQe+6ZvVRKmCB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D+M5/XX3P8N+fIQYlBm2gU11bM+GxawKQb0lG0cm3u1yWFige9oZRx3G91IbdXX8ORAeBc0ht57gnGACpoJLP6Pry+LgYCZfZ/MJu6M46i7bDBvZMyxc1YRgJgGxRkGwFht/pAdR3uQSyC9lmZeef6GCnGZHtIYb6sxZT/G94dY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pUPQyBZu; 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="pUPQyBZu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 354D5C4AF49; Tue, 11 Jun 2024 17:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128570; bh=x/4XpM89xtG/46/uay0k335CF5phqgQe+6ZvVRKmCB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pUPQyBZulwbY6e6Bj/i35pKNC/7GqbAJQSPYIruXB48bAfrDMlgjGT7EU3v4jydoS 9SoBtqFoJ4qcZd/FfABXCMcVy2gAX5o4PISyZEovalay+w9/NJRAw8MaNyon5XuujD G7BB3IIL7sij60t1X8FSonFz5VYS9ClOwon+zuNZNtPHCa8oIH16Id7111D3SqX/RF SfRDiXjCfOxm30pehlEyyVWUEe8LKv04h8yDLHSUQIb8Bu7NKB9WSOMN/d6vR/tH7J l2VzC9z4kK2QFWJXsaw0DWg0gPRLNvxeCtk6iVyU5PqPmGrRaq5VA9TjNBu2PJ7BW9 RryJ8/gzy57OQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 08/16] kconfig: remove conf_unsaved in conf_read_simple() Date: Wed, 12 Jun 2024 02:55:17 +0900 Message-ID: <20240611175536.3518179-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This variable is unnecessary. Call conf_set_changed(true) directly. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 05823f85402a..4359fbc9255b 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -477,7 +477,6 @@ int conf_read_simple(const char *name, int def) int conf_read(const char *name) { struct symbol *sym; - int conf_unsaved = 0; conf_set_changed(false); @@ -508,11 +507,11 @@ int conf_read(const char *name) } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) /* no previous value and not saved */ continue; - conf_unsaved++; + conf_set_changed(true); /* maybe print value in verbose mode... */ } - if (conf_warnings || conf_unsaved) + if (conf_warnings) conf_set_changed(true); return 0; From patchwork Tue Jun 11 17:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694086 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 B865313D2B2; Tue, 11 Jun 2024 17:56:11 +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=1718128571; cv=none; b=WwTdjSn4J87Wr4+Duq/VC05ofp/9hYNg/m3dLN8MwwFVOX1bGEY5YQE5rY3g2SWL+7iIO2RrCLv9kDYz7iXck5RTPsRigtidISAQtcsVudHPETCrGJzGOSyfk+MIvtmzk/xghuSrFCCu8ufR6Mj+O017xHE6lTW6ypdHr3TZMBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128571; c=relaxed/simple; bh=+/lE6+H5ABqs4SlKsAZy4Du0516Zahbwztxm4gigQf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIA1POxKptwrfQiZ8izZirLXWhxrtXqfgRAU7cCOQeFHhSgVp4TAqbc+J5Rg4649h+Cx6PCuFsjEEoaRM/zLDmfz4dB5wnjc5xcw3ATRLBRzexCRVdJv73GVOeiWxjOgV2nMbndc9ZS3paV5E443etLnyRyRiHvwzrwWVEEtsOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gMtRScR+; 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="gMtRScR+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D65AFC4AF48; Tue, 11 Jun 2024 17:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128571; bh=+/lE6+H5ABqs4SlKsAZy4Du0516Zahbwztxm4gigQf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMtRScR+8VyEbauMWoAq2hIGK3K34VVmzRlq04OffhN5gfrz4+ILW4zoxgvXMNxYZ zpW0I2CdLX+v/35a3o9ZOIjWFsKLeR7ZvMHfzoticck8nxqzV6ARvS36mn+WUpZ4bz xTVx/UgOrlpgCFwlVIDC9WvPwH533VNRNb10B6AVFlJRKvStd/wvpFghG1djmOLvOf TFv5qoEnZyWYe4du04ZGtqHAoKOpm+z/Dd/FXPrIxbuX5D1yQIylHAjTNORH/m3GRX hxO4HEAwV+ym6bXuzI9K8kupk459+r12izcbgmUpiZu0Gz4FG3j64VnFsUgMGFhUEY IZPknyhbEcOXg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 09/16] kconfig: change sym_choice_default() to take the choice menu Date: Wed, 12 Jun 2024 02:55:18 +0900 Message-ID: <20240611175536.3518179-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Change the argument of sym_choice_default() to ease further cleanups. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 2 +- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/symbol.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 4359fbc9255b..76193ce5a792 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -779,7 +779,7 @@ int conf_write_defconfig(const char *filename) if (choice) { struct symbol *ds; - ds = sym_choice_default(choice->sym); + ds = sym_choice_default(choice); if (sym == ds && sym_get_tristate_value(sym) == yes) continue; } diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d820272a85fb..586a5e11f51e 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -109,7 +109,7 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help); /* symbol.c */ void sym_clear_all_valid(void); -struct symbol *sym_choice_default(struct symbol *sym); +struct symbol *sym_choice_default(struct menu *choice); struct symbol *sym_calc_choice(struct menu *choice); struct property *sym_get_range_prop(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index b2fdae15f367..32c80a29dcd4 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -255,14 +255,14 @@ static void sym_calc_visibility(struct symbol *sym) * Next locate the first visible choice value * Return NULL if none was found */ -struct symbol *sym_choice_default(struct symbol *sym) +struct symbol *sym_choice_default(struct menu *choice) { struct symbol *def_sym; struct property *prop; struct expr *e; /* any of the defaults visible? */ - for_all_defaults(sym, prop) { + for_all_defaults(choice->sym, prop) { prop->visible.tri = expr_calc_value(prop->visible.expr); if (prop->visible.tri == no) continue; @@ -272,7 +272,7 @@ struct symbol *sym_choice_default(struct symbol *sym) } /* just get the first visible value */ - prop = sym_get_choice_prop(sym); + prop = sym_get_choice_prop(choice->sym); expr_list_for_each_sym(prop->expr, e, def_sym) if (def_sym->visible != no) return def_sym; @@ -309,7 +309,7 @@ struct symbol *sym_calc_choice(struct menu *choice) /* If 'y' is not found in the user input, try the default */ if (!res) { - res = sym_choice_default(choice->sym); + res = sym_choice_default(choice); if (res && sym_has_value(res) && res->def[S_DEF_USER].tri == no) res = NULL; } From patchwork Tue Jun 11 17:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694087 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 6A25615216C; Tue, 11 Jun 2024 17:56:12 +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=1718128573; cv=none; b=afo3YYCtGa8HB8NvA9L+yofZiBR/9Yw2V5iBSxP+JJ7hfGnaMmP4mPEQ0YIBmvPk4xMEa/XMRtuufgzqB9uJJ9xLT157Ke65BDf5P19HIyNGI/98sfrnr+pRJ/8QXqZsbek6MGvACDcuLF4c9b9DBUSdLn9O484kyOg9rzKKKzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128573; c=relaxed/simple; bh=fw7gwYH6PjjTv166bTFSFEw2m1wKgdODwKV9veoJHuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rzcV5nl278qpy0ljIj0rP0ed6AU7Fr8uZkqk8TyeGDZZRiPuGYW6BHfcrl+2GhxH+zcx1/XYwT8mpzQU2fk9OilJCeMQBJ1RwyC2KQKpXb8vGSvM3iE2/CEmQ2HkUOCHqeK9VV+CZv5/eXe3HYEIG7oAXAQvWmKDz5KGn4HzqUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TFawKK/t; 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="TFawKK/t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24627C32786; Tue, 11 Jun 2024 17:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128572; bh=fw7gwYH6PjjTv166bTFSFEw2m1wKgdODwKV9veoJHuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFawKK/tCtZlu0C4bPbY7iDBoxQciVi6hp7bTnAYjgL6lrBmJ/XkMzPS/AlhSYFUW S6xEmuNZW7rXzIoy9YzcTfJpcDWb5Mq4VEyJlNCXUJt9gKeQsl8qaYbWwno09nE0Nh DEc/iElB4427ZxYBOG5N2w31lZFYJFE9ayo8HS7X68cZ1yM6LQXzH48OV91017VJd0 oi9FQeDPpG+JB3A8cl2r/SXDXi22ite0K+Mf0qHAhS1ShCrIyPEE/LSx+yTKCpUyvz c3tW5Yji9opbCmTfMDn2XrGX0x1yZWoFj8t3opEqyKneM7+h+0GkzgoI9lpfKLo3GM hg2r8hG3QA0Lw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 10/16] kconfig: use menu_list_for_each_sym() in sym_choice_default() Date: Wed, 12 Jun 2024 02:55:19 +0900 Message-ID: <20240611175536.3518179-11-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Choices and their members are associated via the P_CHOICE property. Currently, sym_get_choice_prop() and expr_list_for_each_sym() are used to iterate on choice members. Replace them with menu_for_each_sub_entry(), which achieves the same without relying on P_CHOICE. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 32c80a29dcd4..32b38724c960 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -257,9 +257,9 @@ static void sym_calc_visibility(struct symbol *sym) */ struct symbol *sym_choice_default(struct menu *choice) { + struct menu *menu; struct symbol *def_sym; struct property *prop; - struct expr *e; /* any of the defaults visible? */ for_all_defaults(choice->sym, prop) { @@ -272,10 +272,9 @@ struct symbol *sym_choice_default(struct menu *choice) } /* just get the first visible value */ - prop = sym_get_choice_prop(choice->sym); - expr_list_for_each_sym(prop->expr, e, def_sym) - if (def_sym->visible != no) - return def_sym; + menu_for_each_sub_entry(menu, choice) + if (menu->sym && menu->sym->visible != no) + return menu->sym; /* failed to locate any defaults */ return NULL; From patchwork Tue Jun 11 17:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694088 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 21228152517; Tue, 11 Jun 2024 17:56:14 +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=1718128574; cv=none; b=HSzlhtOD34AU/OoAmiEK9x5qeMyIOL2ZUPiOvsIYkt0WAbGBt/iaBDW2x96w5fSacEiLaaPdKZSzpLQci1Z6S9xIkYRg/lCpkUGQyCXyVOugI52hoidbOMvmXEg4qBe20bdCuL/zJVtqSgKoF0kINInIReY/wETh9GFbyPlnpNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128574; c=relaxed/simple; bh=HzGlcc1zoUQ21+21S1BHbLI+WRTcdDdm+q0L5lx0MlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ob2xj7DomKykm1WfrY9F2i2z9yFTQWOEz/ISAJAL+36hL8kvKrdyJ4A6AC8gHDlbnH6nOwDauClUDOMQ/tMvuJNFzp5IFcQGS1lXcZIH0cMGybtlqKsL0CcvSCnsMH4hLV6HDdaiyi9V7UtNIIGsxyr5Kg+lDoM16yuchXTDDPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O/tQ9cJD; 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="O/tQ9cJD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 499CCC4AF49; Tue, 11 Jun 2024 17:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128574; bh=HzGlcc1zoUQ21+21S1BHbLI+WRTcdDdm+q0L5lx0MlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O/tQ9cJDKSZqc4E2aV5nWA3bgw9YHueKFMLGq6Ric0W1mG5zDh7eIyKEU5+6p8Ek4 4aINFnenyFzxx/IAnkEqCjk/ta8c57PnQMFbuYbGS6kW814nNIBCSV5VJwIOx/+4Y+ lIrfH0RCcuThoHKqAatZmvAsRVAhqAP5hf68EvVGuQ3s+FuTOC2F8d9alIfZFMJFkc Hf7QXxDwxcqVHp/G74p+fsbYyaLBItLgbecIw/6v7Wez0498eCXhyVJK1HWosMfcQE qe//AR/0gEtgdvlZGQ8Uo6pzrOprzxWPt/Nms3UcfcN9PyTiVcvTJj3GVfFzE5NKYG kgdB8vYhWbpcA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 11/16] kconfig: remove expr_list_for_each_sym() macro Date: Wed, 12 Jun 2024 02:55:20 +0900 Message-ID: <20240611175536.3518179-12-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All users of this macro have been converted. Remove it. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 7acf27a4f454..1d1c4442c941 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -43,9 +43,6 @@ struct expr { #define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) #define EXPR_NOT(dep) (2-(dep)) -#define expr_list_for_each_sym(l, e, s) \ - for (e = (l); e && (s = e->right.sym); e = e->left.expr) - struct expr_value { struct expr *expr; tristate tri; From patchwork Tue Jun 11 17:55:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694089 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 ABA121534EB; Tue, 11 Jun 2024 17:56:15 +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=1718128575; cv=none; b=r6223VqcHqNJRBt2dG5+xYuwQn5BWHyQSqrlKpHBZ8DYFe931usB3IQFUUEFK844xFx21UM7Gb6MaLvXMimcayqFJIC3HcYB3DKifPN3EAhTIUYwjAiClpbPOpk00mxAQFcw64q4DXDbdN4dPjfOhqT/FlHNvwcKE7piutlYhvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128575; c=relaxed/simple; bh=qpviQ1ERfH+WJ2ZfrRjot8me/WrXcMTZ24tdvkIstK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mw06u3jrlTFvoA4WQf+/LGNiw6kKzRvKuGoVhX5bmPKW13yelLVbp8aVwZiHzc06PbjLR4RRfa/NhtqleOeEF8UTp1a83pYSJ2dEOKumKi4skuQbF8lGU+r345ua0II00kA4cI3ZO0nSAkHIjtBSJ4LUcQEZqCTwJgJ+3st9vV8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cY0QvwRU; 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="cY0QvwRU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75E54C32786; Tue, 11 Jun 2024 17:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128575; bh=qpviQ1ERfH+WJ2ZfrRjot8me/WrXcMTZ24tdvkIstK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cY0QvwRU3froZ6qec0HZ+AAWgrCD78FR1O0r/TAlSKq5PP4aqN18MV6lbqH3n4SUC IUFVx1FyM5p8MjTpLXDO85hEt43YygAkOWskUvuYLLWjKmm7xb56vezP66SiBMLDAC AkGdlB9rE9H4HOO+RRJGYnEgIt37SJiz17BMLCPTsuWjWAj7BtM/XAmTojFyTnALAD h0Slh0TNl9RCt4buh5J0ax9kELMxisrqCz/5ULYenC3FfYUbDliIt0WEiXYy6nNyBY qRJv/wYYe8PxXFCumpOVh8YtquKTXD/xRE8jy58/ICqHWQKCnFOHlNPYHfAG3jl8Ps 9JilaLOB4BD0A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 12/16] kconfig: use sym_get_choice_menu() in sym_check_print_recursive() Date: Wed, 12 Jun 2024 02:55:21 +0900 Message-ID: <20240611175536.3518179-13-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Choices and their members are associated via the P_CHOICE property. Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain the choice of the given choice member. Replace it with sym_get_choice_menu(), which retrieves the choice without relying on P_CHOICE. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 32b38724c960..86358cfb39cc 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1068,12 +1068,14 @@ static void sym_check_print_recursive(struct symbol *last_sym) struct dep_stack *stack; struct symbol *sym, *next_sym; struct menu *menu = NULL; + struct menu *choice; struct property *prop; struct dep_stack cv_stack; - if (sym_is_choice_value(last_sym)) { + choice = sym_get_choice_menu(last_sym); + if (choice) { dep_stack_insert(&cv_stack, last_sym); - last_sym = prop_get_symbol(sym_get_choice_prop(last_sym)); + last_sym = choice->sym; } for (stack = check_top; stack != NULL; stack = stack->prev) From patchwork Tue Jun 11 17:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694090 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 68DDA153584; Tue, 11 Jun 2024 17:56:16 +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=1718128576; cv=none; b=XWYKADaMqChMZ1TNZrX5N0s82WxZGcITHWa+JD2SiWd9QBC+ZbiqX2dtXC9cEzAtPl5uFSdL9JlR/4pzloDyoi4dgQdb6CLSP7EQIDQnSCFBqpfKmnRiJDIkNb4JmNhwjhI9uTS+7EIia2NMchdsAXNBFbTGNS8nw1Ju8x+B3eE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128576; c=relaxed/simple; bh=xG26G4d1ul6MF7ShnOaqRAWp7QAAzxRQqAxuii9Pltw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M0qDhehKwZX8EjN1NbWT7CQIqAr/9dVvnx/UoNDRqEIIBwl5OJHxNfRPwKl2QWDxvhKI58w0Io4upUewRuR3XiV3QgiIMUtSeck8ZPI1F3R1ecVFehB91hgz5s8fR4oL2DUohqzSv/T1ixv4k9i4He23eSNDsQbb629evDN/5Yc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aMoWwTeb; 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="aMoWwTeb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 960E9C4AF1C; Tue, 11 Jun 2024 17:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128576; bh=xG26G4d1ul6MF7ShnOaqRAWp7QAAzxRQqAxuii9Pltw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMoWwTeb0fHLJPPNZxY3+GUVRYrm/ZHNzjGcwm/OpfYFgHJAQEYFzsKbpezy6Wrl5 btPkmY7b5XRrlDDJ/Idrn+so71auRfTVUzQfx+xCdnJqR3pgIok62dEIVTGY/GkjO8 Okqc3JcMAnblS9C4qEYoHvot66PTzOCf7OsYNECBUruWL4luKJCkf/plVCwIA9acew t6tKqbcfNbUBdut6pujHJNjnB7uwHIDcOjnDzOQxo36Z9qxNokkIMz9fOAbkyxAX3N vf7GVEG1l4wGnt+WCJQCoANXFcwAgG6jDXVcdhd7hDcrso12F88fW8chY9nE90BI4o R+P9X3aKfWA6w== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 13/16] kconfig: use sym_get_choice_menu() in sym_check_choice_deps() Date: Wed, 12 Jun 2024 02:55:22 +0900 Message-ID: <20240611175536.3518179-14-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Choices and their members are associated via the P_CHOICE property. Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain the choice of the given choice member. Replace it with sym_get_choice_menu(), which retrieves the choice without relying on P_CHOICE. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 86358cfb39cc..d30d70b43656 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1270,9 +1270,13 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) if (menu->sym) menu->sym->flags &= ~SYMBOL_CHECK; - if (sym2 && sym_is_choice_value(sym2) && - prop_get_symbol(sym_get_choice_prop(sym2)) == choice) - sym2 = choice; + if (sym2) { + struct menu *choice_menu2; + + choice_menu2 = sym_get_choice_menu(sym2); + if (choice_menu2 == choice_menu) + sym2 = choice; + } dep_stack_remove(); From patchwork Tue Jun 11 17:55:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694091 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 9F34660BBE; Tue, 11 Jun 2024 17:56:17 +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=1718128577; cv=none; b=gwCBx0juCx+QdbCAAKCXDmnoM7Tm4MqqlbZ8e47EHlmU7lI1eKmvGczSDBUdZcHwqh3K/+pmLZ13ScAckVAuGEMfKyZ4sOMVKUYHLXRBOyCmsY1hAUrlatM+OtwuXn7givQQa2q8ea52N/T0NtgtRwAQmfaxZLV0c0VScvUvDxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128577; c=relaxed/simple; bh=0d/7irtLqvVKvQbLdv1BtkgLma4a6BUs9FbNciqSICc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=grjyw0IXSrlNrWGwMDjnvKYhu6M6gnSny7FVPC94wstjkNmqmGWTb5olP1VaRaw/T8rUnf1HLYqh+c6qDGf5xxdHMFHbxdaZcmLyJxLeQpIeR2wgQFgp4eJd4Q/xLifeH6eZzoWW3ur6lTQstG9Z5D1nEPuTjdyZN5GMHGkjfAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qI21hgpY; 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="qI21hgpY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2BBCC32786; Tue, 11 Jun 2024 17:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128577; bh=0d/7irtLqvVKvQbLdv1BtkgLma4a6BUs9FbNciqSICc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qI21hgpYKpiSVyYprF38vn68ympALpgB24t1NhRRP6n5Nx2T8EbNG7U0ampYYjC0+ Vz08Fr6M4r0GgmJL8TcJ175keXlVu43Jrw1pV36vv6PeMPY18xXwtnxzFu36I1QIoG 9mGDEaLa4w8L7+l1VxbvYScdUwF+4SRmWreuydp6p1Su8gXRchTg8jfxOY1rBJewLU IaPiKJ2v4U30m9wF+353fRnJyUlR6RIlNwN66uKEt1dWk+g2A4zfhLeMpE8Cs9ivB/ 8mneK7y5aJcazz8LCGfDAvLfs+WskG1/zQoLO+lR7QiRg/m+piaB2L8jENEZTWx5t9 P++RlMe4VzSjQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 14/16] kconfig: use sym_get_choice_menu() in sym_check_deps() Date: Wed, 12 Jun 2024 02:55:23 +0900 Message-ID: <20240611175536.3518179-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Choices and their members are associated via the P_CHOICE property. Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain the choice of the given choice member. Replace it with sym_get_choice_menu(), which retrieves the choice without relying on P_CHOICE. Signed-off-by: Masahiro Yamada --- scripts/kconfig/symbol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index d30d70b43656..3e91ecc35bc3 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1285,8 +1285,8 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) struct symbol *sym_check_deps(struct symbol *sym) { + struct menu *choice; struct symbol *sym2; - struct property *prop; if (sym->flags & SYMBOL_CHECK) { sym_check_print_recursive(sym); @@ -1295,13 +1295,13 @@ struct symbol *sym_check_deps(struct symbol *sym) if (sym->flags & SYMBOL_CHECKED) return NULL; - if (sym_is_choice_value(sym)) { + choice = sym_get_choice_menu(sym); + if (choice) { struct dep_stack stack; /* for choice groups start the check with main choice symbol */ dep_stack_insert(&stack, sym); - prop = sym_get_choice_prop(sym); - sym2 = sym_check_deps(prop_get_symbol(prop)); + sym2 = sym_check_deps(choice->sym); dep_stack_remove(); } else if (sym_is_choice(sym)) { sym2 = sym_check_choice_deps(sym); From patchwork Tue Jun 11 17:55:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694092 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 C77FE1552F9; Tue, 11 Jun 2024 17:56:18 +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=1718128578; cv=none; b=lKYlpsnSvAH8zVShfRqFxBu0yVLkaMvYcIGQ0BDD6P7AjskMKKr6QT1EmtDhXFc12YncmuWCLheiRGO+mAfR0v7a4cCCS1/k+KnKmPD6PjSlgnye8v9Lm/ZfF1UyBQHNZT4ZUrHj0n3MPuWig4BI7RIqgGaQyLdnuY0GQK33pks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128578; c=relaxed/simple; bh=mjmWAkW2QhcMlwcFBklru0Injf0d53f361t5tsub4sQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fNI/GwhpLLFunbG61Vq2KAZ/PzIFJMLMfxdPEdbxSYNLKbGe0avVheOtURmHnRwhANHXPI/aSUzAahQMDn8OXugjUk6jq7CAtAtJCvtxkGEZbD6MdcAYIX6EZJ5WXHKzlDMnE2M+dGY0bfe7xFPbm+9lNA6wPPEybJtvQa/pDX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PJczbbFd; 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="PJczbbFd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07847C4AF48; Tue, 11 Jun 2024 17:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128578; bh=mjmWAkW2QhcMlwcFBklru0Injf0d53f361t5tsub4sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PJczbbFdUdK7Q7rgLN8ixZW6VO+LB8OJyv+BtErfccka7hmVvm3bqgLwMlQ8Eu26K qhb6cA0uNhxBNmW9vq4q8xZInuzdVf9f5eSLHzO6LnpwYFAJQLX3iN/k/+unr83mNR P1cunbdpbqumODxOx/d604uY2A6yh3xGjaEAv6IclYhtBOIYCPE6P/2kYSqM9G7+wK ef7T8koknA0ktD3L1yyjwePk3YLT8RNWuDGHCT90ZADHDBUMVbGWLeXbxetxUyeDkX bFfrG2gTdjnFtmXec6kfKpX3TkxT4tKXh4siGiECE77qWyIemR3VqIdHNnscwhjpUe ZgzB1B357h5/Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 15/16] kconfig: remove P_CHOICE property Date: Wed, 12 Jun 2024 02:55:24 +0900 Message-ID: <20240611175536.3518179-16-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 P_CHOICE is a pseudo property used to link a choice with its members. There is no more code relying on this, except for some debug code. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 4 +--- scripts/kconfig/lkc_proto.h | 1 - scripts/kconfig/menu.c | 8 +------- scripts/kconfig/parser.y | 4 ---- scripts/kconfig/qconf.cc | 8 -------- scripts/kconfig/symbol.c | 14 +------------- 6 files changed, 3 insertions(+), 36 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 1d1c4442c941..58fd4c8c3762 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -167,7 +167,6 @@ enum prop_type { P_COMMENT, /* text associated with a comment */ P_MENU, /* prompt associated with a menu or menuconfig symbol */ P_DEFAULT, /* default y */ - P_CHOICE, /* choice value */ P_SELECT, /* select BAR */ P_IMPLY, /* imply BAR */ P_RANGE, /* range 7..100 (for a symbol) */ @@ -181,7 +180,7 @@ struct property { struct expr_value visible; struct expr *expr; /* the optional conditional part of the property */ struct menu *menu; /* the menu the property are associated with - * valid for: P_SELECT, P_RANGE, P_CHOICE, + * valid for: P_SELECT, P_RANGE, * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ const char *filename; /* what file was this property defined */ int lineno; /* what lineno was this property defined */ @@ -191,7 +190,6 @@ struct property { for (st = sym->prop; st; st = st->next) \ if (st->type == (tok)) #define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT) -#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE) #define for_all_prompts(sym, st) \ for (st = sym->prop; st; st = st->next) \ if (st->text) diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 1221709efac1..49cc649d2810 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -34,7 +34,6 @@ bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_within_range(struct symbol *sym, const char *str); bool sym_set_string_value(struct symbol *sym, const char *newval); bool sym_is_changeable(struct symbol *sym); -struct property * sym_get_choice_prop(struct symbol *sym); struct menu *sym_get_choice_menu(struct symbol *sym); const char * sym_get_string_value(struct symbol *sym); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 170a269a8d7c..0353f621ecaa 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -306,7 +306,7 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) struct menu *menu, *last_menu; struct symbol *sym; struct property *prop; - struct expr *parentdep, *basedep, *dep, *dep2, **ep; + struct expr *parentdep, *basedep, *dep, *dep2; sym = parent->sym; if (parent->list) { @@ -492,12 +492,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) menu->sym && !sym_is_choice_value(menu->sym)) { current_entry = menu; menu->sym->flags |= SYMBOL_CHOICEVAL; - menu_add_symbol(P_CHOICE, sym, NULL); - prop = sym_get_choice_prop(sym); - for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr) - ; - *ep = expr_alloc_one(E_LIST, NULL); - (*ep)->right.sym = menu->sym; } /* diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 9d58544b0255..745c82ee15d0 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -241,7 +241,6 @@ choice: T_CHOICE T_EOL struct symbol *sym = sym_lookup(NULL, 0); menu_add_entry(sym); - menu_add_expr(P_CHOICE, NULL, NULL); menu_set_type(S_BOOLEAN); INIT_LIST_HEAD(¤t_entry->choice_members); @@ -696,9 +695,6 @@ static void print_symbol(FILE *out, struct menu *menu) } fputc('\n', out); break; - case P_CHOICE: - fputs(" #choice value\n", out); - break; case P_SELECT: fputs( " select ", out); expr_fprint(prop->expr, out); diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 30346e294d1a..7d239c032b3d 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1101,14 +1101,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym) &stream, E_NONE); stream << "
"; break; - case P_CHOICE: - if (sym_is_choice(sym)) { - stream << "choice: "; - expr_print(prop->expr, expr_print_help, - &stream, E_NONE); - stream << "
"; - } - break; default: stream << "unknown property: "; stream << prop_get_type_name(prop->type); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 3e91ecc35bc3..9d9b73760969 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -68,15 +68,6 @@ const char *sym_type_name(enum symbol_type type) return "???"; } -struct property *sym_get_choice_prop(struct symbol *sym) -{ - struct property *prop; - - for_all_choices(sym, prop) - return prop; - return NULL; -} - /** * sym_get_choice_menu - get the parent choice menu if present * @@ -1215,8 +1206,7 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) stack.expr = NULL; for (prop = sym->prop; prop; prop = prop->next) { - if (prop->type == P_CHOICE || prop->type == P_SELECT || - prop->type == P_IMPLY) + if (prop->type == P_SELECT || prop->type == P_IMPLY) continue; stack.prop = prop; sym2 = sym_check_expr_deps(prop->visible.expr); @@ -1333,8 +1323,6 @@ const char *prop_get_type_name(enum prop_type type) return "menu"; case P_DEFAULT: return "default"; - case P_CHOICE: - return "choice"; case P_SELECT: return "select"; case P_IMPLY: From patchwork Tue Jun 11 17:55:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13694093 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 509F915534E; Tue, 11 Jun 2024 17:56:19 +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=1718128580; cv=none; b=S/R5LHgOx1xxB1SatxLj2R9yIPIWkjUjfyNqTp4Azxqnw89iLHyMkH+dtNk0+Jon0Yz/g0fPwAASq3OLCWlOdHSKj6wFHWpZfSmsERb/2UmQsOtBO0kMvPVPtToY2yvvA/rpphOt8OWsxpwEmKClj62mc18rlKa2ldvD9+EBbgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718128580; c=relaxed/simple; bh=PBo//4aJrsXf6XHAbijgizpIwmV57rDMalOKmV3B/Hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MRz+TJ89NzZW7BpoWRglI7SBThfoyvPmjeJpgzaW7ppSsG/NBTZI4R6y3FBDfxBlQFzJNQKl/vVJGOUJRy4+pipzOmNKpN4+8balluUnfQilkUO1qcR/ODtOFAbIKe0n/vfrHICvFkC1N5z21NwPuTOEitnYQsIx7QYn2l4q7g4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JiQRtqJg; 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="JiQRtqJg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33F8FC4AF49; Tue, 11 Jun 2024 17:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718128579; bh=PBo//4aJrsXf6XHAbijgizpIwmV57rDMalOKmV3B/Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JiQRtqJg4d1N+9Za+l5rVpzW3RPzKc9n1FYfPCUWWUQpgEvKAbtxhGUTsqX4qZWJ7 hrOACGCvvEoJXX8T2FmcGDOivmMkdpE8zPdj/ayMiistj6FK3Go2aHrJx2Wn0fcQDv N+UzalmTlf+8oQlXD8Sv5smqMsgRzGARrnCJN6gHG8dQsWwB+xPQYHM8/+NvBMGY8w +MZ9ifUnukby2Kyi60EPIdXR3W6mL0Xlw30gbVQI/Z0GRmX552J3UdZ5IIHkO2M0Gy yEdkKqJROXDsXs1Wjj9honfpeSoJ0ZuOpNWCepZ24apSD9wVRrhhY6Stg/qxdAOdZt UupQIoo25l12w== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 16/16] kconfig: remove E_LIST expression type Date: Wed, 12 Jun 2024 02:55:25 +0900 Message-ID: <20240611175536.3518179-17-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611175536.3518179-1-masahiroy@kernel.org> References: <20240611175536.3518179-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 E_LIST was preveously used to form an expression tree consisting of choice members. It is no longer used. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 15 --------------- scripts/kconfig/expr.h | 2 +- scripts/kconfig/symbol.c | 3 +-- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index bea82d5cac83..6d4b5a5a1e62 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -90,7 +90,6 @@ struct expr *expr_copy(const struct expr *org) break; case E_AND: case E_OR: - case E_LIST: e->left.expr = expr_copy(org->left.expr); e->right.expr = expr_copy(org->right.expr); break; @@ -286,7 +285,6 @@ int expr_eq(struct expr *e1, struct expr *e2) expr_free(e2); trans_count = old_count; return res; - case E_LIST: case E_RANGE: case E_NONE: /* panic */; @@ -676,7 +674,6 @@ struct expr *expr_transform(struct expr *e) case E_LTH: case E_UNEQUAL: case E_SYMBOL: - case E_LIST: break; default: e->left.expr = expr_transform(e->left.expr); @@ -947,7 +944,6 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb break; case E_SYMBOL: return expr_alloc_comp(type, e->left.sym, sym); - case E_LIST: case E_RANGE: case E_NONE: /* panic */; @@ -1097,10 +1093,6 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) if (t2 == E_OR) return 1; /* fallthrough */ - case E_OR: - if (t2 == E_LIST) - return 1; - /* fallthrough */ default: break; } @@ -1173,13 +1165,6 @@ void expr_print(struct expr *e, fn(data, NULL, " && "); expr_print(e->right.expr, fn, data, E_AND); break; - case E_LIST: - fn(data, e->right.sym, e->right.sym->name); - if (e->left.expr) { - fn(data, NULL, " ^ "); - expr_print(e->left.expr, fn, data, E_LIST); - } - break; case E_RANGE: fn(data, NULL, "["); fn(data, e->left.sym, e->left.sym->name); diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 58fd4c8c3762..8849a243b5e7 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -26,7 +26,7 @@ typedef enum tristate { enum expr_type { E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ, - E_LIST, E_SYMBOL, E_RANGE + E_SYMBOL, E_RANGE }; union expr_data { diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 9d9b73760969..b4d085342b94 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1306,8 +1306,7 @@ struct symbol *sym_check_deps(struct symbol *sym) struct symbol *prop_get_symbol(struct property *prop) { - if (prop->expr && (prop->expr->type == E_SYMBOL || - prop->expr->type == E_LIST)) + if (prop->expr && prop->expr->type == E_SYMBOL) return prop->expr->left.sym; return NULL; }