diff options
author | Andreas Robinson <andr345@gmail.com> | 2009-05-09 13:54:52 +0200 |
---|---|---|
committer | Andreas Robinson <andr345@gmail.com> | 2009-05-12 12:55:40 +0200 |
commit | e3ac3ca888c0a2a978369f9e73d4df46df7e2be3 (patch) | |
tree | 4b55ad88bd7047c15e6b5ac5851ef4f29239099a | |
parent | 042a3cf35db4f00b55141750fe368e368070fb55 (diff) | |
download | module-init-tools-e3ac3ca888c0a2a978369f9e73d4df46df7e2be3.tar.gz |
depmod: move tables from struct module into separate struct
This is part of the work separating depmod and moduleops.
Signed-off-by: Andreas Robinson <andr345@gmail.com>
-rw-r--r-- | depmod.c | 2 | ||||
-rw-r--r-- | depmod.h | 45 | ||||
-rw-r--r-- | moduleops.h | 3 | ||||
-rw-r--r-- | moduleops_core.c | 79 | ||||
-rw-r--r-- | tables.c | 70 |
5 files changed, 107 insertions, 92 deletions
@@ -714,7 +714,7 @@ static struct module *parse_modules(struct module *list) add_symbol(syms->str[j], i); free(syms); } - i->ops->fetch_tables(i); + i->ops->fetch_tables(i, &i->tables); } for (i = list; i; i = i->next) @@ -2,6 +2,30 @@ #define MODINITTOOLS_DEPMOD_H #include "list.h" +/* Tables extracted from module by ops->fetch_tables(). */ +struct module_tables { + unsigned int pci_size; + void *pci_table; + unsigned int usb_size; + void *usb_table; + unsigned int ieee1394_size; + void *ieee1394_table; + unsigned int ccw_size; + void *ccw_table; + unsigned int pnp_size; + void *pnp_table; + unsigned int pnp_card_size; + unsigned int pnp_card_offset; + void *pnp_card_table; + unsigned int input_size; + void *input_table; + unsigned int input_table_size; + unsigned int serio_size; + void *serio_table; + unsigned int of_size; + void *of_table; +}; + struct module; struct module @@ -26,26 +50,7 @@ struct module unsigned int order; /* Tables extracted from module by ops->fetch_tables(). */ - unsigned int pci_size; - void *pci_table; - unsigned int usb_size; - void *usb_table; - unsigned int ieee1394_size; - void *ieee1394_table; - unsigned int ccw_size; - void *ccw_table; - unsigned int pnp_size; - void *pnp_table; - unsigned int pnp_card_size; - unsigned int pnp_card_offset; - void *pnp_card_table; - unsigned int input_size; - void *input_table; - unsigned int input_table_size; - unsigned int serio_size; - void *serio_table; - unsigned int of_size; - void *of_table; + struct module_tables tables; /* File contents and length. */ void *data; diff --git a/moduleops.h b/moduleops.h index 88616ce..8860889 100644 --- a/moduleops.h +++ b/moduleops.h @@ -21,7 +21,8 @@ struct module_ops struct string_table *(*load_symbols)(struct module *module); struct string_table *(*load_dep_syms)(struct module *module, struct string_table **types); - void (*fetch_tables)(struct module *module); + void (*fetch_tables)(struct module *module, + struct module_tables *tables); char *(*get_aliases)(struct module *module, unsigned long *size); char *(*get_modinfo)(struct module *module, unsigned long *size); }; diff --git a/moduleops_core.c b/moduleops_core.c index 053c84e..f2de691 100644 --- a/moduleops_core.c +++ b/moduleops_core.c @@ -151,7 +151,8 @@ static void *PERBIT(deref_sym)(ElfPERBIT(Ehdr) *hdr, } /* FIXME: Check size, unless we end up using aliases anyway --RR */ -static void PERBIT(fetch_tables)(struct module *module) +static void PERBIT(fetch_tables)(struct module *module, + struct module_tables *tables) { unsigned int i; unsigned long size; @@ -170,64 +171,64 @@ static void PERBIT(fetch_tables)(struct module *module) if (!strings || !syms) return; - module->pci_table = NULL; - module->usb_table = NULL; - module->ccw_table = NULL; - module->ieee1394_table = NULL; - module->pnp_table = NULL; - module->pnp_card_table = NULL; - module->input_table = NULL; - module->serio_table = NULL; - module->of_table = NULL; + tables->pci_table = NULL; + tables->usb_table = NULL; + tables->ccw_table = NULL; + tables->ieee1394_table = NULL; + tables->pnp_table = NULL; + tables->pnp_card_table = NULL; + tables->input_table = NULL; + tables->serio_table = NULL; + tables->of_table = NULL; for (i = 0; i < size / sizeof(syms[0]); i++) { char *name = strings + END(syms[i].st_name, module->conv); - if (!module->pci_table && streq(name, "__mod_pci_device_table")) { - module->pci_size = PERBIT(PCI_DEVICE_SIZE); - module->pci_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + if (!tables->pci_table && streq(name, "__mod_pci_device_table")) { + tables->pci_size = PERBIT(PCI_DEVICE_SIZE); + tables->pci_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->usb_table && streq(name, "__mod_usb_device_table")) { - module->usb_size = PERBIT(USB_DEVICE_SIZE); - module->usb_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->usb_table && streq(name, "__mod_usb_device_table")) { + tables->usb_size = PERBIT(USB_DEVICE_SIZE); + tables->usb_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->ccw_table && streq(name, "__mod_ccw_device_table")) { - module->ccw_size = PERBIT(CCW_DEVICE_SIZE); - module->ccw_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->ccw_table && streq(name, "__mod_ccw_device_table")) { + tables->ccw_size = PERBIT(CCW_DEVICE_SIZE); + tables->ccw_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->ieee1394_table && streq(name, "__mod_ieee1394_device_table")) { - module->ieee1394_size = PERBIT(IEEE1394_DEVICE_SIZE); - module->ieee1394_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->ieee1394_table && streq(name, "__mod_ieee1394_device_table")) { + tables->ieee1394_size = PERBIT(IEEE1394_DEVICE_SIZE); + tables->ieee1394_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->pnp_table && streq(name, "__mod_pnp_device_table")) { - module->pnp_size = PERBIT(PNP_DEVICE_SIZE); - module->pnp_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->pnp_table && streq(name, "__mod_pnp_device_table")) { + tables->pnp_size = PERBIT(PNP_DEVICE_SIZE); + tables->pnp_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->pnp_card_table && streq(name, "__mod_pnp_card_device_table")) { - module->pnp_card_size = PERBIT(PNP_CARD_DEVICE_SIZE); - module->pnp_card_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->pnp_card_table && streq(name, "__mod_pnp_card_device_table")) { + tables->pnp_card_size = PERBIT(PNP_CARD_DEVICE_SIZE); + tables->pnp_card_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); - module->pnp_card_offset = PERBIT(PNP_CARD_DEVICE_OFFSET); + tables->pnp_card_offset = PERBIT(PNP_CARD_DEVICE_OFFSET); } - else if (!module->input_table && streq(name, "__mod_input_device_table")) { - module->input_size = PERBIT(INPUT_DEVICE_SIZE); - module->input_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], - &module->input_table_size, + else if (!tables->input_table && streq(name, "__mod_input_device_table")) { + tables->input_size = PERBIT(INPUT_DEVICE_SIZE); + tables->input_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + &tables->input_table_size, module->conv); } - else if (!module->serio_table && streq(name, "__mod_serio_device_table")) { - module->serio_size = PERBIT(SERIO_DEVICE_SIZE); - module->serio_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->serio_table && streq(name, "__mod_serio_device_table")) { + tables->serio_size = PERBIT(SERIO_DEVICE_SIZE); + tables->serio_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } - else if (!module->of_table && streq(name, "__mod_of_device_table")) { - module->of_size = PERBIT(OF_DEVICE_SIZE); - module->of_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], + else if (!tables->of_table && streq(name, "__mod_of_device_table")) { + tables->of_size = PERBIT(OF_DEVICE_SIZE); + tables->of_table = PERBIT(deref_sym)(hdr, sechdrs, &syms[i], NULL, module->conv); } } @@ -44,12 +44,13 @@ void output_pci_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct pci_device_id *e; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->pci_table) + if (!t->pci_table) continue; make_shortname(shortname, i->pathname); - for (e = i->pci_table; e->vendor; e = (void *)e + i->pci_size) + for (e = t->pci_table; e->vendor; e = (void *)e + t->pci_size) output_pci_entry(e, shortname, out, i->conv); } } @@ -92,14 +93,15 @@ void output_usb_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct usb_device_id *e; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->usb_table) + if (!t->usb_table) continue; make_shortname(shortname, i->pathname); - for (e = i->usb_table; + for (e = t->usb_table; e->idVendor || e->bDeviceClass || e->bInterfaceClass; - e = (void *)e + i->usb_size) + e = (void *)e + t->usb_size) output_usb_entry(e, shortname, out, i->conv); } } @@ -126,13 +128,14 @@ void output_ieee1394_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct ieee1394_device_id *fw; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->ieee1394_table) + if (!t->ieee1394_table) continue; make_shortname(shortname, i->pathname); - for (fw = i->ieee1394_table; fw->match_flags; - fw = (void *) fw + i->ieee1394_size) + for (fw = t->ieee1394_table; fw->match_flags; + fw = (void *) fw + t->ieee1394_size) output_ieee1394_entry(fw, shortname, out, i->conv); } } @@ -158,14 +161,15 @@ void output_ccw_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct ccw_device_id *e; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->ccw_table) + if (!t->ccw_table) continue; make_shortname(shortname, i->pathname); - for (e = i->ccw_table; + for (e = t->ccw_table; e->cu_type || e->cu_model || e->dev_type || e->dev_model; - e = (void *) e + i->ccw_size) + e = (void *) e + t->ccw_size) output_ccw_entry(e, shortname, out, i->conv); } } @@ -197,13 +201,14 @@ void output_isapnp_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (i->pnp_table) { + if (t->pnp_table) { struct pnp_device_id *id; make_shortname(shortname, i->pathname); - for (id = i->pnp_table; + for (id = t->pnp_table; id->id[0]; - id = (void *)id + i->pnp_size) { + id = (void *)id + t->pnp_size) { fprintf(out, "%-20s", shortname); fprintf(out, " 0xffff 0xffff "); fprintf(out, " 0x00000000 "); /* driver_data */ @@ -211,15 +216,15 @@ void output_isapnp_table(struct module *modules, FILE *out, char *dirname) fprintf(out, "\n"); } } - if (i->pnp_card_table) { + if (t->pnp_card_table) { void *id; make_shortname(shortname, i->pathname); - for (id = i->pnp_card_table; + for (id = t->pnp_card_table; ((char *)id)[0]; - id += i->pnp_card_size) { + id += t->pnp_card_size) { int idx; struct pnp_card_devid *devid - = id + i->pnp_card_offset; + = id + t->pnp_card_offset; fprintf(out, "%-20s", shortname); put_isapnp_id(out, id); @@ -419,27 +424,28 @@ void output_input_table(struct module *modules, FILE *out, char *dirname) void *p; char shortname[strlen(i->pathname) + 1]; int done = 0; + struct module_tables *t = &i->tables; - if (!i->input_table) + if (!t->input_table) continue; make_shortname(shortname, i->pathname); /* Guess what size it really is, based on size of * whole table. Table changed in 2.6.14. This is a hack. */ - if (i->input_size == sizeof(struct input_device_id_old_64)) { - if ((i->input_table_size % i->input_size) != 0) { - i->input_size + if (t->input_size == sizeof(struct input_device_id_old_64)) { + if ((t->input_table_size % t->input_size) != 0) { + t->input_size = sizeof(struct input_device_id_64); } } else { - if ((i->input_table_size % i->input_size) != 0) { - i->input_size + if ((t->input_table_size % t->input_size) != 0) { + t->input_size = sizeof(struct input_device_id_32); } } - for (p = i->input_table; !done; p += i->input_size) { - switch (i->input_size) { + for (p = t->input_table; !done; p += t->input_size) { + switch (t->input_size) { case sizeof(struct input_device_id_old_64): done = output_input_entry_64_old(p, shortname, @@ -486,12 +492,13 @@ void output_serio_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct serio_device_id *e; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->serio_table) + if (!t->serio_table) continue; make_shortname(shortname, i->pathname); - for (e = i->serio_table; e->type || e->proto; e = (void *)e + i->serio_size) + for (e = t->serio_table; e->type || e->proto; e = (void *)e + t->serio_size) output_serio_entry(e, shortname, out); } } @@ -544,13 +551,14 @@ void output_of_table(struct module *modules, FILE *out, char *dirname) for (i = modules; i; i = i->next) { struct of_device_id *e; char shortname[strlen(i->pathname) + 1]; + struct module_tables *t = &i->tables; - if (!i->of_table) + if (!t->of_table) continue; make_shortname(shortname, i->pathname); - for (e = i->of_table; e->name[0]|e->type[0]|e->compatible[0]; - e = (void *)e + i->of_size) + for (e = t->of_table; e->name[0]|e->type[0]|e->compatible[0]; + e = (void *)e + t->of_size) output_of_entry(e, shortname, out); } } |