aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-02-20 18:35:54 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:22 -0400
commit0c81eed4b9d6273124c7ab5eb99760b4d3a3cb9e (patch)
treeddc83231802e2f7061a2526855a3d5a4b00be5f6 /scripts/mod
parent4b65fc8cfbd1d1cfcc78865af72608e3b6cc9d9b (diff)
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 <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/file2alias.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 348d8687b7c9..769b69db89c1 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -328,19 +328,52 @@ static int do_pnp_entry(const char *filename,
328 return 1; 328 return 1;
329} 329}
330 330
331/* looks like: "pnp:cCdD..." */ 331/* looks like: "pnp:dD" for every device of the card */
332static int do_pnp_card_entry(const char *filename, 332static void do_pnp_card_entries(void *symval, unsigned long size,
333 struct pnp_card_device_id *id, char *alias) 333 struct module *mod)
334{ 334{
335 int i; 335 const unsigned long id_size = sizeof(struct pnp_card_device_id);
336 const unsigned int count = (size / id_size)-1;
337 const struct pnp_card_device_id *cards = symval;
338 unsigned int i;
336 339
337 sprintf(alias, "pnp:c%s", id->id); 340 device_id_check(mod->name, "pnp", size, id_size, symval);
338 for (i = 0; i < PNP_MAX_DEVICES; i++) { 341
339 if (! *id->devs[i].id) 342 for (i = 0; i < count; i++) {
340 break; 343 unsigned int j;
341 sprintf(alias + strlen(alias), "d%s", id->devs[i].id); 344 const struct pnp_card_device_id *card = &cards[i];
345
346 for (j = 0; j < PNP_MAX_DEVICES; j++) {
347 const char *id = (char *)card->devs[j].id;
348 int i2, j2;
349 int dup = 0;
350
351 if (!id[0])
352 break;
353
354 /* find duplicate, already added value */
355 for (i2 = 0; i2 < i && !dup; i2++) {
356 const struct pnp_card_device_id *card2 = &cards[i2];
357
358 for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) {
359 const char *id2 = (char *)card2->devs[j2].id;
360
361 if (!id2[0])
362 break;
363
364 if (!strcmp(id, id2)) {
365 dup = 1;
366 break;
367 }
368 }
369 }
370
371 /* add an individual alias for every device entry */
372 if (!dup)
373 buf_printf(&mod->dev_table_buf,
374 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
375 }
342 } 376 }
343 return 1;
344} 377}
345 378
346/* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */ 379/* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
@@ -634,9 +667,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
634 sizeof(struct pnp_device_id), "pnp", 667 sizeof(struct pnp_device_id), "pnp",
635 do_pnp_entry, mod); 668 do_pnp_entry, mod);
636 else if (sym_is(symname, "__mod_pnp_card_device_table")) 669 else if (sym_is(symname, "__mod_pnp_card_device_table"))
637 do_table(symval, sym->st_size, 670 do_pnp_card_entries(symval, sym->st_size, mod);
638 sizeof(struct pnp_card_device_id), "pnp_card",
639 do_pnp_card_entry, mod);
640 else if (sym_is(symname, "__mod_pcmcia_device_table")) 671 else if (sym_is(symname, "__mod_pcmcia_device_table"))
641 do_table(symval, sym->st_size, 672 do_table(symval, sym->st_size,
642 sizeof(struct pcmcia_device_id), "pcmcia", 673 sizeof(struct pcmcia_device_id), "pcmcia",