summaryrefslogtreecommitdiff
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-11-20 08:56:41 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-11-28 08:42:58 +0900
commitf4fdb17ca5a5285d4a0ed81b25d5a3d7b9b3ebf3 (patch)
tree3919ba866936ff712552472685a4d13eaa0619e2 /scripts/mod/modpost.c
parentb7bca42d101d8d9678068cde645bd6d0afa8a20f (diff)
modpost: introduce module_alias_printf() helper
The generic ->do_entry() handler is currently limited to returning a single alias string. However, this is not flexible enough for several subsystems, which currently require their own implementations: - do_usb_table() - do_of_table() - do_pnp_device_entry() - do_pnp_card_entries() This commit introduces a helper function so that these special cases can add multiple MODULE_ALIAS() and then migrate to the generic framework. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 107393a8c48a..1948d69ce2b9 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -176,6 +176,7 @@ static struct module *new_module(const char *name, size_t namelen)
INIT_LIST_HEAD(&mod->unresolved_symbols);
INIT_LIST_HEAD(&mod->missing_namespaces);
INIT_LIST_HEAD(&mod->imported_namespaces);
+ INIT_LIST_HEAD(&mod->aliases);
memcpy(mod->name, name, namelen);
mod->name[namelen] = '\0';
@@ -1966,6 +1967,7 @@ static void write_vmlinux_export_c_file(struct module *mod)
static void write_mod_c_file(struct module *mod)
{
struct buffer buf = { };
+ struct module_alias *alias, *next;
char fname[PATH_MAX];
int ret;
@@ -1973,7 +1975,14 @@ static void write_mod_c_file(struct module *mod)
add_exported_symbols(&buf, mod);
add_versions(&buf, mod);
add_depends(&buf, mod);
- add_moddevtable(&buf, mod);
+
+ buf_printf(&buf, "\n");
+ list_for_each_entry_safe(alias, next, &mod->aliases, node) {
+ buf_printf(&buf, "MODULE_ALIAS(\"%s\");\n", alias->str);
+ list_del(&alias->node);
+ free(alias);
+ }
+
add_srcversion(&buf, mod);
ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name);