module: make __mod_device_table__* symbols static
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 2 Jun 2025 10:55:36 +0000 (19:55 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 5 Jun 2025 20:40:25 +0000 (05:40 +0900)
The __mod_device_table__* symbols are only parsed by modpost to generate
MODULE_ALIAS() entries from MODULE_DEVICE_TABLE().

Therefore, these symbols do not need to be globally visible, or globally
unique.

If they are in the global scope, we would worry about the symbol
uniqueness, but modpost is fine with parsing multiple symbols with the
same name.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
include/linux/module.h

index 8050f77c3b64f8512afcb7ccde889a922ae89ab7..92e1420fccdffc9de9f49da9061546cc1e0c89d1 100644 (file)
@@ -249,8 +249,8 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
 #ifdef MODULE
 /* Creates an alias so file2alias.c can find device table. */
 #define MODULE_DEVICE_TABLE(type, name)                                        \
-extern typeof(name) __mod_device_table__##type##__##name               \
-  __attribute__ ((unused, alias(__stringify(name))))
+static typeof(name) __mod_device_table__##type##__##name               \
+  __attribute__ ((used, alias(__stringify(name))))
 #else  /* !MODULE */
 #define MODULE_DEVICE_TABLE(type, name)
 #endif