You do not need to iterate over all modules for resetting ->seen flag because add_depends() is only interested in modules that export symbols referenced from the given 'mod'. This also avoids shadowing the 'modules' parameter of add_depends().
Unified · Split
| @@ -2241,15 +2241,15 @@ static int add_versions(struct buffer *b, struct module *mod) · 2240 unmodified lines | ||
| 2241 | 2241 | return err; |
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | −static void add_depends(struct buffer *b, struct module *mod, | |
| 2245 | − struct module *modules) | |
| 2244 | +static void add_depends(struct buffer *b, struct module *mod) | |
| 2246 | 2245 | { |
| 2247 | 2246 | struct symbol *s; |
| 2248 | − struct module *m; | |
| 2249 | 2247 | int first = 1; |
| 2250 | 2248 | |
| 2251 | − for (m = modules; m; m = m->next) | |
| 2252 | − m->seen = is_vmlinux(m->name); | |
| 2249 | + /* Clear ->seen flag of modules that own symbols needed by this. */ | |
| 2250 | + for (s = mod->unres; s; s = s->next) | |
| 2251 | + if (s->module) | |
| 2252 | + s->module->seen = is_vmlinux(s->module->name); | |
| 2253 | 2253 | |
| 2254 | 2254 | buf_printf(b, "\n"); |
| 2255 | 2255 | buf_printf(b, "static const char __module_depends[]\n"); |
| @@ -2518,7 +2518,7 @@ int main(int argc, char **argv) · 262 unmodified lines | ||
| 2518 | 2518 | add_retpoline(&buf); |
| 2519 | 2519 | add_staging_flag(&buf, mod->name); |
| 2520 | 2520 | err |= add_versions(&buf, mod); |
| 2521 | − add_depends(&buf, mod, modules); | |
| 2521 | + add_depends(&buf, mod); | |
| 2522 | 2522 | add_moddevtable(&buf, mod); |
| 2523 | 2523 | add_srcversion(&buf, mod); |
| 2524 | 2524 | |