]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
modpost: convert do_usb_table() to a generic handler
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 19 Nov 2024 23:56:49 +0000 (08:56 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 27 Nov 2024 23:46:02 +0000 (08:46 +0900)
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>
scripts/mod/file2alias.c

index 7f079a3857b2bc63405779bb197916474217f0ac..7f1bbb46dc65010676684afd035412e7071ecb3e 100644 (file)
@@ -122,7 +122,6 @@ typedef struct {
  * we handle those differences explicitly below */
 #include "../../include/linux/mod_devicetable.h"
 
-/* This array collects all instances that use the generic do_table */
 struct devtable {
        const char *device_id; /* name of table, __mod_<name>__*_device_table. */
        unsigned long id_size;
@@ -318,7 +317,7 @@ static unsigned int incbcd(unsigned int *bcd,
        return init;
 }
 
-static void do_usb_entry_multi(void *symval, struct module *mod)
+static void do_usb_entry_multi(struct module *mod, void *symval)
 {
        unsigned int devlo, devhi;
        unsigned char chi, clo, max;
@@ -383,21 +382,6 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
        }
 }
 
-static void do_usb_table(void *symval, unsigned long size,
-                        struct module *mod)
-{
-       unsigned int i;
-       const unsigned long id_size = SIZE_usb_device_id;
-
-       device_id_check(mod->name, "usb", size, id_size, symval);
-
-       /* Leave last one: it's the terminator. */
-       size -= id_size;
-
-       for (i = 0; i < size; i += id_size)
-               do_usb_entry_multi(symval + i, mod);
-}
-
 static void do_of_entry(struct module *mod, void *symval)
 {
        char alias[500];
@@ -1506,6 +1490,7 @@ static const struct devtable devtable[] = {
        {"vchiq", SIZE_vchiq_device_id, do_vchiq_entry},
        {"coreboot", SIZE_coreboot_device_id, do_coreboot_entry},
        {"of", SIZE_of_device_id, do_of_entry},
+       {"usb", SIZE_usb_device_id, do_usb_entry_multi},
        {"pnp", SIZE_pnp_device_id, do_pnp_device_entry},
        {"pnp_card", SIZE_pnp_card_device_id, do_pnp_card_entry},
 };
@@ -1551,21 +1536,15 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
                symval = sym_get_data(info, sym);
        }
 
-       /* First handle the "special" cases */
-       if (sym_is(name, namelen, "usb"))
-               do_usb_table(symval, sym->st_size, mod);
-       else {
-               int i;
-
-               for (i = 0; i < ARRAY_SIZE(devtable); i++) {
-                       const struct devtable *p = &devtable[i];
+       for (int i = 0; i < ARRAY_SIZE(devtable); i++) {
+               const struct devtable *p = &devtable[i];
 
-                       if (sym_is(name, namelen, p->device_id)) {
-                               do_table(symval, sym->st_size, p->id_size,
-                                        p->device_id, p->do_entry, mod);
-                               break;
-                       }
+               if (sym_is(name, namelen, p->device_id)) {
+                       do_table(symval, sym->st_size, p->id_size,
+                                p->device_id, p->do_entry, mod);
+                       break;
                }
        }
+
        free(zeros);
 }