History

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.

Masahiro Yamada committed 1 year ago

Commit 054a9cd1 parent 9a8ace82 files · +8 −11Browse files

Unified · Split

2 files
  1. include/linux/module.h +1 −1
  2. scripts/mod/file2alias.c +7 −10
include/linux/module.h+1−1
@@ -247,7 +247,7 @@ extern void cleanup_module(void); · 246 unmodified lines
247247 #ifdef MODULE
248248 /* Creates an alias so file2alias.c can find device table. */
249249 #define MODULE_DEVICE_TABLE(type, name) \
250−extern typeof(name) __mod_##type##__##name##_device_table \
250+extern typeof(name) __mod_device_table__##type##__##name \
251251 __attribute__ ((unused, alias(__stringify(name))))
252252 #else /* !MODULE */
253253 #define MODULE_DEVICE_TABLE(type, name)
scripts/mod/file2alias.c+7−10
@@ -123,7 +123,7 @@ typedef struct { · 122 unmodified lines
123123 #include "../../include/linux/mod_devicetable.h"
124124
125125 struct devtable {
126− const char *device_id; /* name of table, __mod_<name>__*_device_table. */
126+ const char *device_id;
127127 unsigned long id_size;
128128 void (*do_entry)(struct module *mod, void *symval);
129129 };
@@ -190,7 +190,7 @@ static void device_id_check(const char *modname, const char *device_id, · 60 unmodified lines
190190 int i;
191191
192192 if (size % id_size || size < id_size) {
193− fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_%s__<identifier>_device_table=%lu.\n"
193+ fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_device_table__%s__<identifier>=%lu.\n"
194194 "Fix definition of struct %s_device_id in mod_devicetable.h\n",
195195 modname, device_id, id_size, device_id, size, device_id);
196196 }
@@ -1505,6 +1505,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, · 1308 unmodified lines
15051505 char *zeros = NULL;
15061506 const char *type, *name;
15071507 size_t typelen;
1508+ static const char *prefix = "__mod_device_table__";
15081509
15091510 /* We're looking for a section relative symbol */
15101511 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, · 3 unmodified lines
15141515 if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
15151516 return;
15161517
1517− /* All our symbols are of form __mod_<type>__<name>_device_table. */
1518− if (!strstarts(symname, "__mod_"))
1519− return;
1520− type = symname + strlen("__mod_");
1521− typelen = strlen(type);
1522− if (typelen < strlen("_device_table"))
1523− return;
1524− if (strcmp(type + typelen - strlen("_device_table"), "_device_table"))
1518+ /* All our symbols are of form __mod_device_table__<type>__<name>. */
1519+ if (!strstarts(symname, prefix))
15251520 return;
1521+ type = symname + strlen(prefix);
1522+
15261523 name = strstr(type, "__");
15271524 if (!name)
15281525 return;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t