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 /* Always end in a wildcard, for future extension */
55 static inline void add_wildcard(char *str)
57 int len = strlen(str);
59 if (str[len - 1] != '*')
60 strcat(str + len, "*");
63 unsigned int cross_build = 0;
65 * Check that sizeof(device_id type) are consistent with size of section
66 * in .o file. If in-consistent then userspace and kernel does not agree
67 * on actual size which is a bug.
68 * Also verify that the final entry in the table is all zeros.
69 * Ignore both checks if build host differ from target host and size differs.
71 static void device_id_check(const char *modname, const char *device_id,
72 unsigned long size, unsigned long id_size,
77 if (size % id_size || size < id_size) {
80 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
81 "of the size of section __mod_%s_device_table=%lu.\n"
82 "Fix definition of struct %s_device_id "
83 "in mod_devicetable.h\n",
84 modname, device_id, id_size, device_id, size, device_id);
86 /* Verify last one is a terminator */
87 for (i = 0; i < id_size; i++ ) {
88 if (*(uint8_t*)(symval+size-id_size+i)) {
89 fprintf(stderr,"%s: struct %s_device_id is %lu bytes. "
90 "The last of %lu is:\n",
91 modname, device_id, id_size, size / id_size);
92 for (i = 0; i < id_size; i++ )
93 fprintf(stderr,"0x%02x ",
94 *(uint8_t*)(symval+size-id_size+i) );
96 fatal("%s: struct %s_device_id is not terminated "
97 "with a NULL entry!\n", modname, device_id);
102 /* USB is special because the bcdDevice can be matched against a numeric range */
103 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
104 static void do_usb_entry(struct usb_device_id *id,
105 unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
106 unsigned char range_lo, unsigned char range_hi,
110 strcpy(alias, "usb:");
111 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
113 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
117 if (bcdDevice_initial_digits)
118 sprintf(alias + strlen(alias), "%0*X",
119 bcdDevice_initial_digits, bcdDevice_initial);
120 if (range_lo == range_hi)
121 sprintf(alias + strlen(alias), "%u", range_lo);
122 else if (range_lo > 0 || range_hi < 9)
123 sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
124 if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
127 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
130 id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
131 id->bDeviceSubClass);
133 id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
134 id->bDeviceProtocol);
136 id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
137 id->bInterfaceClass);
139 id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
140 id->bInterfaceSubClass);
142 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
143 id->bInterfaceProtocol);
146 buf_printf(&mod->dev_table_buf,
147 "MODULE_ALIAS(\"%s\");\n", alias);
150 static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
152 unsigned int devlo, devhi;
153 unsigned char chi, clo;
156 id->match_flags = TO_NATIVE(id->match_flags);
157 id->idVendor = TO_NATIVE(id->idVendor);
158 id->idProduct = TO_NATIVE(id->idProduct);
160 devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ?
161 TO_NATIVE(id->bcdDevice_lo) : 0x0U;
162 devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
163 TO_NATIVE(id->bcdDevice_hi) : ~0x0U;
166 * Some modules (visor) have empty slots as placeholder for
167 * run-time specification that results in catch-all alias
169 if (!(id->idVendor | id->idProduct | id->bDeviceClass | id->bInterfaceClass))
172 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
173 for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
176 if (chi > 9) /* it's bcd not hex */
181 if (devlo == devhi || !ndigits) {
182 do_usb_entry(id, devlo, ndigits, clo, chi, mod);
187 do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
190 do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
194 static void do_usb_table(void *symval, unsigned long size,
198 const unsigned long id_size = sizeof(struct usb_device_id);
200 device_id_check(mod->name, "usb", size, id_size, symval);
202 /* Leave last one: it's the terminator. */
205 for (i = 0; i < size; i += id_size)
206 do_usb_entry_multi(symval + i, mod);
209 /* Looks like: ieee1394:venNmoNspNverN */
210 static int do_ieee1394_entry(const char *filename,
211 struct ieee1394_device_id *id, char *alias)
213 id->match_flags = TO_NATIVE(id->match_flags);
214 id->vendor_id = TO_NATIVE(id->vendor_id);
215 id->model_id = TO_NATIVE(id->model_id);
216 id->specifier_id = TO_NATIVE(id->specifier_id);
217 id->version = TO_NATIVE(id->version);
219 strcpy(alias, "ieee1394:");
220 ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
222 ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
224 ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
226 ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
233 /* Looks like: pci:vNdNsvNsdNbcNscNiN. */
234 static int do_pci_entry(const char *filename,
235 struct pci_device_id *id, char *alias)
237 /* Class field can be divided into these three. */
238 unsigned char baseclass, subclass, interface,
239 baseclass_mask, subclass_mask, interface_mask;
241 id->vendor = TO_NATIVE(id->vendor);
242 id->device = TO_NATIVE(id->device);
243 id->subvendor = TO_NATIVE(id->subvendor);
244 id->subdevice = TO_NATIVE(id->subdevice);
245 id->class = TO_NATIVE(id->class);
246 id->class_mask = TO_NATIVE(id->class_mask);
248 strcpy(alias, "pci:");
249 ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
250 ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
251 ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
252 ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
254 baseclass = (id->class) >> 16;
255 baseclass_mask = (id->class_mask) >> 16;
256 subclass = (id->class) >> 8;
257 subclass_mask = (id->class_mask) >> 8;
258 interface = id->class;
259 interface_mask = id->class_mask;
261 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
262 || (subclass_mask != 0 && subclass_mask != 0xFF)
263 || (interface_mask != 0 && interface_mask != 0xFF)) {
264 warn("Can't handle masks in %s:%04X\n",
265 filename, id->class_mask);
269 ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
270 ADD(alias, "sc", subclass_mask == 0xFF, subclass);
271 ADD(alias, "i", interface_mask == 0xFF, interface);
276 /* looks like: "ccw:tNmNdtNdmN" */
277 static int do_ccw_entry(const char *filename,
278 struct ccw_device_id *id, char *alias)
280 id->match_flags = TO_NATIVE(id->match_flags);
281 id->cu_type = TO_NATIVE(id->cu_type);
282 id->cu_model = TO_NATIVE(id->cu_model);
283 id->dev_type = TO_NATIVE(id->dev_type);
284 id->dev_model = TO_NATIVE(id->dev_model);
286 strcpy(alias, "ccw:");
287 ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
289 ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
291 ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
293 ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_MODEL,
299 /* looks like: "ap:tN" */
300 static int do_ap_entry(const char *filename,
301 struct ap_device_id *id, char *alias)
303 sprintf(alias, "ap:t%02X*", id->dev_type);
307 /* looks like: "css:tN" */
308 static int do_css_entry(const char *filename,
309 struct css_device_id *id, char *alias)
311 sprintf(alias, "css:t%01X", id->type);
315 /* Looks like: "serio:tyNprNidNexN" */
316 static int do_serio_entry(const char *filename,
317 struct serio_device_id *id, char *alias)
319 id->type = TO_NATIVE(id->type);
320 id->proto = TO_NATIVE(id->proto);
321 id->id = TO_NATIVE(id->id);
322 id->extra = TO_NATIVE(id->extra);
324 strcpy(alias, "serio:");
325 ADD(alias, "ty", id->type != SERIO_ANY, id->type);
326 ADD(alias, "pr", id->proto != SERIO_ANY, id->proto);
327 ADD(alias, "id", id->id != SERIO_ANY, id->id);
328 ADD(alias, "ex", id->extra != SERIO_ANY, id->extra);
334 /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
335 static int do_acpi_entry(const char *filename,
336 struct acpi_device_id *id, char *alias)
338 sprintf(alias, "acpi*:%s:*", id->id);
342 /* looks like: "pnp:dD" */
343 static void do_pnp_device_entry(void *symval, unsigned long size,
346 const unsigned long id_size = sizeof(struct pnp_device_id);
347 const unsigned int count = (size / id_size)-1;
348 const struct pnp_device_id *devs = symval;
351 device_id_check(mod->name, "pnp", size, id_size, symval);
353 for (i = 0; i < count; i++) {
354 const char *id = (char *)devs[i].id;
356 buf_printf(&mod->dev_table_buf,
357 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
358 buf_printf(&mod->dev_table_buf,
359 "MODULE_ALIAS(\"acpi*:%s:*\");\n", id);
363 /* looks like: "pnp:dD" for every device of the card */
364 static void do_pnp_card_entries(void *symval, unsigned long size,
367 const unsigned long id_size = sizeof(struct pnp_card_device_id);
368 const unsigned int count = (size / id_size)-1;
369 const struct pnp_card_device_id *cards = symval;
372 device_id_check(mod->name, "pnp", size, id_size, symval);
374 for (i = 0; i < count; i++) {
376 const struct pnp_card_device_id *card = &cards[i];
378 for (j = 0; j < PNP_MAX_DEVICES; j++) {
379 const char *id = (char *)card->devs[j].id;
386 /* find duplicate, already added value */
387 for (i2 = 0; i2 < i && !dup; i2++) {
388 const struct pnp_card_device_id *card2 = &cards[i2];
390 for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) {
391 const char *id2 = (char *)card2->devs[j2].id;
396 if (!strcmp(id, id2)) {
403 /* add an individual alias for every device entry */
405 buf_printf(&mod->dev_table_buf,
406 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
407 buf_printf(&mod->dev_table_buf,
408 "MODULE_ALIAS(\"acpi*:%s:*\");\n", id);
414 /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
415 static int do_pcmcia_entry(const char *filename,
416 struct pcmcia_device_id *id, char *alias)
420 id->match_flags = TO_NATIVE(id->match_flags);
421 id->manf_id = TO_NATIVE(id->manf_id);
422 id->card_id = TO_NATIVE(id->card_id);
423 id->func_id = TO_NATIVE(id->func_id);
424 id->function = TO_NATIVE(id->function);
425 id->device_no = TO_NATIVE(id->device_no);
427 for (i=0; i<4; i++) {
428 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
431 strcpy(alias, "pcmcia:");
432 ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID,
434 ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID,
436 ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID,
438 ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION,
440 ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO,
442 ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]);
443 ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]);
444 ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]);
445 ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]);
453 static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
457 len = sprintf (alias, "of:N%sT%s",
458 of->name[0] ? of->name : "*",
459 of->type[0] ? of->type : "*");
461 if (of->compatible[0])
462 sprintf (&alias[len], "%sC%s",
463 of->type[0] ? "*" : "",
466 /* Replace all whitespace with underscores */
467 for (tmp = alias; tmp && *tmp; tmp++)
475 static int do_vio_entry(const char *filename, struct vio_device_id *vio,
480 sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*",
481 vio->compat[0] ? vio->compat : "*");
483 /* Replace all whitespace with underscores */
484 for (tmp = alias; tmp && *tmp; tmp++)
492 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
494 static void do_input(char *alias,
495 kernel_ulong_t *arr, unsigned int min, unsigned int max)
499 for (i = min; i < max; i++)
500 if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG)))
501 sprintf(alias + strlen(alias), "%X,*", i);
504 /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
505 static int do_input_entry(const char *filename, struct input_device_id *id,
508 sprintf(alias, "input:");
510 ADD(alias, "b", id->flags & INPUT_DEVICE_ID_MATCH_BUS, id->bustype);
511 ADD(alias, "v", id->flags & INPUT_DEVICE_ID_MATCH_VENDOR, id->vendor);
512 ADD(alias, "p", id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT, id->product);
513 ADD(alias, "e", id->flags & INPUT_DEVICE_ID_MATCH_VERSION, id->version);
515 sprintf(alias + strlen(alias), "-e*");
516 if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT)
517 do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX);
518 sprintf(alias + strlen(alias), "k*");
519 if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT)
520 do_input(alias, id->keybit,
521 INPUT_DEVICE_ID_KEY_MIN_INTERESTING,
522 INPUT_DEVICE_ID_KEY_MAX);
523 sprintf(alias + strlen(alias), "r*");
524 if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT)
525 do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX);
526 sprintf(alias + strlen(alias), "a*");
527 if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT)
528 do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX);
529 sprintf(alias + strlen(alias), "m*");
530 if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT)
531 do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX);
532 sprintf(alias + strlen(alias), "l*");
533 if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT)
534 do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX);
535 sprintf(alias + strlen(alias), "s*");
536 if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT)
537 do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX);
538 sprintf(alias + strlen(alias), "f*");
539 if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT)
540 do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX);
541 sprintf(alias + strlen(alias), "w*");
542 if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT)
543 do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX);
547 static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
551 sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig);
557 /* Looks like: parisc:tNhvNrevNsvN */
558 static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
561 id->hw_type = TO_NATIVE(id->hw_type);
562 id->hversion = TO_NATIVE(id->hversion);
563 id->hversion_rev = TO_NATIVE(id->hversion_rev);
564 id->sversion = TO_NATIVE(id->sversion);
566 strcpy(alias, "parisc:");
567 ADD(alias, "t", id->hw_type != PA_HWTYPE_ANY_ID, id->hw_type);
568 ADD(alias, "hv", id->hversion != PA_HVERSION_ANY_ID, id->hversion);
569 ADD(alias, "rev", id->hversion_rev != PA_HVERSION_REV_ANY_ID, id->hversion_rev);
570 ADD(alias, "sv", id->sversion != PA_SVERSION_ANY_ID, id->sversion);
576 /* Looks like: sdio:cNvNdN. */
577 static int do_sdio_entry(const char *filename,
578 struct sdio_device_id *id, char *alias)
580 id->class = TO_NATIVE(id->class);
581 id->vendor = TO_NATIVE(id->vendor);
582 id->device = TO_NATIVE(id->device);
584 strcpy(alias, "sdio:");
585 ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class);
586 ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor);
587 ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device);
592 /* Looks like: ssb:vNidNrevN. */
593 static int do_ssb_entry(const char *filename,
594 struct ssb_device_id *id, char *alias)
596 id->vendor = TO_NATIVE(id->vendor);
597 id->coreid = TO_NATIVE(id->coreid);
598 id->revision = TO_NATIVE(id->revision);
600 strcpy(alias, "ssb:");
601 ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor);
602 ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid);
603 ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision);
608 /* Looks like: virtio:dNvN */
609 static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
612 id->device = TO_NATIVE(id->device);
613 id->vendor = TO_NATIVE(id->vendor);
615 strcpy(alias, "virtio:");
616 ADD(alias, "d", 1, id->device);
617 ADD(alias, "v", id->vendor != VIRTIO_DEV_ANY_ID, id->vendor);
623 /* Looks like: i2c:S */
624 static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
627 sprintf(alias, I2C_MODULE_PREFIX "%s", id->name);
632 /* Ignore any prefix, eg. some architectures prepend _ */
633 static inline int sym_is(const char *symbol, const char *name)
637 match = strstr(symbol, name);
640 return match[strlen(symbol)] == '\0';
643 static void do_table(void *symval, unsigned long size,
644 unsigned long id_size,
645 const char *device_id,
651 int (*do_entry)(const char *, void *entry, char *alias) = function;
653 device_id_check(mod->name, device_id, size, id_size, symval);
654 /* Leave last one: it's the terminator. */
657 for (i = 0; i < size; i += id_size) {
658 if (do_entry(mod->name, symval+i, alias)) {
659 buf_printf(&mod->dev_table_buf,
660 "MODULE_ALIAS(\"%s\");\n", alias);
665 /* Create MODULE_ALIAS() statements.
666 * At this time, we cannot write the actual output C source yet,
667 * so we write into the mod->dev_table_buf buffer. */
668 void handle_moddevtable(struct module *mod, struct elf_info *info,
669 Elf_Sym *sym, const char *symname)
674 /* We're looking for a section relative symbol */
675 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
678 /* Handle all-NULL symbols allocated into .bss */
679 if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) {
680 zeros = calloc(1, sym->st_size);
683 symval = (void *)info->hdr
684 + info->sechdrs[sym->st_shndx].sh_offset
688 if (sym_is(symname, "__mod_pci_device_table"))
689 do_table(symval, sym->st_size,
690 sizeof(struct pci_device_id), "pci",
692 else if (sym_is(symname, "__mod_usb_device_table"))
693 /* special case to handle bcdDevice ranges */
694 do_usb_table(symval, sym->st_size, mod);
695 else if (sym_is(symname, "__mod_ieee1394_device_table"))
696 do_table(symval, sym->st_size,
697 sizeof(struct ieee1394_device_id), "ieee1394",
698 do_ieee1394_entry, mod);
699 else if (sym_is(symname, "__mod_ccw_device_table"))
700 do_table(symval, sym->st_size,
701 sizeof(struct ccw_device_id), "ccw",
703 else if (sym_is(symname, "__mod_ap_device_table"))
704 do_table(symval, sym->st_size,
705 sizeof(struct ap_device_id), "ap",
707 else if (sym_is(symname, "__mod_css_device_table"))
708 do_table(symval, sym->st_size,
709 sizeof(struct css_device_id), "css",
711 else if (sym_is(symname, "__mod_serio_device_table"))
712 do_table(symval, sym->st_size,
713 sizeof(struct serio_device_id), "serio",
714 do_serio_entry, mod);
715 else if (sym_is(symname, "__mod_acpi_device_table"))
716 do_table(symval, sym->st_size,
717 sizeof(struct acpi_device_id), "acpi",
719 else if (sym_is(symname, "__mod_pnp_device_table"))
720 do_pnp_device_entry(symval, sym->st_size, mod);
721 else if (sym_is(symname, "__mod_pnp_card_device_table"))
722 do_pnp_card_entries(symval, sym->st_size, mod);
723 else if (sym_is(symname, "__mod_pcmcia_device_table"))
724 do_table(symval, sym->st_size,
725 sizeof(struct pcmcia_device_id), "pcmcia",
726 do_pcmcia_entry, mod);
727 else if (sym_is(symname, "__mod_of_device_table"))
728 do_table(symval, sym->st_size,
729 sizeof(struct of_device_id), "of",
731 else if (sym_is(symname, "__mod_vio_device_table"))
732 do_table(symval, sym->st_size,
733 sizeof(struct vio_device_id), "vio",
735 else if (sym_is(symname, "__mod_input_device_table"))
736 do_table(symval, sym->st_size,
737 sizeof(struct input_device_id), "input",
738 do_input_entry, mod);
739 else if (sym_is(symname, "__mod_eisa_device_table"))
740 do_table(symval, sym->st_size,
741 sizeof(struct eisa_device_id), "eisa",
743 else if (sym_is(symname, "__mod_parisc_device_table"))
744 do_table(symval, sym->st_size,
745 sizeof(struct parisc_device_id), "parisc",
746 do_parisc_entry, mod);
747 else if (sym_is(symname, "__mod_sdio_device_table"))
748 do_table(symval, sym->st_size,
749 sizeof(struct sdio_device_id), "sdio",
751 else if (sym_is(symname, "__mod_ssb_device_table"))
752 do_table(symval, sym->st_size,
753 sizeof(struct ssb_device_id), "ssb",
755 else if (sym_is(symname, "__mod_virtio_device_table"))
756 do_table(symval, sym->st_size,
757 sizeof(struct virtio_device_id), "virtio",
758 do_virtio_entry, mod);
759 else if (sym_is(symname, "__mod_i2c_device_table"))
760 do_table(symval, sym->st_size,
761 sizeof(struct i2c_device_id), "i2c",
766 /* Now add out buffered information to the generated C source */
767 void add_moddevtable(struct buffer *buf, struct module *mod)
769 buf_printf(buf, "\n");
770 buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
771 free(mod->dev_table_buf.p);