summaryrefslogtreecommitdiff
path: root/include/linux/init.h
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2023-11-26 16:19:14 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2023-12-10 15:32:48 +0900
commit5b20755b7780464fea3e54af0af744258dcc2841 (patch)
treedd4b6f346d798784f2e1125c7110658aaff060bd /include/linux/init.h
parent6262afa10ef7cc8fdf39b81a36f9546b68810431 (diff)
init: move THIS_MODULE from <linux/export.h> to <linux/init.h>
Commit f50169324df4 ("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 <masahiroy@kernel.org> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Diffstat (limited to 'include/linux/init.h')
-rw-r--r--include/linux/init.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/init.h b/include/linux/init.h
index 01b52c9c7526..3fa3f6241350 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -179,6 +179,13 @@ extern void (*late_time_init)(void);
extern bool initcall_debug;
+#ifdef MODULE
+extern struct module __this_module;
+#define THIS_MODULE (&__this_module)
+#else
+#define THIS_MODULE ((struct module *)0)
+#endif
+
#endif
#ifndef MODULE