Skip to content

Commit abd2042

Browse files
committed
modpost: convert do_usb_table() to a generic handler
do_usb_table() no longer needs to iterate over the usb_device_id array. Convert it to a generic ->do_entry() handler. This is the last special case. Clean up handle_moddevtable(). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent c58854c commit abd2042

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

scripts/mod/file2alias.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ typedef struct {
122122
* we handle those differences explicitly below */
123123
#include "../../include/linux/mod_devicetable.h"
124124

125-
/* This array collects all instances that use the generic do_table */
126125
struct devtable {
127126
const char *device_id; /* name of table, __mod_<name>__*_device_table. */
128127
unsigned long id_size;
@@ -318,7 +317,7 @@ static unsigned int incbcd(unsigned int *bcd,
318317
return init;
319318
}
320319

321-
static void do_usb_entry_multi(void *symval, struct module *mod)
320+
static void do_usb_entry_multi(struct module *mod, void *symval)
322321
{
323322
unsigned int devlo, devhi;
324323
unsigned char chi, clo, max;
@@ -383,21 +382,6 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
383382
}
384383
}
385384

386-
static void do_usb_table(void *symval, unsigned long size,
387-
struct module *mod)
388-
{
389-
unsigned int i;
390-
const unsigned long id_size = SIZE_usb_device_id;
391-
392-
device_id_check(mod->name, "usb", size, id_size, symval);
393-
394-
/* Leave last one: it's the terminator. */
395-
size -= id_size;
396-
397-
for (i = 0; i < size; i += id_size)
398-
do_usb_entry_multi(symval + i, mod);
399-
}
400-
401385
static void do_of_entry(struct module *mod, void *symval)
402386
{
403387
char alias[500];
@@ -1506,6 +1490,7 @@ static const struct devtable devtable[] = {
15061490
{"vchiq", SIZE_vchiq_device_id, do_vchiq_entry},
15071491
{"coreboot", SIZE_coreboot_device_id, do_coreboot_entry},
15081492
{"of", SIZE_of_device_id, do_of_entry},
1493+
{"usb", SIZE_usb_device_id, do_usb_entry_multi},
15091494
{"pnp", SIZE_pnp_device_id, do_pnp_device_entry},
15101495
{"pnp_card", SIZE_pnp_card_device_id, do_pnp_card_entry},
15111496
};
@@ -1551,21 +1536,15 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
15511536
symval = sym_get_data(info, sym);
15521537
}
15531538

1554-
/* First handle the "special" cases */
1555-
if (sym_is(name, namelen, "usb"))
1556-
do_usb_table(symval, sym->st_size, mod);
1557-
else {
1558-
int i;
1559-
1560-
for (i = 0; i < ARRAY_SIZE(devtable); i++) {
1561-
const struct devtable *p = &devtable[i];
1539+
for (int i = 0; i < ARRAY_SIZE(devtable); i++) {
1540+
const struct devtable *p = &devtable[i];
15621541

1563-
if (sym_is(name, namelen, p->device_id)) {
1564-
do_table(symval, sym->st_size, p->id_size,
1565-
p->device_id, p->do_entry, mod);
1566-
break;
1567-
}
1542+
if (sym_is(name, namelen, p->device_id)) {
1543+
do_table(symval, sym->st_size, p->id_size,
1544+
p->device_id, p->do_entry, mod);
1545+
break;
15681546
}
15691547
}
1548+
15701549
free(zeros);
15711550
}

0 commit comments

Comments
 (0)