diff options
author | Tom Gundersen <teg@jklm.no> | 2014-02-02 19:44:13 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-03-12 21:41:00 -0400 |
commit | 21bdd17b21b45ea48e06e23918d681afbe0622e9 (patch) | |
tree | 6eff7072912ade3ba7722d98acc753c65477b169 /scripts/mod | |
parent | 27bba4d6bb3779a6678b31f9c9b9c1553c63fa95 (diff) |
module: allow multiple calls to MODULE_DEVICE_TABLE() per module
Commit 78551277e4df5: "Input: i8042 - add PNP modaliases" had a bug, where the
second call to MODULE_DEVICE_TABLE() overrode the first resulting in not all
the modaliases being exposed.
This fixes the problem by including the name of the device_id table in the
__mod_*_device_table alias, allowing us to export several device_id tables
per module.
Suggested-by: Kay Sievers <kay@vrfy.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Tom Gundersen <teg@jklm.no>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/file2alias.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 25e5cb0aaef6..ce164044f0cc 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -42,7 +42,7 @@ typedef unsigned char __u8; | |||
42 | 42 | ||
43 | /* This array collects all instances that use the generic do_table */ | 43 | /* This array collects all instances that use the generic do_table */ |
44 | struct devtable { | 44 | struct devtable { |
45 | const char *device_id; /* name of table, __mod_<name>_device_table. */ | 45 | const char *device_id; /* name of table, __mod_<name>__*_device_table. */ |
46 | unsigned long id_size; | 46 | unsigned long id_size; |
47 | void *function; | 47 | void *function; |
48 | }; | 48 | }; |
@@ -146,7 +146,8 @@ static void device_id_check(const char *modname, const char *device_id, | |||
146 | 146 | ||
147 | if (size % id_size || size < id_size) { | 147 | if (size % id_size || size < id_size) { |
148 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " | 148 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " |
149 | "of the size of section __mod_%s_device_table=%lu.\n" | 149 | "of the size of " |
150 | "section __mod_%s__<identifier>_device_table=%lu.\n" | ||
150 | "Fix definition of struct %s_device_id " | 151 | "Fix definition of struct %s_device_id " |
151 | "in mod_devicetable.h\n", | 152 | "in mod_devicetable.h\n", |
152 | modname, device_id, id_size, device_id, size, device_id); | 153 | modname, device_id, id_size, device_id, size, device_id); |
@@ -1206,7 +1207,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1206 | { | 1207 | { |
1207 | void *symval; | 1208 | void *symval; |
1208 | char *zeros = NULL; | 1209 | char *zeros = NULL; |
1209 | const char *name; | 1210 | const char *name, *identifier; |
1210 | unsigned int namelen; | 1211 | unsigned int namelen; |
1211 | 1212 | ||
1212 | /* We're looking for a section relative symbol */ | 1213 | /* We're looking for a section relative symbol */ |
@@ -1217,7 +1218,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1217 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) | 1218 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) |
1218 | return; | 1219 | return; |
1219 | 1220 | ||
1220 | /* All our symbols are of form <prefix>__mod_XXX_device_table. */ | 1221 | /* All our symbols are of form <prefix>__mod_<name>__<identifier>_device_table. */ |
1221 | name = strstr(symname, "__mod_"); | 1222 | name = strstr(symname, "__mod_"); |
1222 | if (!name) | 1223 | if (!name) |
1223 | return; | 1224 | return; |
@@ -1227,7 +1228,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1227 | return; | 1228 | return; |
1228 | if (strcmp(name + namelen - strlen("_device_table"), "_device_table")) | 1229 | if (strcmp(name + namelen - strlen("_device_table"), "_device_table")) |
1229 | return; | 1230 | return; |
1230 | namelen -= strlen("_device_table"); | 1231 | identifier = strstr(name, "__"); |
1232 | if (!identifier) | ||
1233 | return; | ||
1234 | namelen = identifier - name; | ||
1231 | 1235 | ||
1232 | /* Handle all-NULL symbols allocated into .bss */ | 1236 | /* Handle all-NULL symbols allocated into .bss */ |
1233 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { | 1237 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |