Re: [PATCH v3] kconfig: Support conditional deps using "depends on X if Y"

"Arnd Bergmann" <[email protected]> Sat, 04 Jul 2026 17:33:16 +0200
Newsgroups gmane.linux.kbuild.devel,gmane.linux.documentation,gmane.linux.kernel
Message-ID <[email protected]>
On Sat, Jul 4, 2026, at 15:23, Julian Braha wrote:
> On 12/15/25 23:06, Graham Roff wrote:
>> 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".
>
> I have always found both of these:
> 'depends on X || !X'
> and:
> 'depends on X if X'
>
> to be unintuitive and confusing to read.
>
> Yes, I understand from the docs that the purpose is to disallow
> FOO=Y with BAR=M, like in this example from the official kconfig docs:
> ```
> config FOO
>       tristate "Support for foo hardware"
>       depends on BAR if BAR
> ```
>
> However, in my testing, neither of these constructs are necessary to
> achieve that.
>
> A very standard 'depends on BAR' also disallows FOO=Y with BAR=M.

The difference is that a plain 'depends on BAR' does not
allow FOO=m with BAR=n. The idea of the construct is that
BAR is optional, but whenever BAR is enabled (m or y) it is
a dependency.

Specifically we need to allow all of

  BAR=n FOO=n
  BAR=n FOO=m
  BAR=n FOO=y
  BAR=m FOO=n
  BAR=m FOO=m
  BAR=y FOO=n
  BAR=y FOO=m
  BAR=y FOO=y

just not BAR=m FOO=y.

     Arnd