From patchwork Tue Jan 31 15:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1734953 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=UCDjLhZT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5pwG07b1z23gV for ; Wed, 1 Feb 2023 02:33:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 73A2285B3E; Tue, 31 Jan 2023 16:29:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UCDjLhZT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ACAA385AFA; Tue, 31 Jan 2023 16:28:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E477385AF0 for ; Tue, 31 Jan 2023 16:28:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id i17so6456858ils.11 for ; Tue, 31 Jan 2023 07:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xl49c+wcaUWI8k03WlrDXYXN4QHhBIqnehFOLi1M5NA=; b=UCDjLhZTCTyUPLFDlgx+2b/BlTcfE/8/7Q1vcmG1I2QcbjGrs+gXOi6DaGVZbOTxS7 OAktGvTzSYOl8VszxklNp4z3BiTVL2JgjcPSxowhFFSILq5WNrejpKbES0D+Sr0sZ+KB x9jyxIvdObbt6BzmR7pXpyycb0uXKdgbgYpSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xl49c+wcaUWI8k03WlrDXYXN4QHhBIqnehFOLi1M5NA=; b=Gm6ZO0Lem5KHqSig9fyBREtHkJvFe1F1g+ylherPwO/yVoQWrZKmE1zeL/BEiit7av Bs72o8LwqxB2BwnIx6hrpj/Jm2n+RsE/y1OHVfHffNg4dquW/NKpp9R3AThLeAYjmmB4 FHUdMj5ModdD4i29dGuE0UM2apWE9f0jSZ9eOkwNAUW24xYbET030M82aN5hhB4bTTO+ dXjuIscXjdq/eA5K5Wh8bMFHjRdUHTM56LaYSoQTu+H2TB2h+GlvrpG4/uqSf9PWKskD kYiHEd+ycSa25dJgvFskFJDvjdGdLFshyp1KycyX3uUAySr6J8qBqtfRIRaRYEMQ8LhG kd0Q== X-Gm-Message-State: AO0yUKVIIj34HZLO5Kx7O6xQmE0VE6ykwk4n/el8PIQMVrE3LdkcTfQs tGnI1g2p6UHpriBA4nyYT2OJ+MkLCKhIDSJG X-Google-Smtp-Source: AK7set9LYft8w9WhPsI/5KSdbt+Py3nwxDDBJudPhtTglpjXmMzpyvRULSTnF4gX+0/5S2rngV9e5A== X-Received: by 2002:a05:6e02:12c5:b0:310:a5b8:5050 with SMTP id i5-20020a056e0212c500b00310a5b85050mr18001433ilm.22.1675178881134; Tue, 31 Jan 2023 07:28:01 -0800 (PST) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id u4-20020a02cb84000000b0039db6cffcbasm5649328jap.71.2023.01.31.07.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:28:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH 26/32] kconfig: Adjust the meaning of CONFIG_IS_ENABLED() Date: Tue, 31 Jan 2023 08:26:56 -0700 Message-Id: <20230131152702.249197-27-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230131152702.249197-1-sjg@chromium.org> References: <20230131152702.249197-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Adjust this to require the CONFIG option be provided, so that instead of: CONFIG_IS_ENABLED(FOO) you must write: CONFIG_IS_ENABLED(CONFIG_FOO) This is in preparation for dropping this and just using it is as the new implementation of IS_ENABLED(). For now, update IS_ENABLED() to use CONFIG_IS_ENABLED(), so we can rely on the three-argument version. Signed-off-by: Simon Glass --- arch/x86/lib/fsp/fsp_dram.c | 2 +- board/st/stm32mp1/stm32mp1.c | 2 +- drivers/fastboot/fb_command.c | 16 ++++++++-------- include/linux/kconfig.h | 34 ++++++++++++---------------------- test/dm/ofnode.c | 2 +- test/lib/kconfig.c | 6 +++--- test/lib/kconfig_spl.c | 4 ++-- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index db4e3ff5fa2..13e89d41727 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -152,7 +152,7 @@ unsigned int install_e820_map(unsigned int max_entries, if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) { ulong stack_size; - stack_size = CONFIG_IS_ENABLED(HAVE_ACPI_RESUME, + stack_size = IS_ENABLED(CONFIG_HAVE_ACPI_RESUME, (CONFIG_STACK_SIZE_RESUME), (0)); /* * Everything between U-Boot's stack and ram top needs to be diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 0ffcca419f2..6dd44396185 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -903,7 +903,7 @@ const char *env_ext4_get_dev_part(void) int mmc_get_env_dev(void) { - const int mmc_env_dev = CONFIG_IS_ENABLED(ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1)); + const int mmc_env_dev = IS_ENABLED(CONFIG_ENV_IS_IN_MMC, (CONFIG_SYS_MMC_ENV_DEV), (-1)); if (mmc_env_dev >= 0) return mmc_env_dev; diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 71cfaec6e9d..3a5e29861a2 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -56,11 +56,11 @@ static const struct { }, [FASTBOOT_COMMAND_FLASH] = { .command = "flash", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (flash), (NULL)) }, [FASTBOOT_COMMAND_ERASE] = { .command = "erase", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_FLASH, (erase), (NULL)) }, [FASTBOOT_COMMAND_BOOT] = { .command = "boot", @@ -92,27 +92,27 @@ static const struct { }, [FASTBOOT_COMMAND_OEM_FORMAT] = { .command = "oem format", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL)) }, [FASTBOOT_COMMAND_OEM_PARTCONF] = { .command = "oem partconf", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL)) }, [FASTBOOT_COMMAND_OEM_BOOTBUS] = { .command = "oem bootbus", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL)) }, [FASTBOOT_COMMAND_OEM_RUN] = { .command = "oem run", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_OEM_RUN, (run_ucmd), (NULL)) }, [FASTBOOT_COMMAND_UCMD] = { .command = "UCmd", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL)) }, [FASTBOOT_COMMAND_ACMD] = { .command = "ACmd", - .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL)) + .dispatch = IS_ENABLED(CONFIG_FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL)) }, }; diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index f00686eb3e1..57d5afc7a1a 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -32,12 +32,6 @@ #define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 1, def_val) #define ___config_enabled(__ignored, val, ...) val -/* - * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', - * 0 otherwise. - */ -#define IS_ENABLED(option) config_enabled(option, 0) - #define __config_val(cfg) CONFIG_ ## cfg #define CONFIG_VAL(option) __config_val(option) @@ -83,34 +77,30 @@ long invalid_use_of_IF_ENABLED_INT(void); #define __CONFIG_IS_ENABLED_1(option) __CONFIG_IS_ENABLED_3(option, (1), (0)) #define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, case1, ()) #define __CONFIG_IS_ENABLED_3(option, case1, case0) \ - __concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0) + __concat(__unwrap, config_enabled(option, 0)) (case1, case0) /* - * CONFIG_IS_ENABLED(FOO) returns 1 if CONFIG_FOO is enabled for the phase being - * built, else 0. Note that CONFIG_FOO corresponds to CONFIG_SPL_FOO (in - * Kconfig) for the SPL phase, CONFIG_TPL_FOO for the TPL phase, etc. - * - * The _nospl version of a CONFIG is emitted by kconfig when an option has no - * SPL equivalent. So in that case there is a CONFIG_xxx for example, but not a - * CONFIG_SPL_xxx - * - * This is needed as a transition measure while CONFIG_IS_ENABLED() is used on - * options without SPL equivalent, since in that case it should always return - * zero. Once we add SPL equivalents, this clause can be dropped. + * CONFIG_IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the + * phase being built, else 0. * * The optional second and third arguments must be parenthesized; that * allows one to include a trailing comma, e.g. for use in * - * CONFIG_IS_ENABLED(ACME, ({.compatible = "acme,frobnozzle"},)) + * CONFIG_IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},)) * - * which adds an entry to the array being defined if CONFIG_ACME (or - * CONFIG_SPL_ACME/CONFIG_TPL_ACME, depending on build context) is + * which adds an entry to the array being defined if CONFIG_ACME is * set, and nothing otherwise. */ #define CONFIG_IS_ENABLED(option, ...) \ __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__) +/* + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', + * 0 otherwise. + */ +#define IS_ENABLED(option, ...) CONFIG_IS_ENABLED(option, ##__VA_ARGS__) + #ifndef __ASSEMBLY__ /* * Detect usage of a the value when the conditional is not enabled. When used @@ -125,7 +115,7 @@ long invalid_use_of_CONFIG_IF_ENABLED_INT(void); * otherwise build error */ #define CONFIG_IF_ENABLED_INT(option, int_option) \ - CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \ + CONFIG_IS_ENABLED(option, (int_option), \ (invalid_use_of_CONFIG_IF_ENABLED_INT())) #define CONFIG_IF_INT(option, int_option) \ diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 8077affabb7..8aec458c3c5 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1148,7 +1148,7 @@ DM_TEST(dm_test_ofnode_get_name, UT_TESTF_SCAN_FDT); /* try to access more FDTs than is supported */ static int dm_test_ofnode_too_many(struct unit_test_state *uts) { - const int max_trees = CONFIG_IS_ENABLED(OFNODE_MULTI_TREE, + const int max_trees = IS_ENABLED(CONFIG_OFNODE_MULTI_TREE, (CONFIG_OFNODE_MULTI_TREE_MAX), (1)); const int fdt_size = 256; const int num_trees = max_trees + 1; diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c index 8fb6422c905..029a2be8cd9 100644 --- a/test/lib/kconfig.c +++ b/test/lib/kconfig.c @@ -25,7 +25,7 @@ static int lib_test_is_enabled(struct unit_test_state *uts) ut_asserteq(0xc000, IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); ut_asserteq(0xc000, - CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR)); + CONFIG_IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); /* * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the @@ -48,8 +48,8 @@ static int lib_test_is_enabled(struct unit_test_state *uts) */ if (!IS_ENABLED(CONFIG_SANDBOX_SPL) && IS_ENABLED(CONFIG_TEST_KCONFIG)) { - val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, - TEST_KCONFIG_VALUE); + val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, + CONFIG_TEST_KCONFIG_VALUE); printf("value2 %ld\n", val); } diff --git a/test/lib/kconfig_spl.c b/test/lib/kconfig_spl.c index 5c66183dc3d..2894a03f1e8 100644 --- a/test/lib/kconfig_spl.c +++ b/test/lib/kconfig_spl.c @@ -34,8 +34,8 @@ static int lib_test_spl_is_enabled(struct unit_test_state *uts) * value is used. */ if (IS_ENABLED(CONFIG_TEST_KCONFIG)) { - val = CONFIG_IF_ENABLED_INT(TEST_KCONFIG_ENABLE, - TEST_KCONFIG_VALUE); + val = CONFIG_IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE, + CONFIG_TEST_KCONFIG_VALUE); printf("value2 %ld\n", val); }