From patchwork Mon Feb 6 19:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1738420 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=85.214.62.61; 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=ZddafYan; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4P9bmL1Jbgz23r8 for ; Tue, 7 Feb 2023 06:24:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4BDAA857AD; Mon, 6 Feb 2023 20:16:58 +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="ZddafYan"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD9B885772; Mon, 6 Feb 2023 20:10:51 +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-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 B7DCF85CCB for ; Mon, 6 Feb 2023 20:10:20 +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-io1-xd32.google.com with SMTP id e2so4810915iot.11 for ; Mon, 06 Feb 2023 11:10:20 -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=tnv4JvUCkf8CT1ujsuynutPHTxzd5wJjKw7ciozNpRM=; b=ZddafYanIjnim2usBA71CqvEakLU3kHxIJZ3O2ImEZnAe85SdF4oRHeQ4lIbuJg7wm KfdnNHDzGJg03OxleIpSy/hi0c6zjpcjW/qNqL3g9LPKON4YGjzIhtT/KGmr2hol1Dm6 +bClTcB5B6aZ88GawCNfMBb+7apX0X1+nB7ds= 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=tnv4JvUCkf8CT1ujsuynutPHTxzd5wJjKw7ciozNpRM=; b=WxZ1IH2jPaU4wJpf989tED+YprzccoXlWVLoQpZhaepwrpAnoX8S3jMUEoiGejt7Np ir/zNkV040jbHInA9ZjYChXEbYry30p+PagakF5Rz25daApxGDa7qHPdzoxFGSn/1Edr dpcm0Unx9AW+3dsQ9Pvvb+u1RonmkjisUykRIZC6o3+lfDLv3xDXklUU9l6bcXelaBpL MP/Vhi65o1TC4rBGtrNF6yzMnRewWW/h/vpBvFLh+nQXIRgeu1645g4Jjk98leF3DLy/ O3qmUH1RFrYyrgaszTuhoLruyZyr6dsyhP6PKGJuvIaElYSK6ISV8yVFD2/RDp68fp5D OZDQ== X-Gm-Message-State: AO0yUKUx1jsOLNqmkkFHwmYo1Ekg6W5nxdrw1SbpOCJJPdagJGOSWYIU HeUIhiKuZPtxSIj4bg1jCOV+ZzPFx941UApb X-Google-Smtp-Source: AK7set+ZihluabGUpwphJWfFjAngPJiw26ixt3+xm+KLefH1Fk3jYEZF8FQnHc5aLZ4UrUUf+0dU3w== X-Received: by 2002:a6b:5403:0:b0:704:bc96:24bd with SMTP id i3-20020a6b5403000000b00704bc9624bdmr78895iob.19.1675710590163; Mon, 06 Feb 2023 11:09:50 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:34e9:6977:1cac:fd32]) by smtp.gmail.com with ESMTPSA id t24-20020a028798000000b00375a885f908sm749878jai.36.2023.02.06.11.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 11:09:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH v3 72/81] kconfig: Adjust the meaning of CONFIG_IS_ENABLED() Date: Mon, 6 Feb 2023 12:05:40 -0700 Message-Id: <20230206190550.1692420-73-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230206190550.1692420-1-sjg@chromium.org> References: <20230206190550.1692420-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 --- (no changes since v1) arch/x86/lib/fsp/fsp_dram.c | 4 ++-- 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, 29 insertions(+), 39 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index db4e3ff5fa2..f46c6cdbc2e 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -152,8 +152,8 @@ 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, - (CONFIG_STACK_SIZE_RESUME), (0)); + 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 * reserved in order for ACPI S3 resume to work. diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 822edf55f0e..58bc12fcb63 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); }