aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/file2alias.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r--scripts/mod/file2alias.c62
1 files changed, 43 insertions, 19 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 37f67c23e11b..44312926b849 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -52,6 +52,23 @@ do { \
52 sprintf(str + strlen(str), "*"); \ 52 sprintf(str + strlen(str), "*"); \
53} while(0) 53} while(0)
54 54
55/**
56 * Check that sizeof(device_id type) are consistent with size of section
57 * in .o file. If in-consistent then userspace and kernel does not agree
58 * on actual size which is a bug.
59 **/
60static void device_id_size_check(const char *modname, const char *device_id,
61 unsigned long size, unsigned long id_size)
62{
63 if (size % id_size || size < id_size) {
64 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
65 "of the size of section __mod_%s_device_table=%lu.\n"
66 "Fix definition of struct %s_device_id "
67 "in mod_devicetable.h\n",
68 modname, device_id, id_size, device_id, size, device_id);
69 }
70}
71
55/* USB is special because the bcdDevice can be matched against a numeric range */ 72/* USB is special because the bcdDevice can be matched against a numeric range */
56/* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */ 73/* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
57static void do_usb_entry(struct usb_device_id *id, 74static void do_usb_entry(struct usb_device_id *id,
@@ -152,10 +169,8 @@ static void do_usb_table(void *symval, unsigned long size,
152 unsigned int i; 169 unsigned int i;
153 const unsigned long id_size = sizeof(struct usb_device_id); 170 const unsigned long id_size = sizeof(struct usb_device_id);
154 171
155 if (size % id_size || size < id_size) { 172 device_id_size_check(mod->name, "usb", size, id_size);
156 warn("%s ids %lu bad size " 173
157 "(each on %lu)\n", mod->name, size, id_size);
158 }
159 /* Leave last one: it's the terminator. */ 174 /* Leave last one: it's the terminator. */
160 size -= id_size; 175 size -= id_size;
161 176
@@ -434,6 +449,7 @@ static inline int sym_is(const char *symbol, const char *name)
434 449
435static void do_table(void *symval, unsigned long size, 450static void do_table(void *symval, unsigned long size,
436 unsigned long id_size, 451 unsigned long id_size,
452 const char *device_id,
437 void *function, 453 void *function,
438 struct module *mod) 454 struct module *mod)
439{ 455{
@@ -441,10 +457,7 @@ static void do_table(void *symval, unsigned long size,
441 char alias[500]; 457 char alias[500];
442 int (*do_entry)(const char *, void *entry, char *alias) = function; 458 int (*do_entry)(const char *, void *entry, char *alias) = function;
443 459
444 if (size % id_size || size < id_size) { 460 device_id_size_check(mod->name, device_id, size, id_size);
445 warn("%s ids %lu bad size "
446 "(each on %lu)\n", mod->name, size, id_size);
447 }
448 /* Leave last one: it's the terminator. */ 461 /* Leave last one: it's the terminator. */
449 size -= id_size; 462 size -= id_size;
450 463
@@ -476,40 +489,51 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
476 + sym->st_value; 489 + sym->st_value;
477 490
478 if (sym_is(symname, "__mod_pci_device_table")) 491 if (sym_is(symname, "__mod_pci_device_table"))
479 do_table(symval, sym->st_size, sizeof(struct pci_device_id), 492 do_table(symval, sym->st_size,
493 sizeof(struct pci_device_id), "pci",
480 do_pci_entry, mod); 494 do_pci_entry, mod);
481 else if (sym_is(symname, "__mod_usb_device_table")) 495 else if (sym_is(symname, "__mod_usb_device_table"))
482 /* special case to handle bcdDevice ranges */ 496 /* special case to handle bcdDevice ranges */
483 do_usb_table(symval, sym->st_size, mod); 497 do_usb_table(symval, sym->st_size, mod);
484 else if (sym_is(symname, "__mod_ieee1394_device_table")) 498 else if (sym_is(symname, "__mod_ieee1394_device_table"))
485 do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id), 499 do_table(symval, sym->st_size,
500 sizeof(struct ieee1394_device_id), "ieee1394",
486 do_ieee1394_entry, mod); 501 do_ieee1394_entry, mod);
487 else if (sym_is(symname, "__mod_ccw_device_table")) 502 else if (sym_is(symname, "__mod_ccw_device_table"))
488 do_table(symval, sym->st_size, sizeof(struct ccw_device_id), 503 do_table(symval, sym->st_size,
504 sizeof(struct ccw_device_id), "ccw",
489 do_ccw_entry, mod); 505 do_ccw_entry, mod);
490 else if (sym_is(symname, "__mod_serio_device_table")) 506 else if (sym_is(symname, "__mod_serio_device_table"))
491 do_table(symval, sym->st_size, sizeof(struct serio_device_id), 507 do_table(symval, sym->st_size,
508 sizeof(struct serio_device_id), "serio",
492 do_serio_entry, mod); 509 do_serio_entry, mod);
493 else if (sym_is(symname, "__mod_pnp_device_table")) 510 else if (sym_is(symname, "__mod_pnp_device_table"))
494 do_table(symval, sym->st_size, sizeof(struct pnp_device_id), 511 do_table(symval, sym->st_size,
512 sizeof(struct pnp_device_id), "pnp",
495 do_pnp_entry, mod); 513 do_pnp_entry, mod);
496 else if (sym_is(symname, "__mod_pnp_card_device_table")) 514 else if (sym_is(symname, "__mod_pnp_card_device_table"))
497 do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id), 515 do_table(symval, sym->st_size,
516 sizeof(struct pnp_card_device_id), "pnp_card",
498 do_pnp_card_entry, mod); 517 do_pnp_card_entry, mod);
499 else if (sym_is(symname, "__mod_pcmcia_device_table")) 518 else if (sym_is(symname, "__mod_pcmcia_device_table"))
500 do_table(symval, sym->st_size, sizeof(struct pcmcia_device_id), 519 do_table(symval, sym->st_size,
520 sizeof(struct pcmcia_device_id), "pcmcia",
501 do_pcmcia_entry, mod); 521 do_pcmcia_entry, mod);
502 else if (sym_is(symname, "__mod_of_device_table")) 522 else if (sym_is(symname, "__mod_of_device_table"))
503 do_table(symval, sym->st_size, sizeof(struct of_device_id), 523 do_table(symval, sym->st_size,
524 sizeof(struct of_device_id), "of",
504 do_of_entry, mod); 525 do_of_entry, mod);
505 else if (sym_is(symname, "__mod_vio_device_table")) 526 else if (sym_is(symname, "__mod_vio_device_table"))
506 do_table(symval, sym->st_size, sizeof(struct vio_device_id), 527 do_table(symval, sym->st_size,
528 sizeof(struct vio_device_id), "vio",
507 do_vio_entry, mod); 529 do_vio_entry, mod);
508 else if (sym_is(symname, "__mod_i2c_device_table")) 530 else if (sym_is(symname, "__mod_i2c_device_table"))
509 do_table(symval, sym->st_size, sizeof(struct i2c_device_id), 531 do_table(symval, sym->st_size,
532 sizeof(struct i2c_device_id), "i2c",
510 do_i2c_entry, mod); 533 do_i2c_entry, mod);
511 else if (sym_is(symname, "__mod_input_device_table")) 534 else if (sym_is(symname, "__mod_input_device_table"))
512 do_table(symval, sym->st_size, sizeof(struct input_device_id), 535 do_table(symval, sym->st_size,
536 sizeof(struct input_device_id), "input",
513 do_input_entry, mod); 537 do_input_entry, mod);
514} 538}
515 539