From: Randy Dunlap <rdunlap@infradead.org>
To: Graham Roff <grahamr@qti.qualcomm.com>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>, Jonathan Corbet <corbet@lwn.net>
Cc: linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, Nicolas Pitre <nico@fluxnic.net>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3] kconfig: Support conditional deps using "depends on X if Y"
Date: Sun, 4 Jan 2026 14:49:33 -0800 [thread overview]
Message-ID: <e99afc0e-e0a2-4719-9c04-4fa8fcafb4f0@infradead.org> (raw)
In-Reply-To: <20251215-kconfig_conditional_deps-v3-1-59519af0a5df@qti.qualcomm.com>
On 12/15/25 3:06 PM, Graham Roff wrote:
> From: Nicolas Pitre <nico@fluxnic.net>
>
> Extend the "depends on" syntax to support conditional dependencies
> using "depends on X if Y". While functionally equivalent to "depends
> on X || (Y == n)", "depends on X if Y" is much more readable and
> makes the kconfig language uniform in supporting the "if <expr>"
> suffix.
> This also improves readability for "optional" dependencies, which
> are the subset of conditional dependencies where X is Y.
> Previously such optional dependencies had to be expressed as
> the counterintuitive "depends on X || !X", now this can be
> represented as "depends on X if X".
>
> The change is implemented by converting the "X if Y" syntax into the
> "X || (Y == n)" syntax during "depends on" token processing.
>
> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
>
> [Graham Roff: Rewrote commit message, updated patch, added tests]
>
> Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
LGTM. Thanks.
Acked-by: Randy Dunlap <rdunlap@infradead.org>
> ---
> This patch updates an earlier one that was not merged to work on
> the latest kernel release.
>
> Link: https://lwn.net/ml/linux-kernel/nycvar.YSQ.7.76.2004231102480.2671@knanqh.ubzr/#t
>
> Support for this change has been expressed by a number of developers
> since the original patch was proposed back in 2020, and has recently
> also been raised as a patch to the Zephyr kconfig system.
> One specific use is when mapping the Bluetooth specification to Kconfig,
> as it explicitly provides dependencies between features as conditional
> on other features. Many other cases exist where the "slightly
> counterintuitive" (quoted from the Kconfig specification) expression
> "depends on BAR || !BAR" has been used when a proper "if" condition
> would be more readable. Some examples:
>
> arch/arm64/Kconfig:
> depends on ARM64_64K_PAGES || !ARM64_VA_BITS_52 -->
> depends on ARM64_64K_PAGES if ARM64_VA_BITS_52
> arch/mips/Kconfig:
> depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP -->
> depends on SYS_SUPPORTS_HOTPLUG_CPU if SMP
> arch/riscv/Kconfig:
> depends on CC_HAS_MIN_FUNCTION_ALIGNMENT || !RISCV_ISA_C -->
> depends on CC_HAS_MIN_FUNCTION_ALIGNMENT if RISCV_ISA_C
> arch/x86/Kconfig:
> depends on X86_64 || !SPARSEMEM -->
> depends on X86_64 if SPARSEMEM
> drivers/acpi/Kconfig:
> depends on ACPI_WMI || !X86 -->
> depends on ACPI_WMI if X86
> drivers/bluetooth/Kconfig:
> depends on USB || !BT_HCIBTUSB_MTK
> depends on USB if BT_HCIBTUSB_MTK
> mm/Kconfig:
> depends on !ARM || CPU_CACHE_VIPT -->
> depends on CPU_CACHE_VIPT if ARM
> kernel/Kconfig.locks:
> depends on !PREEMPTION || ARCH_INLINE_READ_UNLOCK -->
> depends on ARCH_INLINE_READ_UNLOCK if PREEMPTION
>
> The earlier patch discussion ended without a real conclusion and should
> be revisited now.
> ---
> Changes in v3:
> - Updated commit to prefix with "kconfig:".
> - Updated tests to support modules for tri_state configs.
> - Link to v2: https://lore.kernel.org/r/20251118-kconfig_conditional_deps-v2-1-e360792edaed@qti.qualcomm.com
>
> Changes in v2:
> - Added test cases.
> - Updated documentation to improve the dscription of conditional
> and optional dependencies
> - Link to v1: https://lore.kernel.org/r/20251107-kconfig_conditional_deps-v1-1-aff22199ec0b@qti.qualcomm.com
> ---
> Documentation/kbuild/kconfig-language.rst | 22 +++++++++++++--
> scripts/kconfig/lkc.h | 2 +-
> scripts/kconfig/menu.c | 12 +++++++-
> scripts/kconfig/parser.y | 6 ++--
> scripts/kconfig/tests/conditional_dep/Kconfig | 32 ++++++++++++++++++++++
> scripts/kconfig/tests/conditional_dep/__init__.py | 14 ++++++++++
> .../kconfig/tests/conditional_dep/expected_config1 | 11 ++++++++
> .../kconfig/tests/conditional_dep/expected_config2 | 9 ++++++
> .../kconfig/tests/conditional_dep/expected_config3 | 11 ++++++++
> scripts/kconfig/tests/conditional_dep/test_config1 | 6 ++++
> scripts/kconfig/tests/conditional_dep/test_config2 | 7 +++++
> scripts/kconfig/tests/conditional_dep/test_config3 | 6 ++++
> 12 files changed, 130 insertions(+), 8 deletions(-)
--
~Randy
next prev parent reply other threads:[~2026-01-04 22:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 23:06 [PATCH v3] kconfig: Support conditional deps using "depends on X if Y" Graham Roff
2025-12-19 19:56 ` Nathan Chancellor
2026-01-04 22:49 ` Randy Dunlap [this message]
2026-01-06 22:06 ` Nathan Chancellor
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=e99afc0e-e0a2-4719-9c04-4fa8fcafb4f0@infradead.org \
--to=rdunlap@infradead.org \
--cc=arnd@arndb.de \
--cc=corbet@lwn.net \
--cc=grahamr@qti.qualcomm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nico@fluxnic.net \
--cc=nsc@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox