All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Subject: [PATCH 23/32] kconfig: Update CONFIG_IS_ENABLED() for split files
Date: Tue, 31 Jan 2023 08:26:53 -0700	[thread overview]
Message-ID: <20230131152702.249197-24-sjg@chromium.org> (raw)
In-Reply-To: <20230131152702.249197-1-sjg@chromium.org>

Update this file to include the correct autoconf.h or autoconf_spl.h file
for each phase. This allows the macros to be simplified.

With this, CONFIG_IS_ENABLED() is the same as IS_ENABLED() apart from a
migration detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/linux/kconfig.h                | 74 +++++++++-----------------
 tools/binman/test/generated/autoconf.h |  4 +-
 2 files changed, 28 insertions(+), 50 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..f00686eb3e1 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -1,7 +1,17 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
+#ifdef USE_HOSTCC
+#include <generated/autoconf_tools.h>
+#elif defined(CONFIG_TPL_BUILD)
+#include <generated/autoconf_tpl.h>
+#elif defined(CONFIG_VPL_BUILD)
+#include <generated/autoconf_vpl.h>
+#elif defined(CONFIG_SPL_BUILD)
+#include <generated/autoconf_spl.h>
+#else
 #include <generated/autoconf.h>
+#endif
 
 /*
  * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
@@ -28,37 +38,9 @@
  */
 #define IS_ENABLED(option)	config_enabled(option, 0)
 
-/*
- * U-Boot add-on: Helper macros to reference to different macros (prefixed by
- * CONFIG_, CONFIG_SPL_, CONFIG_TPL_ or CONFIG_TOOLS_), depending on the build
- * context.
- */
+#define __config_val(cfg) CONFIG_ ## cfg
 
-#ifdef USE_HOSTCC
-#define _CONFIG_PREFIX TOOLS_
-#elif defined(CONFIG_TPL_BUILD)
-#define _CONFIG_PREFIX TPL_
-#elif defined(CONFIG_VPL_BUILD)
-#define _CONFIG_PREFIX VPL_
-#elif defined(CONFIG_SPL_BUILD)
-#define _CONFIG_PREFIX SPL_
-#else
-#define _CONFIG_PREFIX
-#endif
-
-#define   config_val(cfg)       _config_val(_CONFIG_PREFIX, cfg)
-#define  _config_val(pfx, cfg) __config_val(pfx, cfg)
-#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg
-
-/*
- * CONFIG_VAL(FOO) evaluates to the value of
- *  CONFIG_TOOLS_FOO if USE_HOSTCC is defined,
- *  CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
- *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
- *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
- *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
- */
-#define CONFIG_VAL(option)  config_val(option)
+#define CONFIG_VAL(option)  __config_val(option)
 
 /*
  * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
@@ -104,26 +86,17 @@ long invalid_use_of_IF_ENABLED_INT(void);
 	__concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0)
 
 /*
- * CONFIG_IS_ENABLED(FOO) expands to
- *  1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  0 otherwise.
+ * 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.
  *
- * CONFIG_IS_ENABLED(FOO, (abc)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  nothing otherwise.
+ * 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
  *
- * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  def otherwise.
+ * 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.
  *
  * The optional second and third arguments must be parenthesized; that
  * allows one to include a trailing comma, e.g. for use in
@@ -135,7 +108,7 @@ long invalid_use_of_IF_ENABLED_INT(void);
  * set, and nothing otherwise.
  */
 
-#define CONFIG_IS_ENABLED(option, ...)					\
+#define CONFIG_IS_ENABLED(option, ...) \
 	__concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__)
 
 #ifndef __ASSEMBLY__
@@ -155,4 +128,7 @@ long invalid_use_of_CONFIG_IF_ENABLED_INT(void);
 	CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \
 		(invalid_use_of_CONFIG_IF_ENABLED_INT()))
 
+#define CONFIG_IF_INT(option, int_option) \
+	CONFIG_IF_ENABLED_INT(option, int_option)
+
 #endif /* __LINUX_KCONFIG_H */
diff --git a/tools/binman/test/generated/autoconf.h b/tools/binman/test/generated/autoconf.h
index 6a23039f469..88dc762c423 100644
--- a/tools/binman/test/generated/autoconf.h
+++ b/tools/binman/test/generated/autoconf.h
@@ -1,3 +1,5 @@
 #define CONFIG_BINMAN 1
 #define CONFIG_SPL_BUILD 1
