lkml.org 
[lkml]   [2020]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] if_enabled.h: Add IF_ENABLED_OR_ELSE() and IF_ENABLED() macros
Hi Linus,

Le mer. 9 déc. 2020 à 9:59, Linus Walleij <linus.walleij@linaro.org>
a écrit :
> On Tue, Dec 8, 2020 at 5:48 PM Paul Cercueil <paul@crapouillou.net>
> wrote:
>
>> Introduce a new header <linux/if_enabled.h>, that brings two new
>> macros:
>> IF_ENABLED_OR_ELSE() and IF_ENABLED().
>
> I understand what the patch is trying to do, but when we already have
> IS_ENABLED() in <linux/kconfig.h> this syntax becomes a big cognitive
> confusion for the mind.
>
> At least the commit needs to explain why it doesn't work to use
> IS_ENABLED() instead so that this is needed.

You can use IS_ENABLED(). Then you'd write:

field = IS_ENABLED(CONFIG_FOO) ? &my_ptr : NULL,

the IF_ENABLED() macro makes it a bit cleaner by allowing you to write:

field = IF_ENABLED(CONFIG_FOO, &my_ptr),

Cheers,
-Paul

> Certainly the build failures must be possible to solve so that this
> can live with the sibling IS_ENABLED() inside <linux/kconfig.h>,
> it can't be too hard.
>
> Yours,
> Linus Walleij


\
 
 \ /
  Last update: 2020-12-09 12:36    [W:0.863 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site