Skip to content

Commit 054a9cd

Browse files
committed
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>
1 parent 9a8ace8 commit 054a9cd

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

include/linux/module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ extern void cleanup_module(void);
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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ typedef struct {
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,
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,
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,
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;

0 commit comments

Comments
 (0)