[RFC PATCH 4/4] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED

Simon Glass sjg at google.com
Fri Jul 3 18:22:17 CEST 2020


Hi,

On Tue, 16 Jun 2020 at 17:31, Simon Glass <sjg at google.com> wrote:
>
> Hi Rasmus,
>
> On Fri, 12 Jun 2020 at 05:02, Rasmus Villemoes
> <rasmus.villemoes at prevas.dk> wrote:
> >
> > This adds a bunch of preprocessor magic to extend the capabilities of
> > CONFIG_IS_ENABLED. The existing semantics of
> >
> >   CONFIG_IS_ENABLED(FOO)
> >
> > expanding to a 1 or 0 (depending on build context and the defined-ness
> > or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
> > are of course preserved. With this, one is also allowed a two-argument
> > form
> >
> >   CONFIG_IS_ENABLED(FOO, (something))
> >
> > which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
> > expand to 1, and expands to nothing otherwise. It is, in other words,
> > completely equivalent to the three lines
> >
> >   #if CONFIG_IS_ENABLED(FOO)
> >   something
> >   #endif
> >
> > The second argument must be parenthesized in order to allow any
> > tokens, including a trailing comma, to appear - one use case for this
> > is precisely to make it a bit more ergonomic to build an array and
> > only include certain items depending on .config. That should increase
> > both readability and not least "git grep"ability.
> >
> > A third variant is also introduced,
> >
> >   CONFIG_IS_ENABLED(FOO, (xxx), (yyy))
> >
> > which corresponds to
> >
> >   #if CONFIG_IS_ENABLED(FOO)
> >   xxx
> >   #else
> >   yyy
> >   #endif
> >
> > Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> > ---
> >  include/linux/kconfig.h | 48 ++++++++++++++++++++++++++++++++++++++---
> >  1 file changed, 45 insertions(+), 3 deletions(-)
>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> See also this:
>
> http://patchwork.ozlabs.org/project/uboot/patch/20200522020223.230834-2-sjg@chromium.org/
>
> but I think your idea is a lot nicer.

I'd like to pick up these three Kconfig patches for dm/next. Any objection?

Regards,
SImon


More information about the U-Boot mailing list