1 /* Simple code to turn various tables in an ELF file into alias definitions.
2 * This deals with kernel datastructures where they should be
3 * dealt with: in the kernel source.
5 * Copyright 2002-2003 Rusty Russell, IBM Corporation
6 * 2003 Kai Germaschewski
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
15 /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
16 * use either stdint.h or inttypes.h for the rest. */
17 #if KERNEL_ELFCLASS == ELFCLASS32
18 typedef Elf32_Addr kernel_ulong_t;
19 #define BITS_PER_LONG 32
21 typedef Elf64_Addr kernel_ulong_t;
22 #define BITS_PER_LONG 64
32 typedef uint32_t __u32;
33 typedef uint16_t __u16;
34 typedef unsigned char __u8;
36 /* Big exception to the "don't include kernel headers into userspace, which
37 * even potentially has different endianness and word sizes, since
38 * we handle those differences explicitly below */
39 #include "../../include/linux/mod_devicetable.h"
41 #define ADD(str, sep, cond, field) \
45 sprintf(str + strlen(str), \
46 sizeof(field) == 1 ? "%02X" : \
47 sizeof(field) == 2 ? "%04X" : \
48 sizeof(field) == 4 ? "%08X" : "", \
51 sprintf(str + strlen(str), "*"); \
54 unsigned int cross_build = 0;
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 * Also verify that the final entry in the table is all zeros.
60 * Ignore both checks if build host differ from target host and size differs.
62 static void device_id_check(const char *modname, const char *device_id,
63 unsigned long size, unsigned long id_size,
68 if (size % id_size || size < id_size) {
71 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
72 "of the size of section __mod_%s_device_table=%lu.\n"
73 "Fix definition of struct %s_device_id "
74 "in mod_devicetable.h\n",
75 modname, device_id, id_size, device_id, size, device_id);
77 /* Verify last one is a terminator */
78 for (i = 0; i < id_size; i++ ) {
79 if (*(uint8_t*)(symval+size-id_size+i)) {
80 fprintf(stderr,"%s: struct %s_device_id is %lu bytes. "
81 "The last of %lu is:\n",
82 modname, device_id, id_size, size / id_size);
83 for (i = 0; i < id_size; i++ )
84 fprintf(stderr,"0x%02x ",
85 *(uint8_t*)(symval+size-id_size+i) );
87 fatal("%s: struct %s_device_id is not terminated "
88 "with a NULL entry!\n", modname, device_id);
93 /* USB is special because the bcdDevice can be matched against a numeric range */
94 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
95 static void do_usb_entry(struct usb_device_id *id,
96 unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97 unsigned char range_lo, unsigned char range_hi,
101 strcpy(alias, "usb:");
102 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
104 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
108 if (bcdDevice_initial_digits)
109 sprintf(alias + strlen(alias), "%0*X",
110 bcdDevice_initial_digits, bcdDevice_initial);
111 if (range_lo == range_hi)
112 sprintf(alias + strlen(alias), "%u", range_lo);
113 else if (range_lo > 0 || range_hi < 9)
114 sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
115 if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
118 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
121 id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
122 id->bDeviceSubClass);
124 id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
125 id->bDeviceProtocol);
127 id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
128 id->bInterfaceClass);
130 id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
131 id->bInterfaceSubClass);
133 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
134 id->bInterfaceProtocol);
136 /* Always end in a wildcard, for future extension */
137 if (alias[strlen(alias)-1] != '*')
139 buf_printf(&mod->dev_table_buf,
140 "MODULE_ALIAS(\"%s\");\n", alias);
143 static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
145 unsigned int devlo, devhi;
146 unsigned char chi, clo;
149 id->match_flags = TO_NATIVE(id->match_flags);
150 id->idVendor = TO_NATIVE(id->idVendor);
151 id->idProduct = TO_NATIVE(id->idProduct);
153 devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ?
154 TO_NATIVE(id->bcdDevice_lo) : 0x0U;
155 devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
156 TO_NATIVE(id->bcdDevice_hi) : ~0x0U;
159 * Some modules (visor) have empty slots as placeholder for
160 * run-time specification that results in catch-all alias
162 if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass))
165 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
166 for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
169 if (chi > 9) /* it's bcd not hex */
174 if (devlo == devhi || !ndigits) {
175 do_usb_entry(id, devlo, ndigits, clo, chi, mod);
180 do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
183 do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
187 static void do_usb_table(void *symval, unsigned long size,
191 const unsigned long id_size = sizeof(struct usb_device_id);
193 device_id_check(mod->name, "usb", size, id_size, symval);
195 /* Leave last one: it's the terminator. */
198 for (i = 0; i < size; i += id_size)
199 do_usb_entry_multi(symval + i, mod);
202 /* Looks like: ieee1394:venNmoNspNverN */
203 static int do_ieee1394_entry(const char *filename,
204 struct ieee1394_device_id *id, char *alias)
206 id->match_flags = TO_NATIVE(id->match_flags);
207 id->vendor_id = TO_NATIVE(id->vendor_id);
208 id->model_id = TO_NATIVE(id->model_id);
209 id->specifier_id = TO_NATIVE(id->specifier_id);
210 id->version = TO_NATIVE(id->version);
212 strcpy(alias, "ieee1394:");
213 ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
215 ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
217 ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
219 ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
225 /* Looks like: pci:vNdNsvNsdNbcNscNiN. */
226 static int do_pci_entry(const char *filename,
227 struct pci_device_id *id, char *alias)
229 /* Class field can be divided into these three. */
230 unsigned char baseclass, subclass, interface,
231 baseclass_mask, subclass_mask, interface_mask;
233 id->vendor = TO_NATIVE(id->vendor);
234 id->device = TO_NATIVE(id->device);
235 id->subvendor = TO_NATIVE(id->subvendor);
236 id->subdevice = TO_NATIVE(id->subdevice);
237 id->class = TO_NATIVE(id->class);
238 id->class_mask = TO_NATIVE(id->class_mask);
240 strcpy(alias, "pci:");
241 ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
242 ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
243 ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
244 ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
246 baseclass = (id->class) >> 16;
247 baseclass_mask = (id->class_mask) >> 16;
248 subclass = (id->class) >> 8;
249 subclass_mask = (id->class_mask) >> 8;
250 interface = id->class;
251 interface_mask = id->class_mask;
253 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
254 || (subclass_mask != 0 && subclass_mask != 0xFF)
255 || (interface_mask != 0 && interface_mask != 0xFF)) {
256 warn("Can't handle masks in %s:%04X\n",
257 filename, id->class_mask);
261 ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
262 ADD(alias, "sc", subclass_mask == 0xFF, subclass);
263 ADD(alias, "i", interface_mask == 0xFF, interface);
267 /* looks like: "ccw:tNmNdtNdmN" */
268 static int do_ccw_entry(const char *filename,
269 struct ccw_device_id *id, char *alias)
271 id->match_flags = TO_NATIVE(id->match_flags);
272 id->cu_type = TO_NATIVE(id->cu_type);
273 id->cu_model = TO_NATIVE(id->cu_model);
274 id->dev_type = TO_NATIVE(id->dev_type);
275 id->dev_model = TO_NATIVE(id->dev_model);
277 strcpy(alias, "ccw:");
278 ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
280 ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
282 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
284 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
289 /* looks like: "ap:tN" */
290 static int do_ap_entry(const char *filename,
291 struct ap_device_id *id, char *alias)
293 sprintf(alias, "ap:t%02X", id->dev_type);
297 /* Looks like: "serio:tyNprNidNexN" */
298 static int do_serio_entry(const char *filename,
299 struct serio_device_id *id, char *alias)
301 id->type = TO_NATIVE(id->type);
302 id->proto = TO_NATIVE(id->proto);
303 id->id = TO_NATIVE(id->id);
304 id->extra = TO_NATIVE(id->extra);
306 strcpy(alias, "serio:");
307 ADD(alias, "ty", id->type != SERIO_ANY, id->type);
308 ADD(alias, "pr", id->proto != SERIO_ANY, id->proto);
309 ADD(alias, "id", id->id != SERIO_ANY, id->id);
310 ADD(alias, "ex", id->extra != SERIO_ANY, id->extra);
315 /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
316 static int do_acpi_entry(const char *filename,
317 struct acpi_device_id *id, char *alias)
319 sprintf(alias, "acpi*:%s:", id->id);
323 /* looks like: "pnp:dD" */
324 static int do_pnp_entry(const char *filename,
325 struct pnp_device_id *id, char *alias)
327 sprintf(alias, "pnp:d%s", id->id);
331 /* looks like: "pnp:dD" for every device of the card */
332 static void do_pnp_card_entries(void *symval, unsigned long size,
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;
340 device_id_check(mod->name, "pnp", size, id_size, symval);
342 for (i = 0; i < count; i++) {
344 const struct pnp_card_device_id *card = &cards[i];
346 for (j = 0; j < PNP_MAX_DEVICES; j++) {
347 const char *id = (char *)card->devs[j].id;
354 /* find duplicate, already added value */
355 for (i2 = 0; i2 < i && !dup; i2++) {
356 const struct pnp_card_device_id *card2 = &cards[i2];
358 for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) {
359 const char *id2 = (char *)card2->devs[j2].id;
364 if (!strcmp(id, id2)) {
371 /* add an individual alias for every device entry */
373 buf_printf(&mod->dev_table_buf,
374 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
379 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
380 static int do_pcmcia_entry(const char *filename,
381 struct pcmcia_device_id *id, char *alias)
385 id->match_flags = TO_NATIVE(id->match_flags);
386 id->manf_id = TO_NATIVE(id->manf_id);
387 id->card_id = TO_NATIVE(id->card_id);
388 id->func_id = TO_NATIVE(id->func_id);
389 id->function = TO_NATIVE(id->function);
390 id->device_no = TO_NATIVE(id->device_no);
392 for (i=0; i<4; i++) {
393 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
396 strcpy(alias, "pcmcia:");
397 ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID,
399 ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID,
401 ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID,
403 ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION,
405 ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO,
407 ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]);
408 ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]);
409 ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]);
410 ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]);
417 static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
421 len = sprintf (alias, "of:N%sT%s",
422 of->name[0] ? of->name : "*",
423 of->type[0] ? of->type : "*");
425 if (of->compatible[0])
426 sprintf (&alias[len], "%sC%s",
427 of->type[0] ? "*" : "",
430 /* Replace all whitespace with underscores */
431 for (tmp = alias; tmp && *tmp; tmp++)
438 static int do_vio_entry(const char *filename, struct vio_device_id *vio,
443 sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*",
444 vio->compat[0] ? vio->compat : "*");
446 /* Replace all whitespace with underscores */
447 for (tmp = alias; tmp && *tmp; tmp++)
454 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
456 static void do_input(char *alias,
457 kernel_ulong_t *arr, unsigned int min, unsigned int max)
461 for (i = min; i < max; i++)
462 if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG)))
463 sprintf(alias + strlen(alias), "%X,*", i);
466 /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
467 static int do_input_entry(const char *filename, struct input_device_id *id,
470 sprintf(alias, "input:");
472 ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype);
473 ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor);
474 ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product);
475 ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version);
477 sprintf(alias + strlen(alias), "-e*");
478 if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT)
479 do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX);
480 sprintf(alias + strlen(alias), "k*");
481 if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT)
482 do_input(alias, id->keybit,
483 INPUT_DEVICE_ID_KEY_MIN_INTERESTING,
484 INPUT_DEVICE_ID_KEY_MAX);
485 sprintf(alias + strlen(alias), "r*");
486 if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT)
487 do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX);
488 sprintf(alias + strlen(alias), "a*");
489 if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT)
490 do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX);
491 sprintf(alias + strlen(alias), "m*");
492 if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT)
493 do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX);
494 sprintf(alias + strlen(alias), "l*");
495 if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT)
496 do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX);
497 sprintf(alias + strlen(alias), "s*");
498 if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT)
499 do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX);
500 sprintf(alias + strlen(alias), "f*");
501 if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT)
502 do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX);
503 sprintf(alias + strlen(alias), "w*");
504 if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT)
505 do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX);
509 static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
513 sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig);
517 /* Looks like: parisc:tNhvNrevNsvN */
518 static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
521 id->hw_type = TO_NATIVE(id->hw_type);
522 id->hversion = TO_NATIVE(id->hversion);
523 id->hversion_rev = TO_NATIVE(id->hversion_rev);
524 id->sversion = TO_NATIVE(id->sversion);
526 strcpy(alias, "parisc:");
527 ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type);
528 ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion);
529 ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev);
530 ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion);
535 /* Looks like: sdio:cNvNdN. */
536 static int do_sdio_entry(const char *filename,
537 struct sdio_device_id *id, char *alias)
539 id->class = TO_NATIVE(id->class);
540 id->vendor = TO_NATIVE(id->vendor);
541 id->device = TO_NATIVE(id->device);
543 strcpy(alias, "sdio:");
544 ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class);
545 ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor);
546 ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device);
550 /* Looks like: ssb:vNidNrevN. */
551 static int do_ssb_entry(const char *filename,
552 struct ssb_device_id *id, char *alias)
554 id->vendor = TO_NATIVE(id->vendor);
555 id->coreid = TO_NATIVE(id->coreid);
556 id->revision = TO_NATIVE(id->revision);
558 strcpy(alias, "ssb:");
559 ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor);
560 ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid);
561 ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision);
565 /* Looks like: virtio:dNvN */
566 static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
569 id->device = TO_NATIVE(id->device);
570 id->vendor = TO_NATIVE(id->vendor);
572 strcpy(alias, "virtio:");
573 ADD(alias, "d", 1, id->device);
574 ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor);
579 /* Looks like: i2c:S */
580 static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
583 sprintf(alias, I2C_MODULE_PREFIX "%s", id->name);
588 /* Ignore any prefix, eg. v850 prepends _ */
589 static inline int sym_is(const char *symbol, const char *name)
593 match = strstr(symbol, name);
596 return match[strlen(symbol)] == '\0';
599 static void do_table(void *symval, unsigned long size,
600 unsigned long id_size,
601 const char *device_id,
607 int (*do_entry)(const char *, void *entry, char *alias) = function;
609 device_id_check(mod->name, device_id, size, id_size, symval);
610 /* Leave last one: it's the terminator. */
613 for (i = 0; i < size; i += id_size) {
614 if (do_entry(mod->name, symval+i, alias)) {
615 /* Always end in a wildcard, for future extension */
616 if (alias[strlen(alias)-1] != '*')
618 buf_printf(&mod->dev_table_buf,
619 "MODULE_ALIAS(\"%s\");\n", alias);
624 /* Create MODULE_ALIAS() statements.
625 * At this time, we cannot write the actual output C source yet,
626 * so we write into the mod->dev_table_buf buffer. */
627 void handle_moddevtable(struct module *mod, struct elf_info *info,
628 Elf_Sym *sym, const char *symname)
633 /* We're looking for a section relative symbol */
634 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
637 /* Handle all-NULL symbols allocated into .bss */
638 if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) {
639 zeros = calloc(1, sym->st_size);
642 symval = (void *)info->hdr
643 + info->sechdrs[sym->st_shndx].sh_offset
647 if (sym_is(symname, "__mod_pci_device_table"))
648 do_table(symval, sym->st_size,
649 sizeof(struct pci_device_id), "pci",
651 else if (sym_is(symname, "__mod_usb_device_table"))
652 /* special case to handle bcdDevice ranges */
653 do_usb_table(symval, sym->st_size, mod);
654 else if (sym_is(symname, "__mod_ieee1394_device_table"))
655 do_table(symval, sym->st_size,
656 sizeof(struct ieee1394_device_id), "ieee1394",
657 do_ieee1394_entry, mod);
658 else if (sym_is(symname, "__mod_ccw_device_table"))
659 do_table(symval, sym->st_size,
660 sizeof(struct ccw_device_id), "ccw",
662 else if (sym_is(symname, "__mod_ap_device_table"))
663 do_table(symval, sym->st_size,
664 sizeof(struct ap_device_id), "ap",
666 else if (sym_is(symname, "__mod_serio_device_table"))
667 do_table(symval, sym->st_size,
668 sizeof(struct serio_device_id), "serio",
669 do_serio_entry, mod);
670 else if (sym_is(symname, "__mod_acpi_device_table"))
671 do_table(symval, sym->st_size,
672 sizeof(struct acpi_device_id), "acpi",
674 else if (sym_is(symname, "__mod_pnp_device_table"))
675 do_table(symval, sym->st_size,
676 sizeof(struct pnp_device_id), "pnp",
678 else if (sym_is(symname, "__mod_pnp_card_device_table"))
679 do_pnp_card_entries(symval, sym->st_size, mod);
680 else if (sym_is(symname, "__mod_pcmcia_device_table"))
681 do_table(symval, sym->st_size,
682 sizeof(struct pcmcia_device_id), "pcmcia",
683 do_pcmcia_entry, mod);
684 else if (sym_is(symname, "__mod_of_device_table"))
685 do_table(symval, sym->st_size,
686 sizeof(struct of_device_id), "of",
688 else if (sym_is(symname, "__mod_vio_device_table"))
689 do_table(symval, sym->st_size,
690 sizeof(struct vio_device_id), "vio",
692 else if (sym_is(symname, "__mod_input_device_table"))
693 do_table(symval, sym->st_size,
694 sizeof(struct input_device_id), "input",
695 do_input_entry, mod);
696 else if (sym_is(symname, "__mod_eisa_device_table"))
697 do_table(symval, sym->st_size,
698 sizeof(struct eisa_device_id), "eisa",
700 else if (sym_is(symname, "__mod_parisc_device_table"))
701 do_table(symval, sym->st_size,
702 sizeof(struct parisc_device_id), "parisc",
703 do_parisc_entry, mod);
704 else if (sym_is(symname, "__mod_sdio_device_table"))
705 do_table(symval, sym->st_size,
706 sizeof(struct sdio_device_id), "sdio",
708 else if (sym_is(symname, "__mod_ssb_device_table"))
709 do_table(symval, sym->st_size,
710 sizeof(struct ssb_device_id), "ssb",
712 else if (sym_is(symname, "__mod_virtio_device_table"))
713 do_table(symval, sym->st_size,
714 sizeof(struct virtio_device_id), "virtio",
715 do_virtio_entry, mod);
716 else if (sym_is(symname, "__mod_i2c_device_table"))
717 do_table(symval, sym->st_size,
718 sizeof(struct i2c_device_id), "i2c",
723 /* Now add out buffered information to the generated C source */
724 void add_moddevtable(struct buffer *buf, struct module *mod)
726 buf_printf(buf, "\n");
727 buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
728 free(mod->dev_table_buf.p);