diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2012-01-19 15:56:50 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2012-01-19 15:56:50 -0500 |
commit | 282f445a779ed76fca9884fe377bf56a3088b208 (patch) | |
tree | d9abcf526baee0100672851e0a8894c19e762a39 /scripts/mod/file2alias.c | |
parent | 68f30fbee19cc67849b9fa8e153ede70758afe81 (diff) | |
parent | 90a4c0f51e8e44111a926be6f4c87af3938a79c3 (diff) |
Merge remote-tracking branch 'linus/master' into x86/urgent
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r-- | scripts/mod/file2alias.c | 286 |
1 files changed, 169 insertions, 117 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index f936d1fa969d..c0e14b3f2306 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -28,6 +28,7 @@ typedef Elf64_Addr kernel_ulong_t; | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <ctype.h> | 30 | #include <ctype.h> |
31 | #include <stdbool.h> | ||
31 | 32 | ||
32 | typedef uint32_t __u32; | 33 | typedef uint32_t __u32; |
33 | typedef uint16_t __u16; | 34 | typedef uint16_t __u16; |
@@ -38,6 +39,35 @@ typedef unsigned char __u8; | |||
38 | * we handle those differences explicitly below */ | 39 | * we handle those differences explicitly below */ |
39 | #include "../../include/linux/mod_devicetable.h" | 40 | #include "../../include/linux/mod_devicetable.h" |
40 | 41 | ||
42 | /* This array collects all instances that use the generic do_table */ | ||
43 | struct devtable { | ||
44 | const char *device_id; /* name of table, __mod_<name>_device_table. */ | ||
45 | unsigned long id_size; | ||
46 | void *function; | ||
47 | }; | ||
48 | |||
49 | /* We construct a table of pointers in an ELF section (pointers generally | ||
50 | * go unpadded by gcc). ld creates boundary syms for us. */ | ||
51 | extern struct devtable *__start___devtable[], *__stop___devtable[]; | ||
52 | #define ___cat(a,b) a ## b | ||
53 | #define __cat(a,b) ___cat(a,b) | ||
54 | |||
55 | #if __GNUC__ == 3 && __GNUC_MINOR__ < 3 | ||
56 | # define __used __attribute__((__unused__)) | ||
57 | #else | ||
58 | # define __used __attribute__((__used__)) | ||
59 | #endif | ||
60 | |||
61 | /* Add a table entry. We test function type matches while we're here. */ | ||
62 | #define ADD_TO_DEVTABLE(device_id, type, function) \ | ||
63 | static struct devtable __cat(devtable,__LINE__) = { \ | ||
64 | device_id + 0*sizeof((function)((const char *)NULL, \ | ||
65 | (type *)NULL, \ | ||
66 | (char *)NULL)), \ | ||
67 | sizeof(type), (function) }; \ | ||
68 | static struct devtable *__attribute__((section("__devtable"))) \ | ||
69 | __used __cat(devtable_ptr,__LINE__) = &__cat(devtable,__LINE__) | ||
70 | |||
41 | #define ADD(str, sep, cond, field) \ | 71 | #define ADD(str, sep, cond, field) \ |
42 | do { \ | 72 | do { \ |
43 | strcat(str, sep); \ | 73 | strcat(str, sep); \ |
@@ -289,6 +319,7 @@ static int do_hid_entry(const char *filename, | |||
289 | 319 | ||
290 | return 1; | 320 | return 1; |
291 | } | 321 | } |
322 | ADD_TO_DEVTABLE("hid", struct hid_device_id, do_hid_entry); | ||
292 | 323 | ||
293 | /* Looks like: ieee1394:venNmoNspNverN */ | 324 | /* Looks like: ieee1394:venNmoNspNverN */ |
294 | static int do_ieee1394_entry(const char *filename, | 325 | static int do_ieee1394_entry(const char *filename, |
@@ -313,6 +344,7 @@ static int do_ieee1394_entry(const char *filename, | |||
313 | add_wildcard(alias); | 344 | add_wildcard(alias); |
314 | return 1; | 345 | return 1; |
315 | } | 346 | } |
347 | ADD_TO_DEVTABLE("ieee1394", struct ieee1394_device_id, do_ieee1394_entry); | ||
316 | 348 | ||
317 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ | 349 | /* Looks like: pci:vNdNsvNsdNbcNscNiN. */ |
318 | static int do_pci_entry(const char *filename, | 350 | static int do_pci_entry(const char *filename, |
@@ -356,6 +388,7 @@ static int do_pci_entry(const char *filename, | |||
356 | add_wildcard(alias); | 388 | add_wildcard(alias); |
357 | return 1; | 389 | return 1; |
358 | } | 390 | } |
391 | ADD_TO_DEVTABLE("pci", struct pci_device_id, do_pci_entry); | ||
359 | 392 | ||
360 | /* looks like: "ccw:tNmNdtNdmN" */ | 393 | /* looks like: "ccw:tNmNdtNdmN" */ |
361 | static int do_ccw_entry(const char *filename, | 394 | static int do_ccw_entry(const char *filename, |
@@ -379,6 +412,7 @@ static int do_ccw_entry(const char *filename, | |||
379 | add_wildcard(alias); | 412 | add_wildcard(alias); |
380 | return 1; | 413 | return 1; |
381 | } | 414 | } |
415 | ADD_TO_DEVTABLE("ccw", struct ccw_device_id, do_ccw_entry); | ||
382 | 416 | ||
383 | /* looks like: "ap:tN" */ | 417 | /* looks like: "ap:tN" */ |
384 | static int do_ap_entry(const char *filename, | 418 | static int do_ap_entry(const char *filename, |
@@ -387,6 +421,7 @@ static int do_ap_entry(const char *filename, | |||
387 | sprintf(alias, "ap:t%02X*", id->dev_type); | 421 | sprintf(alias, "ap:t%02X*", id->dev_type); |
388 | return 1; | 422 | return 1; |
389 | } | 423 | } |
424 | ADD_TO_DEVTABLE("ap", struct ap_device_id, do_ap_entry); | ||
390 | 425 | ||
391 | /* looks like: "css:tN" */ | 426 | /* looks like: "css:tN" */ |
392 | static int do_css_entry(const char *filename, | 427 | static int do_css_entry(const char *filename, |
@@ -395,6 +430,7 @@ static int do_css_entry(const char *filename, | |||
395 | sprintf(alias, "css:t%01X", id->type); | 430 | sprintf(alias, "css:t%01X", id->type); |
396 | return 1; | 431 | return 1; |
397 | } | 432 | } |
433 | ADD_TO_DEVTABLE("css", struct css_device_id, do_css_entry); | ||
398 | 434 | ||
399 | /* Looks like: "serio:tyNprNidNexN" */ | 435 | /* Looks like: "serio:tyNprNidNexN" */ |
400 | static int do_serio_entry(const char *filename, | 436 | static int do_serio_entry(const char *filename, |
@@ -414,6 +450,7 @@ static int do_serio_entry(const char *filename, | |||
414 | add_wildcard(alias); | 450 | add_wildcard(alias); |
415 | return 1; | 451 | return 1; |
416 | } | 452 | } |
453 | ADD_TO_DEVTABLE("serio", struct serio_device_id, do_serio_entry); | ||
417 | 454 | ||
418 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ | 455 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ |
419 | static int do_acpi_entry(const char *filename, | 456 | static int do_acpi_entry(const char *filename, |
@@ -422,6 +459,7 @@ static int do_acpi_entry(const char *filename, | |||
422 | sprintf(alias, "acpi*:%s:*", id->id); | 459 | sprintf(alias, "acpi*:%s:*", id->id); |
423 | return 1; | 460 | return 1; |
424 | } | 461 | } |
462 | ADD_TO_DEVTABLE("acpi", struct acpi_device_id, do_acpi_entry); | ||
425 | 463 | ||
426 | /* looks like: "pnp:dD" */ | 464 | /* looks like: "pnp:dD" */ |
427 | static void do_pnp_device_entry(void *symval, unsigned long size, | 465 | static void do_pnp_device_entry(void *symval, unsigned long size, |
@@ -544,8 +582,7 @@ static int do_pcmcia_entry(const char *filename, | |||
544 | add_wildcard(alias); | 582 | add_wildcard(alias); |
545 | return 1; | 583 | return 1; |
546 | } | 584 | } |
547 | 585 | ADD_TO_DEVTABLE("pcmcia", struct pcmcia_device_id, do_pcmcia_entry); | |
548 | |||
549 | 586 | ||
550 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) | 587 | static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) |
551 | { | 588 | { |
@@ -568,6 +605,7 @@ static int do_of_entry (const char *filename, struct of_device_id *of, char *ali | |||
568 | add_wildcard(alias); | 605 | add_wildcard(alias); |
569 | return 1; | 606 | return 1; |
570 | } | 607 | } |
608 | ADD_TO_DEVTABLE("of", struct of_device_id, do_of_entry); | ||
571 | 609 | ||
572 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, | 610 | static int do_vio_entry(const char *filename, struct vio_device_id *vio, |
573 | char *alias) | 611 | char *alias) |
@@ -585,6 +623,7 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio, | |||
585 | add_wildcard(alias); | 623 | add_wildcard(alias); |
586 | return 1; | 624 | return 1; |
587 | } | 625 | } |
626 | ADD_TO_DEVTABLE("vio", struct vio_device_id, do_vio_entry); | ||
588 | 627 | ||
589 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 628 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
590 | 629 | ||
@@ -640,6 +679,7 @@ static int do_input_entry(const char *filename, struct input_device_id *id, | |||
640 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); | 679 | do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); |
641 | return 1; | 680 | return 1; |
642 | } | 681 | } |
682 | ADD_TO_DEVTABLE("input", struct input_device_id, do_input_entry); | ||
643 | 683 | ||
644 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | 684 | static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, |
645 | char *alias) | 685 | char *alias) |
@@ -650,6 +690,7 @@ static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa, | |||
650 | strcat(alias, "*"); | 690 | strcat(alias, "*"); |
651 | return 1; | 691 | return 1; |
652 | } | 692 | } |
693 | ADD_TO_DEVTABLE("eisa", struct eisa_device_id, do_eisa_entry); | ||
653 | 694 | ||
654 | /* Looks like: parisc:tNhvNrevNsvN */ | 695 | /* Looks like: parisc:tNhvNrevNsvN */ |
655 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | 696 | static int do_parisc_entry(const char *filename, struct parisc_device_id *id, |
@@ -669,6 +710,7 @@ static int do_parisc_entry(const char *filename, struct parisc_device_id *id, | |||
669 | add_wildcard(alias); | 710 | add_wildcard(alias); |
670 | return 1; | 711 | return 1; |
671 | } | 712 | } |
713 | ADD_TO_DEVTABLE("parisc", struct parisc_device_id, do_parisc_entry); | ||
672 | 714 | ||
673 | /* Looks like: sdio:cNvNdN. */ | 715 | /* Looks like: sdio:cNvNdN. */ |
674 | static int do_sdio_entry(const char *filename, | 716 | static int do_sdio_entry(const char *filename, |
@@ -685,6 +727,7 @@ static int do_sdio_entry(const char *filename, | |||
685 | add_wildcard(alias); | 727 | add_wildcard(alias); |
686 | return 1; | 728 | return 1; |
687 | } | 729 | } |
730 | ADD_TO_DEVTABLE("sdio", struct sdio_device_id, do_sdio_entry); | ||
688 | 731 | ||
689 | /* Looks like: ssb:vNidNrevN. */ | 732 | /* Looks like: ssb:vNidNrevN. */ |
690 | static int do_ssb_entry(const char *filename, | 733 | static int do_ssb_entry(const char *filename, |
@@ -701,6 +744,7 @@ static int do_ssb_entry(const char *filename, | |||
701 | add_wildcard(alias); | 744 | add_wildcard(alias); |
702 | return 1; | 745 | return 1; |
703 | } | 746 | } |
747 | ADD_TO_DEVTABLE("ssb", struct ssb_device_id, do_ssb_entry); | ||
704 | 748 | ||
705 | /* Looks like: bcma:mNidNrevNclN. */ | 749 | /* Looks like: bcma:mNidNrevNclN. */ |
706 | static int do_bcma_entry(const char *filename, | 750 | static int do_bcma_entry(const char *filename, |
@@ -719,6 +763,7 @@ static int do_bcma_entry(const char *filename, | |||
719 | add_wildcard(alias); | 763 | add_wildcard(alias); |
720 | return 1; | 764 | return 1; |
721 | } | 765 | } |
766 | ADD_TO_DEVTABLE("bcma", struct bcma_device_id, do_bcma_entry); | ||
722 | 767 | ||
723 | /* Looks like: virtio:dNvN */ | 768 | /* Looks like: virtio:dNvN */ |
724 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | 769 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, |
@@ -734,6 +779,7 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | |||
734 | add_wildcard(alias); | 779 | add_wildcard(alias); |
735 | return 1; | 780 | return 1; |
736 | } | 781 | } |
782 | ADD_TO_DEVTABLE("virtio", struct virtio_device_id, do_virtio_entry); | ||
737 | 783 | ||
738 | /* | 784 | /* |
739 | * Looks like: vmbus:guid | 785 | * Looks like: vmbus:guid |
@@ -755,6 +801,7 @@ static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, | |||
755 | 801 | ||
756 | return 1; | 802 | return 1; |
757 | } | 803 | } |
804 | ADD_TO_DEVTABLE("vmbus", struct hv_vmbus_device_id, do_vmbus_entry); | ||
758 | 805 | ||
759 | /* Looks like: i2c:S */ | 806 | /* Looks like: i2c:S */ |
760 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | 807 | static int do_i2c_entry(const char *filename, struct i2c_device_id *id, |
@@ -764,6 +811,7 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | |||
764 | 811 | ||
765 | return 1; | 812 | return 1; |
766 | } | 813 | } |
814 | ADD_TO_DEVTABLE("i2c", struct i2c_device_id, do_i2c_entry); | ||
767 | 815 | ||
768 | /* Looks like: spi:S */ | 816 | /* Looks like: spi:S */ |
769 | static int do_spi_entry(const char *filename, struct spi_device_id *id, | 817 | static int do_spi_entry(const char *filename, struct spi_device_id *id, |
@@ -773,6 +821,17 @@ static int do_spi_entry(const char *filename, struct spi_device_id *id, | |||
773 | 821 | ||
774 | return 1; | 822 | return 1; |
775 | } | 823 | } |
824 | ADD_TO_DEVTABLE("spi", struct spi_device_id, do_spi_entry); | ||
825 | |||
826 | /* Looks like: mcp:S */ | ||
827 | static int do_mcp_entry(const char *filename, struct mcp_device_id *id, | ||
828 | char *alias) | ||
829 | { | ||
830 | sprintf(alias, MCP_MODULE_PREFIX "%s", id->name); | ||
831 | |||
832 | return 1; | ||
833 | } | ||
834 | ADD_TO_DEVTABLE("mcp", struct mcp_device_id, do_mcp_entry); | ||
776 | 835 | ||
777 | static const struct dmifield { | 836 | static const struct dmifield { |
778 | const char *prefix; | 837 | const char *prefix; |
@@ -827,6 +886,7 @@ static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | |||
827 | strcat(alias, ":"); | 886 | strcat(alias, ":"); |
828 | return 1; | 887 | return 1; |
829 | } | 888 | } |
889 | ADD_TO_DEVTABLE("dmi", struct dmi_system_id, do_dmi_entry); | ||
830 | 890 | ||
831 | static int do_platform_entry(const char *filename, | 891 | static int do_platform_entry(const char *filename, |
832 | struct platform_device_id *id, char *alias) | 892 | struct platform_device_id *id, char *alias) |
@@ -834,6 +894,7 @@ static int do_platform_entry(const char *filename, | |||
834 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); | 894 | sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); |
835 | return 1; | 895 | return 1; |
836 | } | 896 | } |
897 | ADD_TO_DEVTABLE("platform", struct platform_device_id, do_platform_entry); | ||
837 | 898 | ||
838 | static int do_mdio_entry(const char *filename, | 899 | static int do_mdio_entry(const char *filename, |
839 | struct mdio_device_id *id, char *alias) | 900 | struct mdio_device_id *id, char *alias) |
@@ -856,6 +917,7 @@ static int do_mdio_entry(const char *filename, | |||
856 | 917 | ||
857 | return 1; | 918 | return 1; |
858 | } | 919 | } |
920 | ADD_TO_DEVTABLE("mdio", struct mdio_device_id, do_mdio_entry); | ||
859 | 921 | ||
860 | /* Looks like: zorro:iN. */ | 922 | /* Looks like: zorro:iN. */ |
861 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | 923 | static int do_zorro_entry(const char *filename, struct zorro_device_id *id, |
@@ -866,6 +928,7 @@ static int do_zorro_entry(const char *filename, struct zorro_device_id *id, | |||
866 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); | 928 | ADD(alias, "i", id->id != ZORRO_WILDCARD, id->id); |
867 | return 1; | 929 | return 1; |
868 | } | 930 | } |
931 | ADD_TO_DEVTABLE("zorro", struct zorro_device_id, do_zorro_entry); | ||
869 | 932 | ||
870 | /* looks like: "pnp:dD" */ | 933 | /* looks like: "pnp:dD" */ |
871 | static int do_isapnp_entry(const char *filename, | 934 | static int do_isapnp_entry(const char *filename, |
@@ -879,16 +942,84 @@ static int do_isapnp_entry(const char *filename, | |||
879 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); | 942 | (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f); |
880 | return 1; | 943 | return 1; |
881 | } | 944 | } |
945 | ADD_TO_DEVTABLE("isa", struct isapnp_device_id, do_isapnp_entry); | ||
882 | 946 | ||
883 | /* Ignore any prefix, eg. some architectures prepend _ */ | 947 | /* |
884 | static inline int sym_is(const char *symbol, const char *name) | 948 | * Append a match expression for a single masked hex digit. |
949 | * outp points to a pointer to the character at which to append. | ||
950 | * *outp is updated on return to point just after the appended text, | ||
951 | * to facilitate further appending. | ||
952 | */ | ||
953 | static void append_nibble_mask(char **outp, | ||
954 | unsigned int nibble, unsigned int mask) | ||
885 | { | 955 | { |
886 | const char *match; | 956 | char *p = *outp; |
957 | unsigned int i; | ||
887 | 958 | ||
888 | match = strstr(symbol, name); | 959 | switch (mask) { |
889 | if (!match) | 960 | case 0: |
890 | return 0; | 961 | *p++ = '?'; |
891 | return match[strlen(name)] == '\0'; | 962 | break; |
963 | |||
964 | case 0xf: | ||
965 | p += sprintf(p, "%X", nibble); | ||
966 | break; | ||
967 | |||
968 | default: | ||
969 | /* | ||
970 | * Dumbly emit a match pattern for all possible matching | ||
971 | * digits. This could be improved in some cases using ranges, | ||
972 | * but it has the advantage of being trivially correct, and is | ||
973 | * often optimal. | ||
974 | */ | ||
975 | *p++ = '['; | ||
976 | for (i = 0; i < 0x10; i++) | ||
977 | if ((i & mask) == nibble) | ||
978 | p += sprintf(p, "%X", i); | ||
979 | *p++ = ']'; | ||
980 | } | ||
981 | |||
982 | /* Ensure that the string remains NUL-terminated: */ | ||
983 | *p = '\0'; | ||
984 | |||
985 | /* Advance the caller's end-of-string pointer: */ | ||
986 | *outp = p; | ||
987 | } | ||
988 | |||
989 | /* | ||
990 | * looks like: "amba:dN" | ||
991 | * | ||
992 | * N is exactly 8 digits, where each is an upper-case hex digit, or | ||
993 | * a ? or [] pattern matching exactly one digit. | ||
994 | */ | ||
995 | static int do_amba_entry(const char *filename, | ||
996 | struct amba_id *id, char *alias) | ||
997 | { | ||
998 | unsigned int digit; | ||
999 | char *p = alias; | ||
1000 | |||
1001 | if ((id->id & id->mask) != id->id) | ||
1002 | fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " | ||
1003 | "id=0x%08X, mask=0x%08X. Please fix this driver.\n", | ||
1004 | filename, id->id, id->mask); | ||
1005 | |||
1006 | p += sprintf(alias, "amba:d"); | ||
1007 | for (digit = 0; digit < 8; digit++) | ||
1008 | append_nibble_mask(&p, | ||
1009 | (id->id >> (4 * (7 - digit))) & 0xf, | ||
1010 | (id->mask >> (4 * (7 - digit))) & 0xf); | ||
1011 | |||
1012 | return 1; | ||
1013 | } | ||
1014 | ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); | ||
1015 | |||
1016 | /* Does namelen bytes of name exactly match the symbol? */ | ||
1017 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | ||
1018 | { | ||
1019 | if (namelen != strlen(symbol)) | ||
1020 | return false; | ||
1021 | |||
1022 | return memcmp(name, symbol, namelen) == 0; | ||
892 | } | 1023 | } |
893 | 1024 | ||
894 | static void do_table(void *symval, unsigned long size, | 1025 | static void do_table(void *symval, unsigned long size, |
@@ -921,11 +1052,25 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
921 | { | 1052 | { |
922 | void *symval; | 1053 | void *symval; |
923 | char *zeros = NULL; | 1054 | char *zeros = NULL; |
1055 | const char *name; | ||
1056 | unsigned int namelen; | ||
924 | 1057 | ||
925 | /* We're looking for a section relative symbol */ | 1058 | /* We're looking for a section relative symbol */ |
926 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) | 1059 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
927 | return; | 1060 | return; |
928 | 1061 | ||
1062 | /* All our symbols are of form <prefix>__mod_XXX_device_table. */ | ||
1063 | name = strstr(symname, "__mod_"); | ||
1064 | if (!name) | ||
1065 | return; | ||
1066 | name += strlen("__mod_"); | ||
1067 | namelen = strlen(name); | ||
1068 | if (namelen < strlen("_device_table")) | ||
1069 | return; | ||
1070 | if (strcmp(name + namelen - strlen("_device_table"), "_device_table")) | ||
1071 | return; | ||
1072 | namelen -= strlen("_device_table"); | ||
1073 | |||
929 | /* Handle all-NULL symbols allocated into .bss */ | 1074 | /* Handle all-NULL symbols allocated into .bss */ |
930 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { | 1075 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
931 | zeros = calloc(1, sym->st_size); | 1076 | zeros = calloc(1, sym->st_size); |
@@ -936,117 +1081,24 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
936 | + sym->st_value; | 1081 | + sym->st_value; |
937 | } | 1082 | } |
938 | 1083 | ||
939 | if (sym_is(symname, "__mod_pci_device_table")) | 1084 | /* First handle the "special" cases */ |
940 | do_table(symval, sym->st_size, | 1085 | if (sym_is(name, namelen, "usb")) |
941 | sizeof(struct pci_device_id), "pci", | ||
942 | do_pci_entry, mod); | ||
943 | else if (sym_is(symname, "__mod_usb_device_table")) | ||
944 | /* special case to handle bcdDevice ranges */ | ||
945 | do_usb_table(symval, sym->st_size, mod); | 1086 | do_usb_table(symval, sym->st_size, mod); |
946 | else if (sym_is(symname, "__mod_hid_device_table")) | 1087 | else if (sym_is(name, namelen, "pnp")) |
947 | do_table(symval, sym->st_size, | ||
948 | sizeof(struct hid_device_id), "hid", | ||
949 | do_hid_entry, mod); | ||
950 | else if (sym_is(symname, "__mod_ieee1394_device_table")) | ||
951 | do_table(symval, sym->st_size, | ||
952 | sizeof(struct ieee1394_device_id), "ieee1394", | ||
953 | do_ieee1394_entry, mod); | ||
954 | else if (sym_is(symname, "__mod_ccw_device_table")) | ||
955 | do_table(symval, sym->st_size, | ||
956 | sizeof(struct ccw_device_id), "ccw", | ||
957 | do_ccw_entry, mod); | ||
958 | else if (sym_is(symname, "__mod_ap_device_table")) | ||
959 | do_table(symval, sym->st_size, | ||
960 | sizeof(struct ap_device_id), "ap", | ||
961 | do_ap_entry, mod); | ||
962 | else if (sym_is(symname, "__mod_css_device_table")) | ||
963 | do_table(symval, sym->st_size, | ||
964 | sizeof(struct css_device_id), "css", | ||
965 | do_css_entry, mod); | ||
966 | else if (sym_is(symname, "__mod_serio_device_table")) | ||
967 | do_table(symval, sym->st_size, | ||
968 | sizeof(struct serio_device_id), "serio", | ||
969 | do_serio_entry, mod); | ||
970 | else if (sym_is(symname, "__mod_acpi_device_table")) | ||
971 | do_table(symval, sym->st_size, | ||
972 | sizeof(struct acpi_device_id), "acpi", | ||
973 | do_acpi_entry, mod); | ||
974 | else if (sym_is(symname, "__mod_pnp_device_table")) | ||
975 | do_pnp_device_entry(symval, sym->st_size, mod); | 1088 | do_pnp_device_entry(symval, sym->st_size, mod); |
976 | else if (sym_is(symname, "__mod_pnp_card_device_table")) | 1089 | else if (sym_is(name, namelen, "pnp_card")) |
977 | do_pnp_card_entries(symval, sym->st_size, mod); | 1090 | do_pnp_card_entries(symval, sym->st_size, mod); |
978 | else if (sym_is(symname, "__mod_pcmcia_device_table")) | 1091 | else { |
979 | do_table(symval, sym->st_size, | 1092 | struct devtable **p; |
980 | sizeof(struct pcmcia_device_id), "pcmcia", | 1093 | |
981 | do_pcmcia_entry, mod); | 1094 | for (p = __start___devtable; p < __stop___devtable; p++) { |
982 | else if (sym_is(symname, "__mod_of_device_table")) | 1095 | if (sym_is(name, namelen, (*p)->device_id)) { |
983 | do_table(symval, sym->st_size, | 1096 | do_table(symval, sym->st_size, (*p)->id_size, |
984 | sizeof(struct of_device_id), "of", | 1097 | (*p)->device_id, (*p)->function, mod); |
985 | do_of_entry, mod); | 1098 | break; |
986 | else if (sym_is(symname, "__mod_vio_device_table")) | 1099 | } |
987 | do_table(symval, sym->st_size, | 1100 | } |
988 | sizeof(struct vio_device_id), "vio", | 1101 | } |
989 | do_vio_entry, mod); | ||
990 | else if (sym_is(symname, "__mod_input_device_table")) | ||
991 | do_table(symval, sym->st_size, | ||
992 | sizeof(struct input_device_id), "input", | ||
993 | do_input_entry, mod); | ||
994 | else if (sym_is(symname, "__mod_eisa_device_table")) | ||
995 | do_table(symval, sym->st_size, | ||
996 | sizeof(struct eisa_device_id), "eisa", | ||
997 | do_eisa_entry, mod); | ||
998 | else if (sym_is(symname, "__mod_parisc_device_table")) | ||
999 | do_table(symval, sym->st_size, | ||
1000 | sizeof(struct parisc_device_id), "parisc", | ||
1001 | do_parisc_entry, mod); | ||
1002 | else if (sym_is(symname, "__mod_sdio_device_table")) | ||
1003 | do_table(symval, sym->st_size, | ||
1004 | sizeof(struct sdio_device_id), "sdio", | ||
1005 | do_sdio_entry, mod); | ||
1006 | else if (sym_is(symname, "__mod_ssb_device_table")) | ||
1007 | do_table(symval, sym->st_size, | ||
1008 | sizeof(struct ssb_device_id), "ssb", | ||
1009 | do_ssb_entry, mod); | ||
1010 | else if (sym_is(symname, "__mod_bcma_device_table")) | ||
1011 | do_table(symval, sym->st_size, | ||
1012 | sizeof(struct bcma_device_id), "bcma", | ||
1013 | do_bcma_entry, mod); | ||
1014 | else if (sym_is(symname, "__mod_virtio_device_table")) | ||
1015 | do_table(symval, sym->st_size, | ||
1016 | sizeof(struct virtio_device_id), "virtio", | ||
1017 | do_virtio_entry, mod); | ||
1018 | else if (sym_is(symname, "__mod_vmbus_device_table")) | ||
1019 | do_table(symval, sym->st_size, | ||
1020 | sizeof(struct hv_vmbus_device_id), "vmbus", | ||
1021 | do_vmbus_entry, mod); | ||
1022 | else if (sym_is(symname, "__mod_i2c_device_table")) | ||
1023 | do_table(symval, sym->st_size, | ||
1024 | sizeof(struct i2c_device_id), "i2c", | ||
1025 | do_i2c_entry, mod); | ||
1026 | else if (sym_is(symname, "__mod_spi_device_table")) | ||
1027 | do_table(symval, sym->st_size, | ||
1028 | sizeof(struct spi_device_id), "spi", | ||
1029 | do_spi_entry, mod); | ||
1030 | else if (sym_is(symname, "__mod_dmi_device_table")) | ||
1031 | do_table(symval, sym->st_size, | ||
1032 | sizeof(struct dmi_system_id), "dmi", | ||
1033 | do_dmi_entry, mod); | ||
1034 | else if (sym_is(symname, "__mod_platform_device_table")) | ||
1035 | do_table(symval, sym->st_size, | ||
1036 | sizeof(struct platform_device_id), "platform", | ||
1037 | do_platform_entry, mod); | ||
1038 | else if (sym_is(symname, "__mod_mdio_device_table")) | ||
1039 | do_table(symval, sym->st_size, | ||
1040 | sizeof(struct mdio_device_id), "mdio", | ||
1041 | do_mdio_entry, mod); | ||
1042 | else if (sym_is(symname, "__mod_zorro_device_table")) | ||
1043 | do_table(symval, sym->st_size, | ||
1044 | sizeof(struct zorro_device_id), "zorro", | ||
1045 | do_zorro_entry, mod); | ||
1046 | else if (sym_is(symname, "__mod_isapnp_device_table")) | ||
1047 | do_table(symval, sym->st_size, | ||
1048 | sizeof(struct isapnp_device_id), "isa", | ||
1049 | do_isapnp_entry, mod); | ||
1050 | free(zeros); | 1102 | free(zeros); |
1051 | } | 1103 | } |
1052 | 1104 | ||