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
247#ifdef MODULE247#ifdef MODULE
248/* Creates an alias so file2alias.c can find device table. */248/* Creates an alias so file2alias.c can find device table. */
249#define MODULE_DEVICE_TABLE(type, name) \249#define MODULE_DEVICE_TABLE(type, name) \
250extern typeof(name) __mod_##type##__##name##_device_table \250extern typeof(name) __mod_device_table__##type##__##name \
251 __attribute__ ((unused, alias(__stringify(name))))251 __attribute__ ((unused, alias(__stringify(name))))
252#else /* !MODULE */252#else /* !MODULE */
253#define MODULE_DEVICE_TABLE(type, name)253#define MODULE_DEVICE_TABLE(type, name)
scripts/mod/file2alias.c+7−10
@@ -123,7 +123,7 @@ typedef struct { · 122 unmodified lines
123#include "../../include/linux/mod_devicetable.h"123#include "../../include/linux/mod_devicetable.h"
124 124
125struct devtable {125struct devtable {
126 const char *device_id; /* name of table, __mod_<name>__*_device_table. */126 const char *device_id;
127 unsigned long id_size;127 unsigned long id_size;
128 void (*do_entry)(struct module *mod, void *symval);128 void (*do_entry)(struct module *mod, void *symval);
129};129};
@@ -190,7 +190,7 @@ static void device_id_check(const char *modname, const char *device_id, · 60 unmodified lines
190 int i;190 int i;
191 191
192 if (size % id_size || size < id_size) {192 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"
194 "Fix definition of struct %s_device_id in mod_devicetable.h\n",194 "Fix definition of struct %s_device_id in mod_devicetable.h\n",
195 modname, device_id, id_size, device_id, size, device_id);195 modname, device_id, id_size, device_id, size, device_id);
196 }196 }
@@ -1505,6 +1505,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, · 1308 unmodified lines
1505 char *zeros = NULL;1505 char *zeros = NULL;
1506 const char *type, *name;1506 const char *type, *name;
1507 size_t typelen;1507 size_t typelen;
1508 static const char *prefix = "__mod_device_table__";
1508 1509
1509 /* We're looking for a section relative symbol */1510 /* We're looking for a section relative symbol */
1510 if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)1511 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
1514 if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)1515 if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
1515 return;1516 return;
1516 1517
1517 /* All our symbols are of form __mod_<type>__<name>_device_table. */1518 /* All our symbols are of form __mod_device_table__<type>__<name>. */
1518 if (!strstarts(symname, "__mod_"))1519 if (!strstarts(symname, prefix))
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"))
1525 return;1520 return;
1521 type = symname + strlen(prefix);
1522
1526 name = strstr(type, "__");1523 name = strstr(type, "__");
1527 if (!name)1524 if (!name)
1528 return;1525 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