Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: merge each_symbol_section into find_symbol

each_symbol_section is only called by find_symbol, so merge the two
functions.

Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>

authored by

Christoph Hellwig and committed by
Jessica Yu
71e4b309 a7c38f2c

+69 -79
+69 -79
kernel/module.c
··· 428 428 #define symversion(base, idx) ((base != NULL) ? ((base) + (idx)) : NULL) 429 429 #endif 430 430 431 - /* Returns true as soon as fn returns true, otherwise false. */ 432 - static bool each_symbol_section(bool (*fn)(const struct symsearch *arr, 433 - struct module *owner, 434 - void *data), 435 - void *data) 436 - { 437 - unsigned int i; 438 - struct module *mod; 439 - static const struct symsearch arr[] = { 440 - { __start___ksymtab, __stop___ksymtab, __start___kcrctab, 441 - NOT_GPL_ONLY, false }, 442 - { __start___ksymtab_gpl, __stop___ksymtab_gpl, 443 - __start___kcrctab_gpl, 444 - GPL_ONLY, false }, 445 - { __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future, 446 - __start___kcrctab_gpl_future, 447 - WILL_BE_GPL_ONLY, false }, 448 - #ifdef CONFIG_UNUSED_SYMBOLS 449 - { __start___ksymtab_unused, __stop___ksymtab_unused, 450 - __start___kcrctab_unused, 451 - NOT_GPL_ONLY, true }, 452 - { __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl, 453 - __start___kcrctab_unused_gpl, 454 - GPL_ONLY, true }, 455 - #endif 456 - }; 457 - 458 - module_assert_mutex_or_preempt(); 459 - 460 - for (i = 0; i < ARRAY_SIZE(arr); i++) 461 - if (fn(&arr[i], NULL, data)) 462 - return true; 463 - 464 - list_for_each_entry_rcu(mod, &modules, list, 465 - lockdep_is_held(&module_mutex)) { 466 - struct symsearch arr[] = { 467 - { mod->syms, mod->syms + mod->num_syms, mod->crcs, 468 - NOT_GPL_ONLY, false }, 469 - { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms, 470 - mod->gpl_crcs, 471 - GPL_ONLY, false }, 472 - { mod->gpl_future_syms, 473 - mod->gpl_future_syms + mod->num_gpl_future_syms, 474 - mod->gpl_future_crcs, 475 - WILL_BE_GPL_ONLY, false }, 476 - #ifdef CONFIG_UNUSED_SYMBOLS 477 - { mod->unused_syms, 478 - mod->unused_syms + mod->num_unused_syms, 479 - mod->unused_crcs, 480 - NOT_GPL_ONLY, true }, 481 - { mod->unused_gpl_syms, 482 - mod->unused_gpl_syms + mod->num_unused_gpl_syms, 483 - mod->unused_gpl_crcs, 484 - GPL_ONLY, true }, 485 - #endif 486 - }; 487 - 488 - if (mod->state == MODULE_STATE_UNFORMED) 489 - continue; 490 - 491 - for (i = 0; i < ARRAY_SIZE(arr); i++) 492 - if (fn(&arr[i], mod, data)) 493 - return true; 494 - } 495 - return false; 496 - } 497 - 498 431 struct find_symbol_arg { 499 432 /* Input */ 500 433 const char *name; ··· 538 605 bool gplok, 539 606 bool warn) 540 607 { 541 - struct find_symbol_arg fsa; 608 + static const struct symsearch arr[] = { 609 + { __start___ksymtab, __stop___ksymtab, __start___kcrctab, 610 + NOT_GPL_ONLY, false }, 611 + { __start___ksymtab_gpl, __stop___ksymtab_gpl, 612 + __start___kcrctab_gpl, 613 + GPL_ONLY, false }, 614 + { __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future, 615 + __start___kcrctab_gpl_future, 616 + WILL_BE_GPL_ONLY, false }, 617 + #ifdef CONFIG_UNUSED_SYMBOLS 618 + { __start___ksymtab_unused, __stop___ksymtab_unused, 619 + __start___kcrctab_unused, 620 + NOT_GPL_ONLY, true }, 621 + { __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl, 622 + __start___kcrctab_unused_gpl, 623 + GPL_ONLY, true }, 624 + #endif 625 + }; 626 + struct find_symbol_arg fsa = { 627 + .name = name, 628 + .gplok = gplok, 629 + .warn = warn, 630 + }; 631 + struct module *mod; 632 + unsigned int i; 542 633 543 - fsa.name = name; 544 - fsa.gplok = gplok; 545 - fsa.warn = warn; 634 + module_assert_mutex_or_preempt(); 546 635 547 - if (each_symbol_section(find_exported_symbol_in_section, &fsa)) { 548 - if (owner) 549 - *owner = fsa.owner; 550 - if (crc) 551 - *crc = fsa.crc; 552 - if (license) 553 - *license = fsa.license; 554 - return fsa.sym; 636 + for (i = 0; i < ARRAY_SIZE(arr); i++) 637 + if (find_exported_symbol_in_section(&arr[i], NULL, &fsa)) 638 + goto found; 639 + 640 + list_for_each_entry_rcu(mod, &modules, list, 641 + lockdep_is_held(&module_mutex)) { 642 + struct symsearch arr[] = { 643 + { mod->syms, mod->syms + mod->num_syms, mod->crcs, 644 + NOT_GPL_ONLY, false }, 645 + { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms, 646 + mod->gpl_crcs, 647 + GPL_ONLY, false }, 648 + { mod->gpl_future_syms, 649 + mod->gpl_future_syms + mod->num_gpl_future_syms, 650 + mod->gpl_future_crcs, 651 + WILL_BE_GPL_ONLY, false }, 652 + #ifdef CONFIG_UNUSED_SYMBOLS 653 + { mod->unused_syms, 654 + mod->unused_syms + mod->num_unused_syms, 655 + mod->unused_crcs, 656 + NOT_GPL_ONLY, true }, 657 + { mod->unused_gpl_syms, 658 + mod->unused_gpl_syms + mod->num_unused_gpl_syms, 659 + mod->unused_gpl_crcs, 660 + GPL_ONLY, true }, 661 + #endif 662 + }; 663 + 664 + if (mod->state == MODULE_STATE_UNFORMED) 665 + continue; 666 + 667 + for (i = 0; i < ARRAY_SIZE(arr); i++) 668 + if (find_exported_symbol_in_section(&arr[i], mod, &fsa)) 669 + goto found; 555 670 } 556 671 557 672 pr_debug("Failed to find symbol %s\n", name); 558 673 return NULL; 674 + 675 + found: 676 + if (owner) 677 + *owner = fsa.owner; 678 + if (crc) 679 + *crc = fsa.crc; 680 + if (license) 681 + *license = fsa.license; 682 + return fsa.sym; 559 683 } 560 684 561 685 /*