diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-11-20 08:56:52 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2024-11-28 08:46:02 +0900 |
commit | 054a9cd395a79f4a5595f2cd24542e9bca8723c8 (patch) | |
tree | b06d60462e7318bfcf3ceb7c6b1337693511d526 | |
parent | 9a8ace8bb2efa0ca43a77866fa9c835294b1e045 (diff) | |
download | linux-054a9cd395a79f4a5595f2cd24542e9bca8723c8.tar.gz linux-054a9cd395a79f4a5595f2cd24542e9bca8723c8.tar.bz2 linux-054a9cd395a79f4a5595f2cd24542e9bca8723c8.zip |
modpost: rename alias symbol for MODULE_DEVICE_TABLE()
This commit renames the alias symbol, __mod_<type>__<name>_device_table
to __mod_device_table__<type>__<name>.
This change simplifies the code slightly, as there is no longer a need
to check both the prefix and suffix.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-rw-r--r-- | include/linux/module.h | 2 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 17 |
2 files changed, 8 insertions, 11 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 88ecc5e9f523..3dd79a3d0cbf 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -247,7 +247,7 @@ extern void cleanup_module(void); #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ -extern typeof(name) __mod_##type##__##name##_device_table \ +extern typeof(name) __mod_device_table__##type##__##name \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 038b2ab79e11..fc4bbeea1268 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -123,7 +123,7 @@ typedef struct { #include "../../include/linux/mod_devicetable.h" struct devtable { - const char *device_id; /* name of table, __mod_<name>__*_device_table. */ + const char *device_id; unsigned long id_size; void (*do_entry)(struct module *mod, void *symval); }; @@ -190,7 +190,7 @@ static void device_id_check(const char *modname, const char *device_id, int i; if (size % id_size || size < id_size) { - fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_%s__<identifier>_device_table=%lu.\n" + fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_device_table__%s__<identifier>=%lu.\n" "Fix definition of struct %s_device_id in mod_devicetable.h\n", modname, device_id, id_size, device_id, size, device_id); } @@ -1505,6 +1505,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, char *zeros = NULL; const char *type, *name; size_t typelen; + static const char *prefix = "__mod_device_table__"; /* We're looking for a section relative symbol */ if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) @@ -1514,15 +1515,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod_<type>__<name>_device_table. */ - if (!strstarts(symname, "__mod_")) - return; - type = symname + strlen("__mod_"); - typelen = strlen(type); - if (typelen < strlen("_device_table")) - return; - if (strcmp(type + typelen - strlen("_device_table"), "_device_table")) + /* All our symbols are of form __mod_device_table__<type>__<name>. */ + if (!strstarts(symname, prefix)) return; + type = symname + strlen(prefix); + name = strstr(type, "__"); if (!name) return; |