mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
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>
This commit is contained in:
committed by
Jessica Yu
parent
a7c38f2cd3
commit
71e4b309dc
148
kernel/module.c
148
kernel/module.c
@@ -428,73 +428,6 @@ extern const s32 __start___kcrctab_unused_gpl[];
|
|||||||
#define symversion(base, idx) ((base != NULL) ? ((base) + (idx)) : NULL)
|
#define symversion(base, idx) ((base != NULL) ? ((base) + (idx)) : NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Returns true as soon as fn returns true, otherwise false. */
|
|
||||||
static bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
|
|
||||||
struct module *owner,
|
|
||||||
void *data),
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
struct module *mod;
|
|
||||||
static const struct symsearch arr[] = {
|
|
||||||
{ __start___ksymtab, __stop___ksymtab, __start___kcrctab,
|
|
||||||
NOT_GPL_ONLY, false },
|
|
||||||
{ __start___ksymtab_gpl, __stop___ksymtab_gpl,
|
|
||||||
__start___kcrctab_gpl,
|
|
||||||
GPL_ONLY, false },
|
|
||||||
{ __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future,
|
|
||||||
__start___kcrctab_gpl_future,
|
|
||||||
WILL_BE_GPL_ONLY, false },
|
|
||||||
#ifdef CONFIG_UNUSED_SYMBOLS
|
|
||||||
{ __start___ksymtab_unused, __stop___ksymtab_unused,
|
|
||||||
__start___kcrctab_unused,
|
|
||||||
NOT_GPL_ONLY, true },
|
|
||||||
{ __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl,
|
|
||||||
__start___kcrctab_unused_gpl,
|
|
||||||
GPL_ONLY, true },
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
module_assert_mutex_or_preempt();
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(arr); i++)
|
|
||||||
if (fn(&arr[i], NULL, data))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
list_for_each_entry_rcu(mod, &modules, list,
|
|
||||||
lockdep_is_held(&module_mutex)) {
|
|
||||||
struct symsearch arr[] = {
|
|
||||||
{ mod->syms, mod->syms + mod->num_syms, mod->crcs,
|
|
||||||
NOT_GPL_ONLY, false },
|
|
||||||
{ mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
|
|
||||||
mod->gpl_crcs,
|
|
||||||
GPL_ONLY, false },
|
|
||||||
{ mod->gpl_future_syms,
|
|
||||||
mod->gpl_future_syms + mod->num_gpl_future_syms,
|
|
||||||
mod->gpl_future_crcs,
|
|
||||||
WILL_BE_GPL_ONLY, false },
|
|
||||||
#ifdef CONFIG_UNUSED_SYMBOLS
|
|
||||||
{ mod->unused_syms,
|
|
||||||
mod->unused_syms + mod->num_unused_syms,
|
|
||||||
mod->unused_crcs,
|
|
||||||
NOT_GPL_ONLY, true },
|
|
||||||
{ mod->unused_gpl_syms,
|
|
||||||
mod->unused_gpl_syms + mod->num_unused_gpl_syms,
|
|
||||||
mod->unused_gpl_crcs,
|
|
||||||
GPL_ONLY, true },
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
if (mod->state == MODULE_STATE_UNFORMED)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(arr); i++)
|
|
||||||
if (fn(&arr[i], mod, data))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct find_symbol_arg {
|
struct find_symbol_arg {
|
||||||
/* Input */
|
/* Input */
|
||||||
const char *name;
|
const char *name;
|
||||||
@@ -605,24 +538,81 @@ static const struct kernel_symbol *find_symbol(const char *name,
|
|||||||
bool gplok,
|
bool gplok,
|
||||||
bool warn)
|
bool warn)
|
||||||
{
|
{
|
||||||
struct find_symbol_arg fsa;
|
static const struct symsearch arr[] = {
|
||||||
|
{ __start___ksymtab, __stop___ksymtab, __start___kcrctab,
|
||||||
|
NOT_GPL_ONLY, false },
|
||||||
|
{ __start___ksymtab_gpl, __stop___ksymtab_gpl,
|
||||||
|
__start___kcrctab_gpl,
|
||||||
|
GPL_ONLY, false },
|
||||||
|
{ __start___ksymtab_gpl_future, __stop___ksymtab_gpl_future,
|
||||||
|
__start___kcrctab_gpl_future,
|
||||||
|
WILL_BE_GPL_ONLY, false },
|
||||||
|
#ifdef CONFIG_UNUSED_SYMBOLS
|
||||||
|
{ __start___ksymtab_unused, __stop___ksymtab_unused,
|
||||||
|
__start___kcrctab_unused,
|
||||||
|
NOT_GPL_ONLY, true },
|
||||||
|
{ __start___ksymtab_unused_gpl, __stop___ksymtab_unused_gpl,
|
||||||
|
__start___kcrctab_unused_gpl,
|
||||||
|
GPL_ONLY, true },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
struct find_symbol_arg fsa = {
|
||||||
|
.name = name,
|
||||||
|
.gplok = gplok,
|
||||||
|
.warn = warn,
|
||||||
|
};
|
||||||
|
struct module *mod;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
fsa.name = name;
|
module_assert_mutex_or_preempt();
|
||||||
fsa.gplok = gplok;
|
|
||||||
fsa.warn = warn;
|
|
||||||
|
|
||||||
if (each_symbol_section(find_exported_symbol_in_section, &fsa)) {
|
for (i = 0; i < ARRAY_SIZE(arr); i++)
|
||||||
if (owner)
|
if (find_exported_symbol_in_section(&arr[i], NULL, &fsa))
|
||||||
*owner = fsa.owner;
|
goto found;
|
||||||
if (crc)
|
|
||||||
*crc = fsa.crc;
|
list_for_each_entry_rcu(mod, &modules, list,
|
||||||
if (license)
|
lockdep_is_held(&module_mutex)) {
|
||||||
*license = fsa.license;
|
struct symsearch arr[] = {
|
||||||
return fsa.sym;
|
{ mod->syms, mod->syms + mod->num_syms, mod->crcs,
|
||||||
|
NOT_GPL_ONLY, false },
|
||||||
|
{ mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
|
||||||
|
mod->gpl_crcs,
|
||||||
|
GPL_ONLY, false },
|
||||||
|
{ mod->gpl_future_syms,
|
||||||
|
mod->gpl_future_syms + mod->num_gpl_future_syms,
|
||||||
|
mod->gpl_future_crcs,
|
||||||
|
WILL_BE_GPL_ONLY, false },
|
||||||
|
#ifdef CONFIG_UNUSED_SYMBOLS
|
||||||
|
{ mod->unused_syms,
|
||||||
|
mod->unused_syms + mod->num_unused_syms,
|
||||||
|
mod->unused_crcs,
|
||||||
|
NOT_GPL_ONLY, true },
|
||||||
|
{ mod->unused_gpl_syms,
|
||||||
|
mod->unused_gpl_syms + mod->num_unused_gpl_syms,
|
||||||
|
mod->unused_gpl_crcs,
|
||||||
|
GPL_ONLY, true },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
if (mod->state == MODULE_STATE_UNFORMED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(arr); i++)
|
||||||
|
if (find_exported_symbol_in_section(&arr[i], mod, &fsa))
|
||||||
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_debug("Failed to find symbol %s\n", name);
|
pr_debug("Failed to find symbol %s\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
found:
|
||||||
|
if (owner)
|
||||||
|
*owner = fsa.owner;
|
||||||
|
if (crc)
|
||||||
|
*crc = fsa.crc;
|
||||||
|
if (license)
|
||||||
|
*license = fsa.license;
|
||||||
|
return fsa.sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user