* [PATCH 2/5] export.h: use __is_defined() to check if __KSYM_* is defined
2016-06-14 5:58 [PATCH 1/5] kconfig.h: use __is_defined() to check if MODULE is defined Masahiro Yamada
@ 2016-06-14 5:58 ` Masahiro Yamada
2016-06-14 17:10 ` Nicolas Pitre
2016-06-14 5:58 ` [PATCH 3/5] kconfig.h: use already defined macros for IS_REACHABLE() define Masahiro Yamada
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-14 5:58 UTC (permalink / raw)
To: linux-kernel, Andrew Morton
Cc: Rusty Russell, Michal Simek, Linus Torvalds, Arnd Bergmann,
Michal Marek, Nicolas Pitre, Masahiro Yamada
Here the need is for a macro that checks whether the given symbol is
defined or not, which has nothing to do with config.
The new macro __is_defined() is a better fit for this case.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
include/linux/export.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/export.h b/include/linux/export.h
index 2f9ccbe..c565f87 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -82,7 +82,7 @@ extern struct module __this_module;
#include <generated/autoksyms.h>
#define __EXPORT_SYMBOL(sym, sec) \
- __cond_export_sym(sym, sec, config_enabled(__KSYM_##sym))
+ __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym))
#define __cond_export_sym(sym, sec, conf) \
___cond_export_sym(sym, sec, conf)
#define ___cond_export_sym(sym, sec, enabled) \
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] export.h: use __is_defined() to check if __KSYM_* is defined
2016-06-14 5:58 ` [PATCH 2/5] export.h: use __is_defined() to check if __KSYM_* " Masahiro Yamada
@ 2016-06-14 17:10 ` Nicolas Pitre
0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Pitre @ 2016-06-14 17:10 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kernel, Andrew Morton, Rusty Russell, Michal Simek,
Linus Torvalds, Arnd Bergmann, Michal Marek
On Tue, 14 Jun 2016, Masahiro Yamada wrote:
> Here the need is for a macro that checks whether the given symbol is
> defined or not, which has nothing to do with config.
>
> The new macro __is_defined() is a better fit for this case.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
>
> include/linux/export.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/export.h b/include/linux/export.h
> index 2f9ccbe..c565f87 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -82,7 +82,7 @@ extern struct module __this_module;
> #include <generated/autoksyms.h>
>
> #define __EXPORT_SYMBOL(sym, sec) \
> - __cond_export_sym(sym, sec, config_enabled(__KSYM_##sym))
> + __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym))
> #define __cond_export_sym(sym, sec, conf) \
> ___cond_export_sym(sym, sec, conf)
> #define ___cond_export_sym(sym, sec, enabled) \
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/5] kconfig.h: use already defined macros for IS_REACHABLE() define
2016-06-14 5:58 [PATCH 1/5] kconfig.h: use __is_defined() to check if MODULE is defined Masahiro Yamada
2016-06-14 5:58 ` [PATCH 2/5] export.h: use __is_defined() to check if __KSYM_* " Masahiro Yamada
@ 2016-06-14 5:58 ` Masahiro Yamada
2016-06-14 5:58 ` [PATCH 4/5] kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion Masahiro Yamada
2016-06-14 5:58 ` [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED() Masahiro Yamada
3 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-14 5:58 UTC (permalink / raw)
To: linux-kernel, Andrew Morton
Cc: Rusty Russell, Michal Simek, Linus Torvalds, Arnd Bergmann,
Michal Marek, Nicolas Pitre, Masahiro Yamada
For the same reason as commit 02d699f1f464 ("include/linux/kconfig.h:
ese macros which are already defined"), it is better to use macros
IS_BUILTIN() and IS_MODULE() for defining IS_REACHABLE().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
include/linux/kconfig.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a94b5bf..722c7d2 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -42,8 +42,8 @@
* This is similar to IS_ENABLED(), but returns false when invoked from
* built-in code when CONFIG_FOO is set to 'm'.
*/
-#define IS_REACHABLE(option) (config_enabled(option) || \
- (config_enabled(option##_MODULE) && __is_defined(MODULE)))
+#define IS_REACHABLE(option) (IS_BUILTIN(option) || \
+ (IS_MODULE(option) && __is_defined(MODULE)))
/*
* IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion
2016-06-14 5:58 [PATCH 1/5] kconfig.h: use __is_defined() to check if MODULE is defined Masahiro Yamada
2016-06-14 5:58 ` [PATCH 2/5] export.h: use __is_defined() to check if __KSYM_* " Masahiro Yamada
2016-06-14 5:58 ` [PATCH 3/5] kconfig.h: use already defined macros for IS_REACHABLE() define Masahiro Yamada
@ 2016-06-14 5:58 ` Masahiro Yamada
2016-06-14 5:58 ` [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED() Masahiro Yamada
3 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-14 5:58 UTC (permalink / raw)
To: linux-kernel, Andrew Morton
Cc: Rusty Russell, Michal Simek, Linus Torvalds, Arnd Bergmann,
Michal Marek, Nicolas Pitre, Masahiro Yamada
The typical usage of IS_ENABLED() is
if (IS_ENABLED(CONFIG_FOO)) {
...
}
or
#if IS_ENABLED(CONFIG_FOO)
...
#endif
The current implementation of IS_ENABLED() includes "||" operator,
which works well in those expressions like above.
However, there is a case where we want to evaluate a config option
beyond those use cases.
For example, the OF_TABLE() in include/asm-generic/vmlinux.lds.h
needs to evaluate a config option in macro expansion:
#define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
#define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
#define OF_TABLE(cfg, name) __OF_TABLE(config_enabled(cfg), name)
#define _OF_TABLE_0(name)
#define _OF_TABLE_1(name) \
...
Here, we can not use IS_ENABLED() because of the "||" operator in
its define. It is true config_enabled() works well, but it is a bit
ambiguous to be used against config options.
This commit makes IS_ENABLED() available in more generic context by
calculating "or" with macro expansion only.
Do likewise for IS_REACHABLE().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
include/linux/kconfig.h | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 722c7d2..15ec117 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -3,6 +3,21 @@
#include <generated/autoconf.h>
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * The use of "&&" / "||" is limited in certain expressions.
+ * The followings enable to calculate "and" / "or" with macro expansion only.
+ */
+#define __and(x, y) ___and(x, y)
+#define ___and(x, y) ____and(__ARG_PLACEHOLDER_##x, y)
+#define ____and(arg1_or_junk, y) __take_second_arg(arg1_or_junk y, 0)
+
+#define __or(x, y) ___or(x, y)
+#define ___or(x, y) ____or(__ARG_PLACEHOLDER_##x, y)
+#define ____or(arg1_or_junk, y) __take_second_arg(arg1_or_junk 1, y)
+
/*
* Helper macros to use CONFIG_ options in C/CPP expressions. Note that
* these only work with boolean and tristate options.
@@ -16,12 +31,10 @@
* When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
* the last step cherry picks the 2nd arg, we get a zero.
*/
-#define __ARG_PLACEHOLDER_1 0,
#define config_enabled(cfg) ___is_defined(cfg)
#define __is_defined(x) ___is_defined(x)
#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
-#define __take_second_arg(__ignored, val, ...) val
/*
* IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
@@ -42,14 +55,13 @@
* This is similar to IS_ENABLED(), but returns false when invoked from
* built-in code when CONFIG_FOO is set to 'm'.
*/
-#define IS_REACHABLE(option) (IS_BUILTIN(option) || \
- (IS_MODULE(option) && __is_defined(MODULE)))
+#define IS_REACHABLE(option) __or(IS_BUILTIN(option), \
+ __and(IS_MODULE(option), __is_defined(MODULE)))
/*
* IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
* 0 otherwise.
*/
-#define IS_ENABLED(option) \
- (IS_BUILTIN(option) || IS_MODULE(option))
+#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
#endif /* __LINUX_KCONFIG_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-14 5:58 [PATCH 1/5] kconfig.h: use __is_defined() to check if MODULE is defined Masahiro Yamada
` (2 preceding siblings ...)
2016-06-14 5:58 ` [PATCH 4/5] kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion Masahiro Yamada
@ 2016-06-14 5:58 ` Masahiro Yamada
2016-06-20 20:45 ` Michal Marek
3 siblings, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-14 5:58 UTC (permalink / raw)
To: linux-kernel, Andrew Morton
Cc: Rusty Russell, Michal Simek, Linus Torvalds, Arnd Bergmann,
Michal Marek, Nicolas Pitre, Masahiro Yamada, linux-arch
The use of config_enabled() against config options is ambiguous.
Now, IS_ENABLED() is implemented purely with macro expansion, so
let's replace config_enabled() with IS_ENABLED().
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
include/asm-generic/vmlinux.lds.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6a67ab9..faa4d2b 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -164,7 +164,7 @@
#define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
#define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
-#define OF_TABLE(cfg, name) __OF_TABLE(config_enabled(cfg), name)
+#define OF_TABLE(cfg, name) __OF_TABLE(IS_ENABLED(cfg), name)
#define _OF_TABLE_0(name)
#define _OF_TABLE_1(name) \
. = ALIGN(8); \
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-14 5:58 ` [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED() Masahiro Yamada
@ 2016-06-20 20:45 ` Michal Marek
2016-06-20 23:20 ` Masahiro Yamada
0 siblings, 1 reply; 11+ messages in thread
From: Michal Marek @ 2016-06-20 20:45 UTC (permalink / raw)
To: Masahiro Yamada, linux-kernel, Andrew Morton
Cc: Rusty Russell, Michal Simek, Linus Torvalds, Arnd Bergmann,
Nicolas Pitre, linux-arch
Dne 14.6.2016 v 07:58 Masahiro Yamada napsal(a):
> The use of config_enabled() against config options is ambiguous.
>
> Now, IS_ENABLED() is implemented purely with macro expansion, so
> let's replace config_enabled() with IS_ENABLED().
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
I applied the whole series to kbuild.git#kbuild.
Michal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-20 20:45 ` Michal Marek
@ 2016-06-20 23:20 ` Masahiro Yamada
2016-06-21 9:25 ` Arnd Bergmann
2016-06-23 8:07 ` Masahiro Yamada
0 siblings, 2 replies; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-20 23:20 UTC (permalink / raw)
To: Michal Marek
Cc: Linux Kernel Mailing List, Andrew Morton, Rusty Russell,
Michal Simek, Linus Torvalds, Arnd Bergmann, Nicolas Pitre,
linux-arch
2016-06-21 5:45 GMT+09:00 Michal Marek <mmarek@suse.cz>:
> Dne 14.6.2016 v 07:58 Masahiro Yamada napsal(a):
>> The use of config_enabled() against config options is ambiguous.
>>
>> Now, IS_ENABLED() is implemented purely with macro expansion, so
>> let's replace config_enabled() with IS_ENABLED().
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> I applied the whole series to kbuild.git#kbuild.
>
This series was applied by Andrew Morton last week.
I do not want to double it. Could you drop it?
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-20 23:20 ` Masahiro Yamada
@ 2016-06-21 9:25 ` Arnd Bergmann
2016-06-22 6:52 ` Masahiro Yamada
2016-06-23 8:07 ` Masahiro Yamada
1 sibling, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2016-06-21 9:25 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Michal Marek, Linux Kernel Mailing List, Andrew Morton,
Rusty Russell, Michal Simek, Linus Torvalds, Nicolas Pitre,
linux-arch
On Tuesday, June 21, 2016 8:20:10 AM CEST Masahiro Yamada wrote:
> 2016-06-21 5:45 GMT+09:00 Michal Marek <mmarek@suse.cz>:
> > Dne 14.6.2016 v 07:58 Masahiro Yamada napsal(a):
> >> The use of config_enabled() against config options is ambiguous.
> >>
> >> Now, IS_ENABLED() is implemented purely with macro expansion, so
> >> let's replace config_enabled() with IS_ENABLED().
> >>
> >> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> >
> > I applied the whole series to kbuild.git#kbuild.
> >
>
> This series was applied by Andrew Morton last week.
>
> I do not want to double it. Could you drop it?
Andrew usually drops patches from his tree when they show up in
another maintainer tree.
Arnd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-21 9:25 ` Arnd Bergmann
@ 2016-06-22 6:52 ` Masahiro Yamada
0 siblings, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-22 6:52 UTC (permalink / raw)
To: Arnd Bergmann, Andrew Morton
Cc: Michal Marek, Linux Kernel Mailing List, Rusty Russell,
Michal Simek, Linus Torvalds, Nicolas Pitre, linux-arch
Hi Andrew,
2016-06-21 18:25 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> On Tuesday, June 21, 2016 8:20:10 AM CEST Masahiro Yamada wrote:
>> 2016-06-21 5:45 GMT+09:00 Michal Marek <mmarek@suse.cz>:
>> > Dne 14.6.2016 v 07:58 Masahiro Yamada napsal(a):
>> >> The use of config_enabled() against config options is ambiguous.
>> >>
>> >> Now, IS_ENABLED() is implemented purely with macro expansion, so
>> >> let's replace config_enabled() with IS_ENABLED().
>> >>
>> >> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> >
>> > I applied the whole series to kbuild.git#kbuild.
>> >
>>
>> This series was applied by Andrew Morton last week.
>>
>> I do not want to double it. Could you drop it?
>
> Andrew usually drops patches from his tree when they show up in
> another maintainer tree.
Now, each patch of this series appears twice in linux-next.
Andrew,
Is it possible to drop this series from your tree?
Thanks
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] vmlinux.lds.h: replace config_enabled() with IS_ENABLED()
2016-06-20 23:20 ` Masahiro Yamada
2016-06-21 9:25 ` Arnd Bergmann
@ 2016-06-23 8:07 ` Masahiro Yamada
1 sibling, 0 replies; 11+ messages in thread
From: Masahiro Yamada @ 2016-06-23 8:07 UTC (permalink / raw)
To: Michal Marek, Andrew Morton
Cc: Linux Kernel Mailing List, Rusty Russell, Michal Simek,
Linus Torvalds, Arnd Bergmann, Nicolas Pitre, linux-arch
Hi Andrew, Michal,
2016-06-21 8:20 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> 2016-06-21 5:45 GMT+09:00 Michal Marek <mmarek@suse.cz>:
>> Dne 14.6.2016 v 07:58 Masahiro Yamada napsal(a):
>>> The use of config_enabled() against config options is ambiguous.
>>>
>>> Now, IS_ENABLED() is implemented purely with macro expansion, so
>>> let's replace config_enabled() with IS_ENABLED().
>>>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>
>> I applied the whole series to kbuild.git#kbuild.
>>
>
> This series was applied by Andrew Morton last week.
>
> I do not want to double it. Could you drop it?
Michal,
It is OK. Everything is fine now.
Andrew,
Thanks a lot for taking care of this!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 11+ messages in thread