-#define CONFIG_SPL_BINMAN_SYMBOLS 1
+
+/* Don't include the SPL_ here since we are using separate autoconf files */
+#define CONFIG_BINMAN_SYMBOLS 1
-- 
2.39.1.456.gfc5497dd1b-goog


  parent reply	other threads:[~2023-01-31 15:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 15:26 [PATCH 00/32] RFC: Migrate to split config Simon Glass
2023-01-31 15:26 ` [PATCH 01/32] fixup: Bugfix for moveconfig Simon Glass
2023-01-31 15:26 ` [PATCH 02/32] event: Add Kconfig options for SPL Simon Glass
2023-01-31 15:26 ` [PATCH 03/32] bootstd: " Simon Glass
2023-01-31 15:26 ` [PATCH 04/32] cmd: Add an SPL Kconfig for CMDLINE and HUSH Simon Glass
2023-01-31 15:26 ` [PATCH 05/32] boot: Add a Kconfig for SPL_QCOM_PMIC_GPIO Simon Glass
2023-01-31 15:26 ` [PATCH 06/32] cros_ec: Add SPL Kconfigs for cros_ec features Simon Glass
2023-01-31 15:26 ` [PATCH 07/32] boot: Add a Kconfig for SPL_UT_COMPRESSION Simon Glass
2023-01-31 15:26 ` [PATCH 08/32] env: Avoid checking ENV_IS_IN when env disabled Simon Glass
2023-01-31 15:26 ` [PATCH 09/32] boot: Add a Kconfig for SPL_AVB_VERIFY Simon Glass
2023-01-31 15:26 ` [PATCH 10/32] env: Allow VPL environment to be nowhere Simon Glass
2023-01-31 15:26 ` [PATCH 11/32] lib: Add VPL options for SHA1 and SHA256 Simon Glass
2023-01-31 15:26 ` [PATCH 12/32] sandbox: Tidy up RTC options Simon Glass
2023-01-31 15:26 ` [PATCH 13/32] sandbox: Use the generic VPL option to enable VPL Simon Glass
2023-01-31 15:26 ` [PATCH 14/32] sandbox: Tidy up I2C options Simon Glass
2023-01-31 15:26 ` [PATCH 15/32] fixdep: Add support for VPL Simon Glass
2023-01-31 15:26 ` [PATCH 16/32] fixdep: Refactor to make testing easier Simon Glass
2023-01-31 15:26 ` [PATCH 17/32] fixdep: Add some tests for parse_config_line() Simon Glass
2023-01-31 15:26 ` [PATCH 18/32] test: Add SPL versions of the TEST_KCONFIG options Simon Glass
2023-01-31 15:26 ` [PATCH 19/32] kconfig: Add configuration files for noproper and nospl Simon Glass
2023-01-31 15:26 ` [PATCH 20/32] kconfig: Refactor code into separate writer functions Simon Glass
2023-01-31 15:26 ` [PATCH 21/32] kconfig: Support writing separate SPL files Simon Glass
2023-01-31 15:26 ` [PATCH 22/32] Makefile: Include the config for the phase being built Simon Glass
2023-01-31 15:26 ` Simon Glass [this message]
2023-01-31 15:26 ` [PATCH 24/32] Makefile: Use empty SPL_ and SPL_TPL_ vars Simon Glass
2023-01-31 15:26 ` [PATCH 25/32] Drop use of CONFIG_IS_ENABLED() Simon Glass
2023-01-31 15:26 ` [PATCH 26/32] kconfig: Adjust the meaning " Simon Glass
2023-01-31 15:26 ` [PATCH 27/32] kconfig: Drop CONFIG_IF_ENABLED_INT() Simon Glass
2023-01-31 15:26 ` [PATCH 28/32] kconfig: Drop CONFIG_IS_ENABLED() Simon Glass
2023-01-31 15:26 ` [PATCH 29/32] kconfig: drop config_opt_enabled() Simon Glass
2023-01-31 15:27 ` [PATCH 30/32] kconfig: Drop CONFIG_VAL() Simon Glass
2023-01-31 15:27 ` [PATCH 31/32] kconfig: Move closer to the Linux version Simon Glass
2023-01-31 15:27 ` [PATCH 32/32] Makefile: Drop SPL_ and SPL_TPL_ macros Simon Glass
2023-01-31 21:57 ` [PATCH 00/32] RFC: Migrate to split config Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230131152702.249197-24-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.