[PATCH] of: drop symbols declared by _OF_DECLARE() from modules

Subsystems: open firmware and flattened device tree, the rest

STALE3928d

4 messages, 2 authors, 2016-01-14 · open the first message on its own page

[PATCH] of: drop symbols declared by _OF_DECLARE() from modules

From: Masahiro Yamada <hidden>
Date: 2016-01-14 04:33:33

The users of this macro (OF_EARLYCON_DECLARE, CLK_OF_DECLARE,
IRQCHIP_DECLARE, etc.) are only parsed in the early boot stage.

Such symbols contained in modules are never used.

Signed-off-by: Masahiro Yamada <redacted>
---

OF_EARLYCON_DECLARE() is declared in several tristate drivers.

This patch makes each low-level driver be free from
taking care of it.

See this patch
https://patchwork.kernel.org/patch/8028771/


 include/linux/of.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index dd10626..dc6e396 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -929,7 +929,7 @@ static inline int of_get_available_child_count(const struct device_node *np)
 	return num;
 }
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && !defined(MODULE)
 #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
 	static const struct of_device_id __of_table_##name		\
 		__used __section(__##table##_of_table)			\
-- 
1.9.1

Re: [PATCH] of: drop symbols declared by _OF_DECLARE() from modules

From: Arnd Bergmann <arnd@arndb.de>
Date: 2016-01-14 10:15:42

On Thursday 14 January 2016 13:33:06 Masahiro Yamada wrote:
quoted hunk

-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && !defined(MODULE)
 #define _OF_DECLARE(table, name, compat, fn, fn_type)                  \
        static const struct of_device_id __of_table_##name              \
                __used __section(__##table##_of_table)                  \
-- 
Doesn't this lead to "unused function" warnings? Maybe we can change the "__used"
into "__unused" when MODULE is set, so the compiler will automatically
drop all code that is only referenced from the entry.

	Arnd

Re: [PATCH] of: drop symbols declared by _OF_DECLARE() from modules

From: Masahiro Yamada <hidden>
Date: 2016-01-14 10:21:28

Hi Arnd,

2016-01-14 19:14 GMT+09:00 Arnd Bergmann [off-list ref]:
On Thursday 14 January 2016 13:33:06 Masahiro Yamada wrote:
quoted

-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && !defined(MODULE)
 #define _OF_DECLARE(table, name, compat, fn, fn_type)                  \
        static const struct of_device_id __of_table_##name              \
                __used __section(__##table##_of_table)                  \
--
Doesn't this lead to "unused function" warnings? Maybe we can change the "__used"
into "__unused" when MODULE is set,
Yes, this is my intention.

I think this patch does so,
unless I am missing something...


  #if defined(CONFIG_OF) && !defined(MODULE)
          __used
  #else
          __unused
  #endif


so the compiler will automatically
drop all code that is only referenced from the entry.

-- 
Best Regards
Masahiro Yamada

Re: [PATCH] of: drop symbols declared by _OF_DECLARE() from modules

From: Arnd Bergmann <arnd@arndb.de>
Date: 2016-01-14 10:24:15

On Thursday 14 January 2016 19:21:21 Masahiro Yamada wrote:
Yes, this is my intention.

I think this patch does so,
unless I am missing something...


  #if defined(CONFIG_OF) && !defined(MODULE)
          __used
  #else
          __unused
  #endif
Ah, got it. You are right, I just missed that because the #else
part was not in the context that I saw in the patch and I was too lazy
to actually look at the file.

Acked-by: Arnd Bergmann <arnd@arndb.de>

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help