diff options
Diffstat (limited to 'scripts/mod/file2alias.c')
| -rw-r--r-- | scripts/mod/file2alias.c | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 220213e603db..88f3f07205f8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
| @@ -796,6 +796,51 @@ static int do_platform_entry(const char *filename, | |||
| 796 | return 1; | 796 | return 1; |
| 797 | } | 797 | } |
| 798 | 798 | ||
| 799 | static int do_mdio_entry(const char *filename, | ||
| 800 | struct mdio_device_id *id, char *alias) | ||
| 801 | { | ||
| 802 | int i; | ||
| 803 | |||
| 804 | alias += sprintf(alias, MDIO_MODULE_PREFIX); | ||
| 805 | |||
| 806 | for (i = 0; i < 32; i++) { | ||
| 807 | if (!((id->phy_id_mask >> (31-i)) & 1)) | ||
| 808 | *(alias++) = '?'; | ||
| 809 | else if ((id->phy_id >> (31-i)) & 1) | ||
| 810 | *(alias++) = '1'; | ||
| 811 | else | ||
| 812 | *(alias++) = '0'; | ||
| 813 | } | ||
| 814 | |||
| 815 | /* Terminate the string */ | ||
| 816 | *alias = 0; | ||
| 817 | |||
| 818 | return 1; | ||
| 819 | } | ||
| 820 | |||
| 821 | /* Looks like: zorro:iN. */ | ||
| 822 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | ||
| 823 | char *alias) | ||
| 824 | { | ||
| 825 | id->id = TO_NATIVE(id->id); | ||
| 826 | strcpy(alias, "zorro:"); | ||
| 827 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); | ||
| 828 | return 1; | ||
| 829 | } | ||
| 830 | |||
| 831 | /* looks like: "pnp:dD" */ | ||
| 832 | static int do_isapnp_entry(const char *filename, | ||
| 833 | struct isapnp_device_id *id, char *alias) | ||
| 834 | { | ||
| 835 | sprintf(alias, "pnp:d%c%c%c%x%x%x%x*", | ||
| 836 | 'A' + ((id->vendor >> 2) & 0x3f) - 1, | ||
| 837 | 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1, | ||
| 838 | 'A' + ((id->vendor >> 8) & 0x1f) - 1, | ||
| 839 | (id->function >> 4) & 0x0f, id->function & 0x0f, | ||
| 840 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); | ||
| 841 | return 1; | ||
| 842 | } | ||
| 843 | |||
| 799 | /* Ignore any prefix, eg. some architectures prepend _ */ | 844 | /* Ignore any prefix, eg. some architectures prepend _ */ |
| 800 | static inline int sym_is(const char *symbol, const char *name) | 845 | static inline int sym_is(const char *symbol, const char *name) |
| 801 | { | 846 | { |
| @@ -839,16 +884,16 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
| 839 | char *zeros = NULL; | 884 | char *zeros = NULL; |
| 840 | 885 | ||
| 841 | /* We're looking for a section relative symbol */ | 886 | /* We're looking for a section relative symbol */ |
| 842 | if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) | 887 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
| 843 | return; | 888 | return; |
| 844 | 889 | ||
| 845 | /* Handle all-NULL symbols allocated into .bss */ | 890 | /* Handle all-NULL symbols allocated into .bss */ |
| 846 | if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) { | 891 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
| 847 | zeros = calloc(1, sym->st_size); | 892 | zeros = calloc(1, sym->st_size); |
| 848 | symval = zeros; | 893 | symval = zeros; |
| 849 | } else { | 894 | } else { |
| 850 | symval = (void *)info->hdr | 895 | symval = (void *)info->hdr |
| 851 | + info->sechdrs[sym->st_shndx].sh_offset | 896 | + info->sechdrs[get_secindex(info, sym)].sh_offset |
| 852 | + sym->st_value; | 897 | + sym->st_value; |
| 853 | } | 898 | } |
| 854 | 899 | ||
| @@ -943,6 +988,18 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
| 943 | do_table(symval, sym->st_size, | 988 | do_table(symval, sym->st_size, |
| 944 | sizeof(struct platform_device_id), "platform", | 989 | sizeof(struct platform_device_id), "platform", |
| 945 | do_platform_entry, mod); | 990 | do_platform_entry, mod); |
| 991 | else if (sym_is(symname, "__mod_mdio_device_table")) | ||
| 992 | do_table(symval, sym->st_size, | ||
| 993 | sizeof(struct mdio_device_id), "mdio", | ||
| 994 | do_mdio_entry, mod); | ||
| 995 | else if (sym_is(symname, "__mod_zorro_device_table")) | ||
| 996 | do_table(symval, sym->st_size, | ||
| 997 | sizeof(struct zorro_device_id), "zorro", | ||
| 998 | do_zorro_entry, mod); | ||
| 999 | else if (sym_is(symname, "__mod_isapnp_device_table")) | ||
| 1000 | do_table(symval, sym->st_size, | ||
| 1001 | sizeof(struct isapnp_device_id), "isa", | ||
| 1002 | do_isapnp_entry, mod); | ||
| 946 | free(zeros); | 1003 | free(zeros); |
| 947 | } | 1004 | } |
| 948 | 1005 | ||
