From patchwork Mon Dec 9 08:19:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 11278557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE68E13B6 for ; Mon, 9 Dec 2019 08:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2349205ED for ; Mon, 9 Dec 2019 08:19:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FlmtG5xK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbfLIIT1 (ORCPT ); Mon, 9 Dec 2019 03:19:27 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:32924 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfLIIT1 (ORCPT ); Mon, 9 Dec 2019 03:19:27 -0500 Received: by mail-pj1-f65.google.com with SMTP id r67so5551565pjb.0; Mon, 09 Dec 2019 00:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jbpRGF95ZNnelw7MpvbO5/+qdOTsvxhQeZ2np0qSQ5Y=; b=FlmtG5xKIB++/JaurZkU3J/C0+hF0iE6Pw/uZd/aZmCOXnMzMG94FETriFTeKS5RLm b3p1tIJhK/fvU8xI7/9ujaVkFjLqe39A5wqwsx6VQ50sD7QqkWDmy1Kr+PcIRBRGaS3C enuD8C/97wk0u3WZzWkKVZvk6k02RoHPq1lpqQqxbDw2SOM7IQz5KMvuSrW7bDcw4GMr BtjToNVnxNA5doLZ6tc9HGc94VrV62BkAMRGVgc9tAaN1LLj+lAO0eRT9RbiqfjCOiLf Fbyi11EbSvNUGK/nBVn8wBbjnsA+v8rrNhIAwwKVRcjBCQIekQGjEgv3JSIzHMPFGYKv noYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jbpRGF95ZNnelw7MpvbO5/+qdOTsvxhQeZ2np0qSQ5Y=; b=ThTwIAGxBgk7ak6eI9RZz9hYRuCytiWnPReNcy4dlqd1EHniF3gNc+K3s+aszZNVWz vQetVWKqu2PpIbpTKKU11Q8hexrEGgRtkfS2+J49Xs7+xgaaH27IFFBLBKoSG4eLtLU6 Fd71j+L+oYLpfBSz/MpXI/l+HY4KRdIsd0qOq63cE0q662NTfb73by6cqdmVDpl6d2LN vfbJaHSkOOMihpExrVjmXSewh813jmZmebga81/Mp5It8bIXNQrZC+GkogSE2gP6f4O7 kbsBIheVV1oZWr6fje2h3lhMzJxUoMAYO4lqujqn6zQ3kQaTeiZ448394p7UnX15Yxlr HB0w== X-Gm-Message-State: APjAAAVuMnKqGj0dwWpWtgw3wEsp26LWFRkgLblW3hTqsceMM6N4BrGf JyvjwzjO+P6R0nqBFV8V8oriG5/Ny2ckGA== X-Google-Smtp-Source: APXvYqxLVf6KTljRnfSLnvaVT9UEeXs6LiUrPQAUVxU0rg+bh46TGYh9rqhtvMCzCT1p7u2ZMnK88A== X-Received: by 2002:a17:902:8504:: with SMTP id bj4mr27729232plb.171.1575879565721; Mon, 09 Dec 2019 00:19:25 -0800 (PST) Received: from glados.lan ([2601:647:4c01:6541:fa16:54ff:fed1:1bd6]) by smtp.gmail.com with ESMTPSA id u2sm23810375pgc.19.2019.12.09.00.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 00:19:25 -0800 (PST) From: Thomas Hebb To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Thomas Hebb , Masahiro Yamada , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org (open list:SIFIVE DRIVERS) Subject: [PATCH 1/4] kconfig: list all definitions of a symbol in help text Date: Mon, 9 Dec 2019 00:19:16 -0800 Message-Id: <1eaa4143fdb000563cde114bb7e0166b1fc229bf.1575879069.git.tommyhebb@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org In Kconfig, each symbol (representing a config option) can be defined in multiple places. Each definition may or may not have a prompt, which allows the option to be set via an interface like menuconfig. Each definition has a set of dependencies, which determine whether its prompt is visible and whether other pieces of the definition, like a default value, take effect. Historically, a symbol's help text (i.e. what's shown when a user presses '?' in menuconfig) contained some symbol-wide information not tied to any particular definition (e.g. what other symbols it selects) as well as the location (file name and line number) and dependencies of each prompt. Notably, the help text did not show the location or dependencies of definitions without prompts. Because this made it hard to reason about symbols that had no prompts, bcdedcc1afd6 ("menuconfig: print more info for symbol without prompts") changed the help text so that, instead of containing the location and dependencies of each prompt, it contained the location and dependencies of the symbol's first definition, regardless of whether or not that definition had a prompt. For symbols with only one definition, that change makes sense. However, it breaks down for symbols with multiple definitions: each definition has its own set of dependencies (the `dep` field of `struct menu`), and those dependencies are ORed together to get the symbol's dependency list (the `dir_dep` field of `struct symbol`). By printing only the dependencies of the first definition, the help text misleads users into believing that an option is more narrowly-applicable than it actually is. For an extreme example of this, we can look at the SYS_TEXT_BASE symbol in the Das U-Boot project, which also uses Kconfig. (I could not find an illustrative example in the Linux source, unfortunately). This config option specifies the load address of the built binary and, as such, is applicable to basically every configuration possible. And yet, without this patch, its help text is as follows: Symbol: SYS_TEXT_BASE [=0x00200000] Type : hex Prompt: Text Base Location: -> Boot images Defined at arch/arm/mach-aspeed/Kconfig:9 Depends on: ARM [=y] && ARCH_ASPEED [=n] The help text indicates that the option only applicable for a specific unselected architecture (aspeed), because that architecture's promptless definition (which just sets a default value), happens to be the first one seen. Because source locations and dependencies are fundamentally properties of definitions and not of symbols, we should treat them as such. This patch brings back the pre-bcdedcc1afd6 behavior for definitions with prompts but also separately prints the location and dependencies of those without prompts, solving the original problem in a different way. With this change, our SYS_TEXT_BASE example becomes Symbol: SYS_TEXT_BASE [=0x00200000] Type : hex Defined with prompt at Kconfig:548 Prompt: Text Base Depends on: !NIOS2 [=n] && !XTENSA [=n] && !EFI_APP [=n] Location: -> Boot images Defined without prompt at arch/arm/mach-aspeed/Kconfig:9 Depends on: ARM [=y] && ARCH_ASPEED [=n] Defined without prompt at arch/arm/mach-socfpga/Kconfig:28 Depends on: ARM [=y] && ARCH_SOCFPGA [=n] Defined without prompt at board/sifive/fu540/Kconfig:15 Depends on: RISCV [=n] && TARGET_SIFIVE_FU540 [=n] which is a much more accurate representation. Signed-off-by: Thomas Hebb --- scripts/kconfig/menu.c | 49 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index d9d16469859a..59fead4b8823 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -698,6 +698,15 @@ const char *menu_get_help(struct menu *menu) return ""; } +static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix) +{ + if (!expr_is_yes(expr)) { + str_append(r, prefix); + expr_gstr_print(expr, r); + str_append(r, "\n"); + } +} + static void get_prompt_str(struct gstr *r, struct property *prop, struct list_head *head) { @@ -705,7 +714,11 @@ static void get_prompt_str(struct gstr *r, struct property *prop, struct menu *submenu[8], *menu, *location = NULL; struct jump_key *jump = NULL; - str_printf(r, "Prompt: %s\n", prop->text); + str_printf(r, "Defined with prompt at %s:%d\n", + prop->menu->file->name, prop->menu->lineno); + str_printf(r, " Prompt: %s\n", prop->text); + + get_dep_str(r, prop->visible.expr, " Depends on: "); menu = prop->menu->parent; for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { bool accessible = menu_is_visible(menu); @@ -755,18 +768,6 @@ static void get_prompt_str(struct gstr *r, struct property *prop, } } -/* - * get property of type P_SYMBOL - */ -static struct property *get_symbol_prop(struct symbol *sym) -{ - struct property *prop = NULL; - - for_all_properties(sym, prop, P_SYMBOL) - break; - return prop; -} - static void get_symbol_props_str(struct gstr *r, struct symbol *sym, enum prop_type tok, const char *prefix) { @@ -806,17 +807,17 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, } } } - for_all_prompts(sym, prop) - get_prompt_str(r, prop, head); - - prop = get_symbol_prop(sym); - if (prop) { - str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, - prop->menu->lineno); - if (!expr_is_yes(prop->visible.expr)) { - str_append(r, " Depends on: "); - expr_gstr_print(prop->visible.expr, r); - str_append(r, "\n"); + + /* Print the definitions with prompts before the ones without */ + for_all_properties(sym, prop, P_SYMBOL) + if (prop->menu->prompt) + get_prompt_str(r, prop->menu->prompt, head); + + for_all_properties(sym, prop, P_SYMBOL) { + if (!prop->menu->prompt) { + str_printf(r, "Defined without prompt at %s:%d\n", + prop->menu->file->name, prop->menu->lineno); + get_dep_str(r, prop->menu->dep, " Depends on: "); } } From patchwork Mon Dec 9 08:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 11278561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9ACC14B7 for ; Mon, 9 Dec 2019 08:19:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8712B205ED for ; Mon, 9 Dec 2019 08:19:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aSAarSF1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727229AbfLIITb (ORCPT ); Mon, 9 Dec 2019 03:19:31 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37177 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbfLIIT2 (ORCPT ); Mon, 9 Dec 2019 03:19:28 -0500 Received: by mail-pl1-f196.google.com with SMTP id c23so187901plz.4; Mon, 09 Dec 2019 00:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q0ied9L65yH7tx4IRU87dXRq0PeDGyWkKG3sBMiryjI=; b=aSAarSF1Q4vngr/xtJNb7O9bLCUrJSGAd2GqdQvsBD1T81zyGrVEsgwUEdw9dqhDt9 9u9jbJQKhvDiHXlRTwJ+rReVJNowZmDItl6cHOttpJkW3N98tCr/81W9ru5YhTx1kqon qNsENbK2e1W5Brygy7xyOBuZPkB0+YAbaIvmpTGfiuQPLQVlwHXb9Sp4Rb/Dfo6tqO3J 6N3jpZqHBU+2TE2y+i7Rmd0p3gtjWuV813DX6EFyDrHSMIt9yB4Dn4rlrqq+zYB8UwN7 5kfSDrLN69qvFZQKWwY7vOaKXFJD3oSMiLhodfiqDkq6M47Eg9EtsQxj5sKFk+uVlXvv PT4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q0ied9L65yH7tx4IRU87dXRq0PeDGyWkKG3sBMiryjI=; b=SHy89DpIm5hHFpnoLsMfpQJHmtE7CZ+MPc/ZvtlF8zqKcv0e7AMrL0DKXT2MB49mY9 +ZfZcCBOXZdsfmwNb6TcHiKoYv0AthPdkAGR9Z7pFas8ZBEbDAbtYv90vr701cP+glBy tqXtuCZTibx2unhwxLSjFjbOTTNomT+DxNkidRoZQ9OCun3bQ7dtd460diXkSSacRQyh 3n6iq0v2dUgF7ksDNob7AEOKLRr1oRFnxHot6nI5lGIgl4VVdrm6rOZCcg4Od+PRcr0A +nP5qJ6GkASdqOcmu3bYTeNXhHscH/eJG8/+2lTe1QkypLY60rNEqGXT5rzo3aTt9Awc p3SQ== X-Gm-Message-State: APjAAAUe/fTbbiJY8vXp/XSaNrHkBhCfYCaHg2hjq45iAmyUVYb5Z+3s UiNAAmvX2vix1Qr7QCLF8u3oJSlJf6jfqQ== X-Google-Smtp-Source: APXvYqzHpZzDb88qUMIhfw94xrEO0/DNfnFkwUtAGgV3uivw2MIRAyxPWGtMOjFh9Bp8cbIR9Ghijg== X-Received: by 2002:a17:902:12c:: with SMTP id 41mr28079801plb.224.1575879567178; Mon, 09 Dec 2019 00:19:27 -0800 (PST) Received: from glados.lan ([2601:647:4c01:6541:fa16:54ff:fed1:1bd6]) by smtp.gmail.com with ESMTPSA id u2sm23810375pgc.19.2019.12.09.00.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 00:19:26 -0800 (PST) From: Thomas Hebb To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Thomas Hebb , Masahiro Yamada Subject: [PATCH 2/4] kconfig: don't crash on NULL expressions in expr_eq() Date: Mon, 9 Dec 2019 00:19:17 -0800 Message-Id: <2f42719235f9250ed10209982543f99f4fd41d61.1575879069.git.tommyhebb@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org NULL expressions are taken to always be true, as implemented by the expr_is_yes() macro and by several other functions in expr.c. As such, they ought to be valid inputs to expr_eq(), which compares two expressions. Signed-off-by: Thomas Hebb --- scripts/kconfig/expr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 77ffff3a053c..8284444cc3fa 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -254,6 +254,11 @@ static int expr_eq(struct expr *e1, struct expr *e2) { int res, old_count; + /* A NULL expr is taken to be yes, but there's also a different way to + * represent yes. expr_is_yes() checks for either representation. */ + if (!e1 || !e2) + return expr_is_yes(e1) && expr_is_yes(e2); + if (e1->type != e2->type) return 0; switch (e1->type) { From patchwork Mon Dec 9 08:19:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 11278565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62A7014B7 for ; Mon, 9 Dec 2019 08:19:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 374162073D for ; Mon, 9 Dec 2019 08:19:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lz7KVfI7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbfLIITg (ORCPT ); Mon, 9 Dec 2019 03:19:36 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:45681 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfLIITa (ORCPT ); Mon, 9 Dec 2019 03:19:30 -0500 Received: by mail-pj1-f68.google.com with SMTP id r11so5530204pjp.12; Mon, 09 Dec 2019 00:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZbpQ+SxRsU8UeNcbXVf7RHYlP4YI+DdiwpR9PUux8Qw=; b=Lz7KVfI79SnyYoxLBFww86GdVMpI6wV4kqjvuzgKghRyDcfgNg++HRZdH5Ln3zxAuJ Ls0LC3Q5rFs9fJwnNJJ3kX0Sf1+wIF1iW6T2wnpAEY7x6/13iDjQdZMoZ+ktTfIRlrCt lRY7hnO4erUT8imZoaaxeZ7CD0CC4xbv16PHWNokOcbtQqQIm4ffaxaYpDYVTfmlXSbk MYrNIIKlJq7tsp7p1RmrcF8JcaoKg2OJBwES+AuLkgMHYA79QccWXmwC+a3jPbnn54gv xyQGx53Zgd3ib4QuyRMbm2+Xy3Xc7ZPJcKc3JCrFcPXVgZsQuLjZoQUxLD1ugKjH73YI AslQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZbpQ+SxRsU8UeNcbXVf7RHYlP4YI+DdiwpR9PUux8Qw=; b=ihCMZFk5svVGiZvZ4iysqRMaZ7UQwGZ43NEp//Y3G9hSYginmjqO/9wYcyyzEPcH2Z XSrByFtgvna7JMkecdMWvMCLf2LIlKOyeqUNqP2xYADWx1ZEWjEXDgxfUljhUT0R0KtK /XUzu1Py2jWaIXYwc5d1ycOhX/9fda4MNS5iI+/4VAD3gvJWo/2Xv7ZiZAqIXts4G8t3 LDMdCsgbG5QA1iBnM6fuZlpKh9weWpQVsiRbdEYjKQsOQY8rTdqteVKKXB78lmwAmPjX jtrnU8bBjJzFiw1xRD+vDBSxOH/5NTF0gjEvV6dGJbUNt44kCx58Y/balPRvwPUkE4jJ WIOw== X-Gm-Message-State: APjAAAXYFcuCCDu6k5VmHsIUk/IbkDJqbDFh4NEorJOZJt+RuABONc/m CnSehUfV9wjH3Ed1r0cpPYNKlsOUi/gQ8Q== X-Google-Smtp-Source: APXvYqw0+VIO2sSPYIVwhx3axaQXtR19Ch5YKrGy23yxHGISIU1xIki2ZzwzcRoqFQC37eezqGCAmA== X-Received: by 2002:a17:90a:508:: with SMTP id h8mr30800488pjh.91.1575879568519; Mon, 09 Dec 2019 00:19:28 -0800 (PST) Received: from glados.lan ([2601:647:4c01:6541:fa16:54ff:fed1:1bd6]) by smtp.gmail.com with ESMTPSA id u2sm23810375pgc.19.2019.12.09.00.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 00:19:28 -0800 (PST) From: Thomas Hebb To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Thomas Hebb , Masahiro Yamada Subject: [PATCH 3/4] kconfig: distinguish between dependencies and visibility in help text Date: Mon, 9 Dec 2019 00:19:18 -0800 Message-Id: <9d43c96787ecbe2a3f2917483bbc61e378a1a7cf.1575879069.git.tommyhebb@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Kconfig makes a distinction between dependencies (defined by "depends on" expressions and enclosing "if" blocks) and visibility (which includes all dependencies, but also includes inline "if" expressions of individual properties as well as, for prompts, "visible if" expressions of enclosing menus). Before bcdedcc1afd6 ("menuconfig: print more info for symbol without prompts", the "Depends on" lines of a symbol's help text indicated the visibility of the prompt property they appeared under. After bcdedcc1afd, there was always only a single "Depends on" line, which indicated the visibility of the first P_SYMBOL property of the symbol. Since P_SYMBOLs never have inline if expressions, this was in effect the same as the dependencies of the menu item that the P_SYMBOL was attached to. Neither of these situations accurately conveyed the dependencies of a symbol--the first because it was actually the visibility, and the second because it only showed the dependencies from a single definition. Now that we print a "Depends on" line for every definition (regardless of whether or not it has a prompt), we can do better: this patch switches the "Depends on" line for prompts to show the real dependencies of the corresponding menu item and additionally adds a "Visible if" line that shows the visibility only if the visibility is different from the dependencies (which it isn't for most prompts in Linux). Before: Symbol: THUMB2_KERNEL [=n] Type : bool Defined with prompt at arch/arm/Kconfig:1417 Prompt: Compile the kernel in Thumb-2 mode Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] && !CPU_THUMBONLY [=n] Location: -> Kernel Features Selects: ARM_UNWIND [=n] After: Symbol: THUMB2_KERNEL [=n] Type : bool Defined with prompt at arch/arm/Kconfig:1417 Prompt: Compile the kernel in Thumb-2 mode Depends on: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] Visible if: (CPU_V7 [=y] || CPU_V7M [=n]) && !CPU_V6 [=n] && !CPU_V6K [=n] && !CPU_THUMBONLY [=n] Location: -> Kernel Features Selects: ARM_UNWIND [=n] Signed-off-by: Thomas Hebb --- scripts/kconfig/expr.c | 3 +-- scripts/kconfig/expr.h | 1 + scripts/kconfig/menu.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 8284444cc3fa..849c574a28d5 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -13,7 +13,6 @@ #define DEBUG_EXPR 0 -static int expr_eq(struct expr *e1, struct expr *e2); static struct expr *expr_eliminate_yn(struct expr *e); struct expr *expr_alloc_symbol(struct symbol *sym) @@ -250,7 +249,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) * equals some operand in the other (operands do not need to appear in the same * order), recursively. */ -static int expr_eq(struct expr *e1, struct expr *e2) +int expr_eq(struct expr *e1, struct expr *e2) { int res, old_count; diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 017843c9a4f4..d0f17bc9c4ef 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -301,6 +301,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); struct expr *expr_copy(const struct expr *org); void expr_free(struct expr *e); void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); +int expr_eq(struct expr *e1, struct expr *e2); tristate expr_calc_value(struct expr *e); struct expr *expr_trans_bool(struct expr *e); struct expr *expr_eliminate_dups(struct expr *e); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 59fead4b8823..4d0542875d70 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -718,7 +718,17 @@ static void get_prompt_str(struct gstr *r, struct property *prop, prop->menu->file->name, prop->menu->lineno); str_printf(r, " Prompt: %s\n", prop->text); - get_dep_str(r, prop->visible.expr, " Depends on: "); + get_dep_str(r, prop->menu->dep, " Depends on: "); + /* Most prompts in Linux have visibility that exactly matches their + * dependencies. For these, we print only the dependencies to improve + * readability. However, prompts with inline "if" expressions and + * prompts with a parent that has a "visible if" expression have + * differing dependencies and visibility. In these rare cases, we + * print both. */ + if (!expr_eq(prop->menu->dep, prop->visible.expr)) { + get_dep_str(r, prop->visible.expr, " Visible if: "); + } + menu = prop->menu->parent; for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { bool accessible = menu_is_visible(menu); From patchwork Mon Dec 9 08:19:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 11278563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F240113B6 for ; Mon, 9 Dec 2019 08:19:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDD212077B for ; Mon, 9 Dec 2019 08:19:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pUULFXI0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727260AbfLIITg (ORCPT ); Mon, 9 Dec 2019 03:19:36 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45278 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727228AbfLIITb (ORCPT ); Mon, 9 Dec 2019 03:19:31 -0500 Received: by mail-pg1-f194.google.com with SMTP id b9so6319814pgk.12; Mon, 09 Dec 2019 00:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lVXrcLZKGANsU8tPDGf4zTebGjz1MfI/kI2qeZ91X0c=; b=pUULFXI00O+d51QO2CrfHOGqts6TkPmURJGFY2Hx5h5LRwjxA8LLpCl739Sn+zURkx 0Syf+TK2h/Gy3IEWyXtwGiSSI8r5LyVhyLmMuE4qdnTalI/GSRX75z8LVVBDRHvjD4uK 44YJRIWeyZWDrdfhwt/GJU3OhAVMeKiQ4eJl6CoJ3KMfSofmawBsx5aY/7Auz8E0kRIB PR7j380sZmXieN2MoRKIyirgyajIskk1esqF7UiAeES30k4vtyX1yIXBr8uVfqxrleMa oF3ec6yQxzRpJNi+CiWlZU+8BXzRYISf/Js/pT8DfV5An4n/FyQm9CrfUYI1Ln6gIr1s vDUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lVXrcLZKGANsU8tPDGf4zTebGjz1MfI/kI2qeZ91X0c=; b=dEffETPOJEtuVbHJFwZYBymxD/jLXDc247Tn8Z2RQDK47hRW8gKOgaRIN1cVqECOj5 8TI55zGVwbbu6nYycNHFhiU2Kq/QDM0jFp6sI/KlhHrQ3DMLqi97oV6Jnejt1Rwvyi4K uWFeyJ6uoIJ77CLUfITFp/mUT/ySw6s1bvHF/HtBKGh/mCx+0Ie9QXHDiWmumTwc/IHv BhAp18gL9HJCtrd+IRnGq96aW1vLKNE3Rn8wMm7ysaVhgf5DFzRHWmOUTz2rWpo4mMN3 ObNs4T1h0VBujuTDJ0/GenoI2vcsVjEG0C/nHpHU00YAIvosDwIkmzHmir680TRZLw/i iQkQ== X-Gm-Message-State: APjAAAX+2RrVVCoEc1766763/bzVD1FjOr2mDwDjwj5xzSbG0UPx+l50 DQHM7WReqF7O2i8qwXB9WTqNlBBhLgP2DA== X-Google-Smtp-Source: APXvYqxbfbeTkbEc25PmFS4JfnnyWYkx3IwK3B0rBjv3tu1zrkK0Iv1wMQ6f28/CtpitvSTOFpYndg== X-Received: by 2002:a62:3892:: with SMTP id f140mr24826780pfa.190.1575879570010; Mon, 09 Dec 2019 00:19:30 -0800 (PST) Received: from glados.lan ([2601:647:4c01:6541:fa16:54ff:fed1:1bd6]) by smtp.gmail.com with ESMTPSA id u2sm23810375pgc.19.2019.12.09.00.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 00:19:29 -0800 (PST) From: Thomas Hebb To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Thomas Hebb , Masahiro Yamada Subject: [PATCH 4/4] kconfig: fix nesting of symbol help text Date: Mon, 9 Dec 2019 00:19:19 -0800 Message-Id: <4bbeef61f292caaeae4b555edf42820d113a4d4d.1575879069.git.tommyhebb@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org When we generate the help text of a symbol (e.g. when a user presses '?' in menuconfig), we do two things: 1. We iterate through every prompt that belongs to that symbol, printing its text and its location in the menu tree. 2. We print symbol-wide information that's not linked to a particular prompt, such as what it selects/is selected by and what it implies/is implied by. Each prompt we print for 1 starts with a line that's not indented indicating where the prompt is defined, then continues with indented lines that describe properties of that particular definition. Once we get to 2, however, we print all the global data indented as well! Visually, this makes it look like the symbol-wide data is associated with the last prompt we happened to print rather than the symbol as a whole. Fix this by removing the indentation for symbol-wide information. Before: Symbol: CPU_FREQ [=n] Type : bool Defined with prompt at drivers/cpufreq/Kconfig:4 Prompt: CPU Frequency scaling Location: -> CPU Power Management -> CPU Frequency scaling Selects: SRCU [=n] Selected by [n]: - ARCH_SA1100 [=n] && After: Symbol: CPU_FREQ [=n] Type : bool Defined with prompt at drivers/cpufreq/Kconfig:4 Prompt: CPU Frequency scaling Location: -> CPU Power Management -> CPU Frequency scaling Selects: SRCU [=n] Selected by [n]: - ARCH_SA1100 [=n] && Signed-off-by: Thomas Hebb --- scripts/kconfig/menu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 4d0542875d70..25d836aa60fc 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -831,18 +831,18 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, } } - get_symbol_props_str(r, sym, P_SELECT, " Selects: "); + get_symbol_props_str(r, sym, P_SELECT, "Selects: "); if (sym->rev_dep.expr) { - expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n"); - expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n"); - expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, "Selected by [y]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, "Selected by [m]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, no, "Selected by [n]:\n"); } - get_symbol_props_str(r, sym, P_IMPLY, " Implies: "); + get_symbol_props_str(r, sym, P_IMPLY, "Implies: "); if (sym->implied.expr) { - expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n"); - expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n"); - expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, yes, "Implied by [y]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, mod, "Implied by [m]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, no, "Implied by [n]:\n"); } str_append(r, "\n\n");