Thread (99 messages) 99 messages, 5 authors, 2023-07-26

Re: [PATCH v7 1/5] module.h: MODULE_DEVICE_TABLE for built-in modules

From: Allen Webb <hidden>
Date: 2022-12-19 15:56:33
Also in: linux-usb, lkml

On Sat, Dec 17, 2022 at 4:05 AM Christophe Leroy
[off-list ref] wrote:


Le 16/12/2022 à 23:16, Allen Webb a écrit :
quoted
Implement MODULE_DEVICE_TABLE for build-in modules to make it possible
to generate a builtin.alias file to complement modules.alias.

Signed-off-by: Allen Webb <redacted>
---
  include/linux/module.h | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index ec61fb53979a9..49e4019393127 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -243,7 +243,15 @@ extern void cleanup_module(void);
  extern typeof(name) __mod_##type##__##name##_device_table           \
    __attribute__ ((unused, alias(__stringify(name))))
  #else  /* !MODULE */
-#define MODULE_DEVICE_TABLE(type, name)
+/* The names may not be unique for built-in modules, so include the module name
+ * to guarantee uniqueness.
+ */
This is network only comment style.
I have fixed this in my local copy and will include it with the next upload.
Other parts of kenel have different style, see
https://docs.kernel.org/process/coding-style.html#commenting
quoted
+#define MODULE_DEVICE_TABLE(type, name)                                      \
+extern void *CONCATENATE(                                            \
'extern' keyword is pointless of function prototypes and deprecated.
Don't add new occurences.

This is a weird case because these symbols are used for post
compilation processing by modpost. If I drop the extern keyword, the
build fails with a bunch of errors of the form:

/mnt/host/source/src/third_party/kernel/upstream/drivers/hid/hid-generic.c:79:1:
error: definition
'__mod_hid__hid_table__kmod_hid_generic_device_table' cannot also be
an alias
MODULE_DEVICE_TABLE(hid, hid_table);
^
/mnt/host/source/src/third_party/kernel/upstream/include/linux/module.h:255:26:
note: expanded from macro 'MODULE_DEVICE_TABLE'
        __attribute__ ((unused, alias(__stringify(name))))
quoted
+     CONCATENATE(__mod_##type##__##name##__,                         \
+             __KBUILD_MODNAME),                                      \
+     _device_table)                                                  \
+     __attribute__ ((unused, alias(__stringify(name))))
  #endif

  /* Version of form [<epoch>:]<version>[-<extra-version>].
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help