From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Arnd Bergmann <arnd@arndb.de>,
"Guilherme G. Piccoli" <gpiccoli@canonical.com>,
Kars Mulder <kerneldev@karsmulder.nl>,
Kees Cook <keescook@chromium.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Linus Walleij <linus.walleij@linaro.org>,
Paul Cercueil <paul@crapouillou.net>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>, chao <chao@eero.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mips@vger.kernel.org
Subject: Re: [PATCH v2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h>
Date: Sat, 8 May 2021 11:59:43 +1000 [thread overview]
Message-ID: <20210508115943.5dbf76f2@canb.auug.org.au> (raw)
In-Reply-To: <20210505174515.87565-1-masahiroy@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2691 bytes --]
Hi Masahiro,
On Thu, 6 May 2021 02:45:15 +0900 Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> <linux/kconfig.h> is included from all the kernel-space source files,
> including C, assembly, linker scripts. It is intended to contain a
> minimal set of macros to evaluate CONFIG options.
>
> IF_ENABLED() is an intruder here because (x ? y : z) is C code, which
> should not be included from assembly files or linker scripts.
Except it doesn't matter unless IF_ENABLED() is used by one of those.
> Also, <linux/kconfig.h> is no longer self-contained because NULL is
> defined in <linux/stddef.h>.
Again, it doesn't matter unless IF_ENABLED() is used.
> Move IF_ENABLED() out to <linux/kernel.h> as PTR_IF(). PTF_IF()
> takes the general boolean expression instead of a CONFIG option
> so that it fits better in <linux/kernel.h>.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v2:
> - Keep PTF_IF macro in pinctrl-ingenic.c
>
> drivers/pinctrl/pinctrl-ingenic.c | 2 ++
> include/linux/kconfig.h | 6 ------
> include/linux/kernel.h | 2 ++
> 3 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
> index 651a36b9dcc0..0ee69f8e20b2 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -3854,6 +3854,8 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
> return 0;
> }
>
> +#define IF_ENABLED(cfg, ptr) PTR_IF(IS_ENABLED(cfg), (ptr))
> +
> static const struct of_device_id ingenic_pinctrl_of_match[] = {
> {
> .compatible = "ingenic,jz4730-pinctrl",
You also need to include linux/kernel.h in
drivers/pinctrl/pinctrl-ingenic.c (for completeness).
Also, I don't understand why the use of IF_ENABLED doesn't produce
"defined but not used" warnings (if the function "ptr" is not marked as
__maybe_unused) ...
Also, if there is only one user of IF_ENABLED (and therefore PTR_IF),
why not just put it in that file and save me rebuilding the world again
every day because kernel.h is changed (again). I guess that is going
to happen just because kconfig.h is being changed and that is also
included by everything :-(
Also, is anyone else ever going to use PTR_IF() without having to also
use IS_ENABLED()?
So, in case it is not obvious, I consider this patch unnecessary churn
(as was probably the patch that introduced IF_ENABLED in the first
place).
As an aside, this should not have been added to the kbuild tree in
linux-next until after -rc1 was released ...
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-05-08 2:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 17:45 [PATCH v2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h> Masahiro Yamada
2021-05-05 21:09 ` Kees Cook
2021-05-08 1:59 ` Stephen Rothwell [this message]
2021-05-08 4:23 ` Masahiro Yamada
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=20210508115943.5dbf76f2@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=chao@eero.com \
--cc=gpiccoli@canonical.com \
--cc=keescook@chromium.org \
--cc=kerneldev@karsmulder.nl \
--cc=kishon@ti.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=paul@crapouillou.net \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).