Skip to content

Commit 5b20755

Browse files
committed
init: move THIS_MODULE from <linux/export.h> to <linux/init.h>
Commit f501693 ("module.h: split out the EXPORT_SYMBOL into export.h") appropriately separated EXPORT_SYMBOL into <linux/export.h> because modules and EXPORT_SYMBOL are orthogonal; modules are symbol consumers, while EXPORT_SYMBOL are used by symbol providers, which may not be necessarily a module. However, that commit also relocated THIS_MODULE. As explained in the commit description, the intention was to define THIS_MODULE in a lightweight header, but I do not believe <linux/export.h> was the best location because EXPORT_SYMBOL and THIS_MODULE are unrelated. Move it to another lightweight header, <linux/init.h>. The reason for choosing <linux/init.h> is to make <linux/moduleparam.h> self-contained without relying on <linux/linkage.h> incorrectly including <linux/export.h>. With this adjustment, the role of <linux/export.h> becomes clearer as it only defines EXPORT_SYMBOL. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]>
1 parent 6262afa commit 5b20755

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

include/linux/export.h

-18
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
#include <linux/linkage.h>
77
#include <linux/stringify.h>
88

9-
/*
10-
* Export symbols from the kernel to modules. Forked from module.h
11-
* to reduce the amount of pointless cruft we feed to gcc when only
12-
* exporting a simple symbol or two.
13-
*
14-
* Try not to add #includes here. It slows compilation and makes kernel
15-
* hackers place grumpy comments in header files.
16-
*/
17-
189
/*
1910
* This comment block is used by fixdep. Please do not remove.
2011
*
@@ -23,15 +14,6 @@
2314
* side effect of the *.o build rule.
2415
*/
2516

26-
#ifndef __ASSEMBLY__
27-
#ifdef MODULE
28-
extern struct module __this_module;
29-
#define THIS_MODULE (&__this_module)
30-
#else
31-
#define THIS_MODULE ((struct module *)0)
32-
#endif
33-
#endif /* __ASSEMBLY__ */
34-
3517
#ifdef CONFIG_64BIT
3618
#define __EXPORT_SYMBOL_REF(sym) \
3719
.balign 8 ASM_NL \

include/linux/init.h

+7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ extern void (*late_time_init)(void);
179179

180180
extern bool initcall_debug;
181181

182+
#ifdef MODULE
183+
extern struct module __this_module;
184+
#define THIS_MODULE (&__this_module)
185+
#else
186+
#define THIS_MODULE ((struct module *)0)
187+
#endif
188+
182189
#endif
183190

184191
#ifndef MODULE

0 commit comments

Comments
 (0)