diff options
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r-- | scripts/mod/file2alias.c | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 161dd0d67da8..a9155077feef 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -371,6 +371,49 @@ static void do_usb_table(void *symval, unsigned long size, | |||
371 | do_usb_entry_multi(symval + i, mod); | 371 | do_usb_entry_multi(symval + i, mod); |
372 | } | 372 | } |
373 | 373 | ||
374 | static void do_of_entry_multi(void *symval, struct module *mod) | ||
375 | { | ||
376 | char alias[500]; | ||
377 | int len; | ||
378 | char *tmp; | ||
379 | |||
380 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
381 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
382 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
383 | |||
384 | len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*", | ||
385 | (*type)[0] ? *type : "*"); | ||
386 | |||
387 | if (compatible[0]) | ||
388 | sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "", | ||
389 | *compatible); | ||
390 | |||
391 | /* Replace all whitespace with underscores */ | ||
392 | for (tmp = alias; tmp && *tmp; tmp++) | ||
393 | if (isspace(*tmp)) | ||
394 | *tmp = '_'; | ||
395 | |||
396 | buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); | ||
397 | strcat(alias, "C"); | ||
398 | add_wildcard(alias); | ||
399 | buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); | ||
400 | } | ||
401 | |||
402 | static void do_of_table(void *symval, unsigned long size, | ||
403 | struct module *mod) | ||
404 | { | ||
405 | unsigned int i; | ||
406 | const unsigned long id_size = SIZE_of_device_id; | ||
407 | |||
408 | device_id_check(mod->name, "of", size, id_size, symval); | ||
409 | |||
410 | /* Leave last one: it's the terminator. */ | ||
411 | size -= id_size; | ||
412 | |||
413 | for (i = 0; i < size; i += id_size) | ||
414 | do_of_entry_multi(symval + i, mod); | ||
415 | } | ||
416 | |||
374 | /* Looks like: hid:bNvNpN */ | 417 | /* Looks like: hid:bNvNpN */ |
375 | static int do_hid_entry(const char *filename, | 418 | static int do_hid_entry(const char *filename, |
376 | void *symval, char *alias) | 419 | void *symval, char *alias) |
@@ -684,30 +727,6 @@ static int do_pcmcia_entry(const char *filename, | |||
684 | } | 727 | } |
685 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); | 728 | ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); |
686 | 729 | ||
687 | static int do_of_entry (const char *filename, void *symval, char *alias) | ||
688 | { | ||
689 | int len; | ||
690 | char *tmp; | ||
691 | DEF_FIELD_ADDR(symval, of_device_id, name); | ||
692 | DEF_FIELD_ADDR(symval, of_device_id, type); | ||
693 | DEF_FIELD_ADDR(symval, of_device_id, compatible); | ||
694 | |||
695 | len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*", | ||
696 | (*type)[0] ? *type : "*"); | ||
697 | |||
698 | if (compatible[0]) | ||
699 | sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "", | ||
700 | *compatible); | ||
701 | |||
702 | /* Replace all whitespace with underscores */ | ||
703 | for (tmp = alias; tmp && *tmp; tmp++) | ||
704 | if (isspace (*tmp)) | ||
705 | *tmp = '_'; | ||
706 | |||
707 | return 1; | ||
708 | } | ||
709 | ADD_TO_DEVTABLE("of", of_device_id, do_of_entry); | ||
710 | |||
711 | static int do_vio_entry(const char *filename, void *symval, | 730 | static int do_vio_entry(const char *filename, void *symval, |
712 | char *alias) | 731 | char *alias) |
713 | { | 732 | { |
@@ -1348,6 +1367,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1348 | /* First handle the "special" cases */ | 1367 | /* First handle the "special" cases */ |
1349 | if (sym_is(name, namelen, "usb")) | 1368 | if (sym_is(name, namelen, "usb")) |
1350 | do_usb_table(symval, sym->st_size, mod); | 1369 | do_usb_table(symval, sym->st_size, mod); |
1370 | if (sym_is(name, namelen, "of")) | ||
1371 | do_of_table(symval, sym->st_size, mod); | ||
1351 | else if (sym_is(name, namelen, "pnp")) | 1372 | else if (sym_is(name, namelen, "pnp")) |
1352 | do_pnp_device_entry(symval, sym->st_size, mod); | 1373 | do_pnp_device_entry(symval, sym->st_size, mod); |
1353 | else if (sym_is(name, namelen, "pnp_card")) | 1374 | else if (sym_is(name, namelen, "pnp_card")) |