diff options
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/file2alias.c | 75 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 9 |
2 files changed, 84 insertions, 0 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 4c9890ec2528..d4dc222a74f3 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -206,6 +206,20 @@ static void do_usb_table(void *symval, unsigned long size, | |||
206 | do_usb_entry_multi(symval + i, mod); | 206 | do_usb_entry_multi(symval + i, mod); |
207 | } | 207 | } |
208 | 208 | ||
209 | /* Looks like: hid:bNvNpN */ | ||
210 | static int do_hid_entry(const char *filename, | ||
211 | struct hid_device_id *id, char *alias) | ||
212 | { | ||
213 | id->vendor = TO_NATIVE(id->vendor); | ||
214 | id->product = TO_NATIVE(id->product); | ||
215 | |||
216 | sprintf(alias, "hid:b%04X", id->bus); | ||
217 | ADD(alias, "v", id->vendor != HID_ANY_ID, id->vendor); | ||
218 | ADD(alias, "p", id->product != HID_ANY_ID, id->product); | ||
219 | |||
220 | return 1; | ||
221 | } | ||
222 | |||
209 | /* Looks like: ieee1394:venNmoNspNverN */ | 223 | /* Looks like: ieee1394:venNmoNspNverN */ |
210 | static int do_ieee1394_entry(const char *filename, | 224 | static int do_ieee1394_entry(const char *filename, |
211 | struct ieee1394_device_id *id, char *alias) | 225 | struct ieee1394_device_id *id, char *alias) |
@@ -629,6 +643,59 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | |||
629 | return 1; | 643 | return 1; |
630 | } | 644 | } |
631 | 645 | ||
646 | static const struct dmifield { | ||
647 | const char *prefix; | ||
648 | int field; | ||
649 | } dmi_fields[] = { | ||
650 | { "bvn", DMI_BIOS_VENDOR }, | ||
651 | { "bvr", DMI_BIOS_VERSION }, | ||
652 | { "bd", DMI_BIOS_DATE }, | ||
653 | { "svn", DMI_SYS_VENDOR }, | ||
654 | { "pn", DMI_PRODUCT_NAME }, | ||
655 | { "pvr", DMI_PRODUCT_VERSION }, | ||
656 | { "rvn", DMI_BOARD_VENDOR }, | ||
657 | { "rn", DMI_BOARD_NAME }, | ||
658 | { "rvr", DMI_BOARD_VERSION }, | ||
659 | { "cvn", DMI_CHASSIS_VENDOR }, | ||
660 | { "ct", DMI_CHASSIS_TYPE }, | ||
661 | { "cvr", DMI_CHASSIS_VERSION }, | ||
662 | { NULL, DMI_NONE } | ||
663 | }; | ||
664 | |||
665 | static void dmi_ascii_filter(char *d, const char *s) | ||
666 | { | ||
667 | /* Filter out characters we don't want to see in the modalias string */ | ||
668 | for (; *s; s++) | ||
669 | if (*s > ' ' && *s < 127 && *s != ':') | ||
670 | *(d++) = *s; | ||
671 | |||
672 | *d = 0; | ||
673 | } | ||
674 | |||
675 | |||
676 | static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | ||
677 | char *alias) | ||
678 | { | ||
679 | int i, j; | ||
680 | |||
681 | sprintf(alias, "dmi*"); | ||
682 | |||
683 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { | ||
684 | for (j = 0; j < 4; j++) { | ||
685 | if (id->matches[j].slot && | ||
686 | id->matches[j].slot == dmi_fields[i].field) { | ||
687 | sprintf(alias + strlen(alias), ":%s*", | ||
688 | dmi_fields[i].prefix); | ||
689 | dmi_ascii_filter(alias + strlen(alias), | ||
690 | id->matches[j].substr); | ||
691 | strcat(alias, "*"); | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | |||
696 | strcat(alias, ":"); | ||
697 | return 1; | ||
698 | } | ||
632 | /* Ignore any prefix, eg. some architectures prepend _ */ | 699 | /* Ignore any prefix, eg. some architectures prepend _ */ |
633 | static inline int sym_is(const char *symbol, const char *name) | 700 | static inline int sym_is(const char *symbol, const char *name) |
634 | { | 701 | { |
@@ -692,6 +759,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
692 | else if (sym_is(symname, "__mod_usb_device_table")) | 759 | else if (sym_is(symname, "__mod_usb_device_table")) |
693 | /* special case to handle bcdDevice ranges */ | 760 | /* special case to handle bcdDevice ranges */ |
694 | do_usb_table(symval, sym->st_size, mod); | 761 | do_usb_table(symval, sym->st_size, mod); |
762 | else if (sym_is(symname, "__mod_hid_device_table")) | ||
763 | do_table(symval, sym->st_size, | ||
764 | sizeof(struct hid_device_id), "hid", | ||
765 | do_hid_entry, mod); | ||
695 | else if (sym_is(symname, "__mod_ieee1394_device_table")) | 766 | else if (sym_is(symname, "__mod_ieee1394_device_table")) |
696 | do_table(symval, sym->st_size, | 767 | do_table(symval, sym->st_size, |
697 | sizeof(struct ieee1394_device_id), "ieee1394", | 768 | sizeof(struct ieee1394_device_id), "ieee1394", |
@@ -760,6 +831,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
760 | do_table(symval, sym->st_size, | 831 | do_table(symval, sym->st_size, |
761 | sizeof(struct i2c_device_id), "i2c", | 832 | sizeof(struct i2c_device_id), "i2c", |
762 | do_i2c_entry, mod); | 833 | do_i2c_entry, mod); |
834 | else if (sym_is(symname, "__mod_dmi_device_table")) | ||
835 | do_table(symval, sym->st_size, | ||
836 | sizeof(struct dmi_system_id), "dmi", | ||
837 | do_dmi_entry, mod); | ||
763 | free(zeros); | 838 | free(zeros); |
764 | } | 839 | } |
765 | 840 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8e0de6a5e18a..88921611b22e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -1726,6 +1726,14 @@ static void add_header(struct buffer *b, struct module *mod) | |||
1726 | buf_printf(b, "};\n"); | 1726 | buf_printf(b, "};\n"); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void add_staging_flag(struct buffer *b, const char *name) | ||
1730 | { | ||
1731 | static const char *staging_dir = "drivers/staging"; | ||
1732 | |||
1733 | if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) | ||
1734 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); | ||
1735 | } | ||
1736 | |||
1729 | /** | 1737 | /** |
1730 | * Record CRCs for unresolved symbols | 1738 | * Record CRCs for unresolved symbols |
1731 | **/ | 1739 | **/ |
@@ -2135,6 +2143,7 @@ int main(int argc, char **argv) | |||
2135 | buf.pos = 0; | 2143 | buf.pos = 0; |
2136 | 2144 | ||
2137 | add_header(&buf, mod); | 2145 | add_header(&buf, mod); |
2146 | add_staging_flag(&buf, mod->name); | ||
2138 | err |= add_versions(&buf, mod); | 2147 | err |= add_versions(&buf, mod); |
2139 | add_depends(&buf, mod, modules); | 2148 | add_depends(&buf, mod, modules); |
2140 | add_moddevtable(&buf, mod); | 2149 | add_moddevtable(&buf, mod); |