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.
Unified · Split
| @@ -247,7 +247,7 @@ extern void cleanup_module(void); · 246 unmodified lines | ||
| 247 | 247 | #ifdef MODULE |
| 248 | 248 | /* Creates an alias so file2alias.c can find device table. */ |
| 249 | 249 | #define MODULE_DEVICE_TABLE(type, name) \ |
| 250 | −extern typeof(name) __mod_##type##__##name##_device_table \ | |
| 250 | +extern typeof(name) __mod_device_table__##type##__##name \ | |
| 251 | 251 | __attribute__ ((unused, alias(__stringify(name)))) |
| 252 | 252 | #else /* !MODULE */ |
| 253 | 253 | #define MODULE_DEVICE_TABLE(type, name) |
| @@ -123,7 +123,7 @@ typedef struct { · 122 unmodified lines | ||
| 123 | 123 | #include "../../include/linux/mod_devicetable.h" |
| 124 | 124 | |
| 125 | 125 | struct devtable { |
| 126 | − const char *device_id; /* name of table, __mod_<name>__*_device_table. */ | |
| 126 | + const char *device_id; | |
| 127 | 127 | unsigned long id_size; |
| 128 | 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 | 190 | int i; |
| 191 | 191 | |
| 192 | 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 | 194 | "Fix definition of struct %s_device_id in mod_devicetable.h\n", |
| 195 | 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 | 1505 | char *zeros = NULL; |
| 1506 | 1506 | const char *type, *name; |
| 1507 | 1507 | size_t typelen; |
| 1508 | + static const char *prefix = "__mod_device_table__"; | |
| 1508 | 1509 | |
| 1509 | 1510 | /* We're looking for a section relative symbol */ |
| 1510 | 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 | 1515 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) |
| 1515 | 1516 | return; |
| 1516 | 1517 | |
| 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)) | |
| 1525 | 1520 | return; |
| 1521 | + type = symname + strlen(prefix); | |
| 1522 | + | |
| 1526 | 1523 | name = strstr(type, "__"); |
| 1527 | 1524 | if (!name) |
| 1528 | 1525 | return; |