diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-09-16 19:23:28 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-10-13 11:05:06 -0400 |
commit | d945b697d0eea5a811ec299c5f1a25889bb0242b (patch) | |
tree | e9f902122c05a174eac04464b145bd7a69f261dc /scripts/mod/file2alias.c | |
parent | 9d5a9e74655b9d04d0ec9c8e47801163b7b74211 (diff) |
Automatic MODULE_ALIAS() for DMI match tables.
This makes modpost handle MODULE_DEVICE_TABLE(dmi, xxxx).
I had to change the string pointers in the match table to char arrays,
and picked a size of 79 bytes almost at random -- do we need to make it
bigger than that? I was a bit concerned about the 'bloat' this
introduces into the match tables, but they should all be __initdata so
it shouldn't matter too much.
(Actually, modpost does go through the relocations and look at most of
them; it wouldn't be impossible to make it handle string pointers -- but
doesn't seem to be worth the effort, since they're __initdata).
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r-- | scripts/mod/file2alias.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 4c9890ec2528..473f94e56ead 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -629,6 +629,59 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | |||
629 | return 1; | 629 | return 1; |
630 | } | 630 | } |
631 | 631 | ||
632 | static const struct dmifield { | ||
633 | const char *prefix; | ||
634 | int field; | ||
635 | } dmi_fields[] = { | ||
636 | { "bvn", DMI_BIOS_VENDOR }, | ||
637 | { "bvr", DMI_BIOS_VERSION }, | ||
638 | { "bd", DMI_BIOS_DATE }, | ||
639 | { "svn", DMI_SYS_VENDOR }, | ||
640 | { "pn", DMI_PRODUCT_NAME }, | ||
641 | { "pvr", DMI_PRODUCT_VERSION }, | ||
642 | { "rvn", DMI_BOARD_VENDOR }, | ||
643 | { "rn", DMI_BOARD_NAME }, | ||
644 | { "rvr", DMI_BOARD_VERSION }, | ||
645 | { "cvn", DMI_CHASSIS_VENDOR }, | ||
646 | { "ct", DMI_CHASSIS_TYPE }, | ||
647 | { "cvr", DMI_CHASSIS_VERSION }, | ||
648 | { NULL, DMI_NONE } | ||
649 | }; | ||
650 | |||
651 | static void dmi_ascii_filter(char *d, const char *s) | ||
652 | { | ||
653 | /* Filter out characters we don't want to see in the modalias string */ | ||
654 | for (; *s; s++) | ||
655 | if (*s > ' ' && *s < 127 && *s != ':') | ||
656 | *(d++) = *s; | ||
657 | |||
658 | *d = 0; | ||
659 | } | ||
660 | |||
661 | |||
662 | static int do_dmi_entry(const char *filename, struct dmi_system_id *id, | ||
663 | char *alias) | ||
664 | { | ||
665 | int i, j; | ||
666 | |||
667 | sprintf(alias, "dmi*"); | ||
668 | |||
669 | for (i = 0; i < ARRAY_SIZE(dmi_fields); i++) { | ||
670 | for (j = 0; j < 4; j++) { | ||
671 | if (id->matches[j].slot && | ||
672 | id->matches[j].slot == dmi_fields[i].field) { | ||
673 | sprintf(alias + strlen(alias), ":%s*", | ||
674 | dmi_fields[i].prefix); | ||
675 | dmi_ascii_filter(alias + strlen(alias), | ||
676 | id->matches[j].substr); | ||
677 | strcat(alias, "*"); | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | |||
682 | strcat(alias, ":"); | ||
683 | return 1; | ||
684 | } | ||
632 | /* Ignore any prefix, eg. some architectures prepend _ */ | 685 | /* Ignore any prefix, eg. some architectures prepend _ */ |
633 | static inline int sym_is(const char *symbol, const char *name) | 686 | static inline int sym_is(const char *symbol, const char *name) |
634 | { | 687 | { |
@@ -760,6 +813,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
760 | do_table(symval, sym->st_size, | 813 | do_table(symval, sym->st_size, |
761 | sizeof(struct i2c_device_id), "i2c", | 814 | sizeof(struct i2c_device_id), "i2c", |
762 | do_i2c_entry, mod); | 815 | do_i2c_entry, mod); |
816 | else if (sym_is(symname, "__mod_dmi_device_table")) | ||
817 | do_table(symval, sym->st_size, | ||
818 | sizeof(struct dmi_system_id), "dmi", | ||
819 | do_dmi_entry, mod); | ||
763 | free(zeros); | 820 | free(zeros); |
764 | } | 821 | } |
765 | 822 | ||