From b1d2675a6466090b68d4ef63f9237b4d70a18857 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 17 Feb 2008 14:12:10 +0100 Subject: kbuild: fix reversed symbol name order in modpost XXXINIT_TO_INIT and XXXEXIT_TO_EXIT warnings use the reversed symbol name order in the suggestion, e.g.: WARNING: vmlinux.o(.meminit.text+0x36c): Section mismatch in reference from the function free_area_init_core() to the function .init.text:setup_usemap() The function __meminit free_area_init_core() references a function __init setup_usemap(). If free_area_init_core is only used by setup_usemap then annotate free_area_init_core with a matching annotation. Signed-off-by: Geert Uytterhoeven Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/mod') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 61742771c65..695b5d657cf 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1200,7 +1200,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch, "annotate %s with a matching annotation.\n", from, sec2annotation(fromsec), fromsym, from_p, to, sec2annotation(tosec), tosym, to_p, - fromsym, tosym, fromsym); + tosym, fromsym, tosym); break; case INIT_TO_EXIT: fprintf(stderr, -- cgit v1.2.3 From 4ce6efed48d736e3384c39ff87bda723e1f8e041 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 23 Mar 2008 21:38:54 +0100 Subject: kbuild: soften modpost checks when doing cross builds The module alias support in the kernel have a consistency check where it is checked that the size of a structure in the kernel and on the build host are the same. For cross builds this check does not make sense so detect when we do cross builds and silently skip the check in these situations. This fixes a build bug for a wireless driver when cross building for arm. Acked-by: Michael Buesch Tested-by: Gordon Farquharson Signed-off-by: Sam Ravnborg Cc: stable@kernel.org --- scripts/mod/file2alias.c | 4 ++++ scripts/mod/modpost.c | 5 ++++- scripts/mod/modpost.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts/mod') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 9ddf944cce2..348d8687b7c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -51,11 +51,13 @@ do { \ sprintf(str + strlen(str), "*"); \ } while(0) +unsigned int cross_build = 0; /** * Check that sizeof(device_id type) are consistent with size of section * in .o file. If in-consistent then userspace and kernel does not agree * on actual size which is a bug. * Also verify that the final entry in the table is all zeros. + * Ignore both checks if build host differ from target host and size differs. **/ static void device_id_check(const char *modname, const char *device_id, unsigned long size, unsigned long id_size, @@ -64,6 +66,8 @@ static void device_id_check(const char *modname, const char *device_id, int i; if (size % id_size || size < id_size) { + if (cross_build != 0) + return; fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " "of the size of section __mod_%s_device_table=%lu.\n" "Fix definition of struct %s_device_id " diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 695b5d657cf..110cf243fa4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2026,7 +2026,7 @@ int main(int argc, char **argv) int opt; int err; - while ((opt = getopt(argc, argv, "i:I:msSo:awM:K:")) != -1) { + while ((opt = getopt(argc, argv, "i:I:cmsSo:awM:K:")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2035,6 +2035,9 @@ int main(int argc, char **argv) module_read = optarg; external_module = 1; break; + case 'c': + cross_build = 1; + break; case 'm': modversions = 1; break; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 565c5872407..09f58e33d22 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -135,6 +135,7 @@ struct elf_info { }; /* file2alias.c */ +extern unsigned int cross_build; void handle_moddevtable(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname); void add_moddevtable(struct buffer *buf, struct module *mod); -- cgit v1.2.3 From 0c81eed4b9d6273124c7ab5eb99760b4d3a3cb9e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Thu, 21 Feb 2008 00:35:54 +0100 Subject: PNP: add all PNP card device id's as individual aliases The current PNP combined card + devices module aliase can never ever match anything, because these values are not available all at the same time to request a module. Instead of adding the combined alias, we add the device id's all as individual aliases. Device id's are exported by the PNP bus and can now properly used to request the loading of a matching module. The module snd-sbawe currently exports aliases, which can never match anything: alias: pnp:cCTLXXXXdCTL0045dCTL0022* alias: pnp:cCTLXXXXdCTL0044dCTL0023* alias: pnp:cCTLXXXXdCTL0042dCTL0022* alias: pnp:cCTLXXXXdCTL0041dCTL0021* alias: pnp:cCTLXXXXdCTL0031dCTL0021* alias: pnp:cCTL00eddCTL0041dCTL0070* alias: pnp:cCTL00e9dCTL0045dCTL0022* alias: pnp:cCTL00e4dCTL0045dCTL0022* alias: pnp:cCTL00c7dCTL0045dCTL0022* alias: pnp:cCTL00c5dCTL0045dCTL0022* alias: pnp:cCTL00c3dCTL0045dCTL0022* alias: pnp:cCTL00c1dCTL0042dCTL0022* alias: pnp:cCTL00b2dCTL0044dCTL0023* alias: pnp:cCTL009edCTL0044dCTL0023* alias: pnp:cCTL009ddCTL0042dCTL0022* alias: pnp:cCTL009fdCTL0041dCTL0021* alias: pnp:cCTL009cdCTL0041dCTL0021* alias: pnp:cCTL009adCTL0041dCTL0021* alias: pnp:cCTL0054dCTL0031dCTL0021* alias: pnp:cCTL0048dCTL0031dCTL0021* alias: pnp:cCTL0047dCTL0031dCTL0021* alias: pnp:cCTL0046dCTL0031dCTL0021* alias: pnp:cCTL0045dCTL0031dCTL0021* alias: pnp:cCTL0044dCTL0031dCTL0021* alias: pnp:cCTL0043dCTL0031dCTL0021* alias: pnp:cCTL0042dCTL0031dCTL0021* alias: pnp:cCTL0039dCTL0031dCTL0021* alias: pnp:cCTL0035dCTL0031dCTL0021* With this patch it exports only the device id's, as properly matchable aliases: alias: pnp:dCTL0070* alias: pnp:dCTL0045* alias: pnp:dCTL0023* alias: pnp:dCTL0044* alias: pnp:dCTL0022* alias: pnp:dCTL0042* alias: pnp:dCTL0041* alias: pnp:dCTL0021* alias: pnp:dCTL0031* Now, the exported value of the PNP bus can be used to autoload a matching module: $ modprobe --first-time -n -v pnp:dCTL0045 insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/core/snd-rawmidi.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/drivers/mpu401/snd-mpu401-uart.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/core/snd-hwdep.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb-common.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb16-csp.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sb16-dsp.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/drivers/opl3/snd-opl3-lib.ko insmod /lib/modules/2.6.24-rc6-g5b825ed2-dirty/kernel/sound/isa/sb/snd-sbawe.ko $ grep CTL0045 /sys/bus/pnp/devices/*/id /sys/bus/pnp/devices/01:01.00/id:CTL0045 Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 57 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 13 deletions(-) (limited to 'scripts/mod') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 348d8687b7c..769b69db89c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -328,19 +328,52 @@ static int do_pnp_entry(const char *filename, return 1; } -/* looks like: "pnp:cCdD..." */ -static int do_pnp_card_entry(const char *filename, - struct pnp_card_device_id *id, char *alias) +/* looks like: "pnp:dD" for every device of the card */ +static void do_pnp_card_entries(void *symval, unsigned long size, + struct module *mod) { - int i; + const unsigned long id_size = sizeof(struct pnp_card_device_id); + const unsigned int count = (size / id_size)-1; + const struct pnp_card_device_id *cards = symval; + unsigned int i; - sprintf(alias, "pnp:c%s", id->id); - for (i = 0; i < PNP_MAX_DEVICES; i++) { - if (! *id->devs[i].id) - break; - sprintf(alias + strlen(alias), "d%s", id->devs[i].id); + device_id_check(mod->name, "pnp", size, id_size, symval); + + for (i = 0; i < count; i++) { + unsigned int j; + const struct pnp_card_device_id *card = &cards[i]; + + for (j = 0; j < PNP_MAX_DEVICES; j++) { + const char *id = (char *)card->devs[j].id; + int i2, j2; + int dup = 0; + + if (!id[0]) + break; + + /* find duplicate, already added value */ + for (i2 = 0; i2 < i && !dup; i2++) { + const struct pnp_card_device_id *card2 = &cards[i2]; + + for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { + const char *id2 = (char *)card2->devs[j2].id; + + if (!id2[0]) + break; + + if (!strcmp(id, id2)) { + dup = 1; + break; + } + } + } + + /* add an individual alias for every device entry */ + if (!dup) + buf_printf(&mod->dev_table_buf, + "MODULE_ALIAS(\"pnp:d%s*\");\n", id); + } } - return 1; } /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ @@ -634,9 +667,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, sizeof(struct pnp_device_id), "pnp", do_pnp_entry, mod); else if (sym_is(symname, "__mod_pnp_card_device_table")) - do_table(symval, sym->st_size, - sizeof(struct pnp_card_device_id), "pnp_card", - do_pnp_card_entry, mod); + do_pnp_card_entries(symval, sym->st_size, mod); else if (sym_is(symname, "__mod_pcmcia_device_table")) do_table(symval, sym->st_size, sizeof(struct pcmcia_device_id), "pcmcia", -- cgit v1.2.3