Commit 0ab1438b authored by Masahiro Yamada's avatar Masahiro Yamada

linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h>

<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.

Also, <linux/kconfig.h> is no longer self-contained because NULL is
defined in <linux/stddef.h>.

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: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
parent 51eb95e2
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
...@@ -3854,6 +3855,8 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev) ...@@ -3854,6 +3855,8 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
return 0; return 0;
} }
#define IF_ENABLED(cfg, ptr) PTR_IF(IS_ENABLED(cfg), (ptr))
static const struct of_device_id ingenic_pinctrl_of_match[] = { static const struct of_device_id ingenic_pinctrl_of_match[] = {
{ {
.compatible = "ingenic,jz4730-pinctrl", .compatible = "ingenic,jz4730-pinctrl",
......
...@@ -70,10 +70,4 @@ ...@@ -70,10 +70,4 @@
*/ */
#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
/*
* IF_ENABLED(CONFIG_FOO, ptr) evaluates to (ptr) if CONFIG_FOO is set to 'y'
* or 'm', NULL otherwise.
*/
#define IF_ENABLED(option, ptr) (IS_ENABLED(option) ? (ptr) : NULL)
#endif /* __LINUX_KCONFIG_H */ #endif /* __LINUX_KCONFIG_H */
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
*/ */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL)
#define u64_to_user_ptr(x) ( \ #define u64_to_user_ptr(x) ( \
{ \ { \
typecheck(u64, (x)); \ typecheck(u64, (x)); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment