mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
module: each_symbol_section instead of each_symbol
Instead of having a callback function for each symbol in the kernel, have a callback for each array of symbols. This eases the logic when we move to sorted symbols and binary search. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Alessio Igor Bogani <abogani@kernel.org>
This commit is contained in:
parent
01526ed083
commit
de4d8d5346
@ -477,8 +477,9 @@ const struct kernel_symbol *find_symbol(const char *name,
|
|||||||
bool warn);
|
bool warn);
|
||||||
|
|
||||||
/* Walk the exported symbol table */
|
/* Walk the exported symbol table */
|
||||||
bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
|
bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
|
||||||
unsigned int symnum, void *data), void *data);
|
struct module *owner,
|
||||||
|
void *data), void *data);
|
||||||
|
|
||||||
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
|
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
|
||||||
symnum out of range. */
|
symnum out of range. */
|
||||||
|
@ -240,23 +240,24 @@ static bool each_symbol_in_section(const struct symsearch *arr,
|
|||||||
struct module *owner,
|
struct module *owner,
|
||||||
bool (*fn)(const struct symsearch *syms,
|
bool (*fn)(const struct symsearch *syms,
|
||||||
struct module *owner,
|
struct module *owner,
|
||||||
unsigned int symnum, void *data),
|
void *data),
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int j;
|
||||||
|
|
||||||
for (j = 0; j < arrsize; j++) {
|
for (j = 0; j < arrsize; j++) {
|
||||||
for (i = 0; i < arr[j].stop - arr[j].start; i++)
|
if (fn(&arr[j], owner, data))
|
||||||
if (fn(&arr[j], owner, i, data))
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true as soon as fn returns true, otherwise false. */
|
/* Returns true as soon as fn returns true, otherwise false. */
|
||||||
bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
|
bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
|
||||||
unsigned int symnum, void *data), void *data)
|
struct module *owner,
|
||||||
|
void *data),
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
struct module *mod;
|
struct module *mod;
|
||||||
static const struct symsearch arr[] = {
|
static const struct symsearch arr[] = {
|
||||||
@ -309,7 +310,7 @@ bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(each_symbol);
|
EXPORT_SYMBOL_GPL(each_symbol_section);
|
||||||
|
|
||||||
struct find_symbol_arg {
|
struct find_symbol_arg {
|
||||||
/* Input */
|
/* Input */
|
||||||
@ -323,15 +324,12 @@ struct find_symbol_arg {
|
|||||||
const struct kernel_symbol *sym;
|
const struct kernel_symbol *sym;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool find_symbol_in_section(const struct symsearch *syms,
|
static bool check_symbol(const struct symsearch *syms,
|
||||||
struct module *owner,
|
struct module *owner,
|
||||||
unsigned int symnum, void *data)
|
unsigned int symnum, void *data)
|
||||||
{
|
{
|
||||||
struct find_symbol_arg *fsa = data;
|
struct find_symbol_arg *fsa = data;
|
||||||
|
|
||||||
if (strcmp(syms->start[symnum].name, fsa->name) != 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!fsa->gplok) {
|
if (!fsa->gplok) {
|
||||||
if (syms->licence == GPL_ONLY)
|
if (syms->licence == GPL_ONLY)
|
||||||
return false;
|
return false;
|
||||||
@ -365,6 +363,20 @@ static bool find_symbol_in_section(const struct symsearch *syms,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool find_symbol_in_section(const struct symsearch *syms,
|
||||||
|
struct module *owner,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
struct find_symbol_arg *fsa = data;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < syms->stop - syms->start; i++) {
|
||||||
|
if (strcmp(syms->start[i].name, fsa->name) == 0)
|
||||||
|
return check_symbol(syms, owner, i, data);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find a symbol and return it, along with, (optional) crc and
|
/* Find a symbol and return it, along with, (optional) crc and
|
||||||
* (optional) module which owns it. Needs preempt disabled or module_mutex. */
|
* (optional) module which owns it. Needs preempt disabled or module_mutex. */
|
||||||
const struct kernel_symbol *find_symbol(const char *name,
|
const struct kernel_symbol *find_symbol(const char *name,
|
||||||
@ -379,7 +391,7 @@ const struct kernel_symbol *find_symbol(const char *name,
|
|||||||
fsa.gplok = gplok;
|
fsa.gplok = gplok;
|
||||||
fsa.warn = warn;
|
fsa.warn = warn;
|
||||||
|
|
||||||
if (each_symbol(find_symbol_in_section, &fsa)) {
|
if (each_symbol_section(find_symbol_in_section, &fsa)) {
|
||||||
if (owner)
|
if (owner)
|
||||||
*owner = fsa.owner;
|
*owner = fsa.owner;
|
||||||
if (crc)
|
if (crc)
|
||||||
|
Loading…
Reference in New Issue
Block a user