aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinfei Huang <mnfhuang@gmail.com>2015-07-20 08:57:20 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2015-07-22 14:32:03 +1000
commit0d31ce7978f1cb2f459b818764ce1c238b512381 (patch)
tree796b68c879e4e3856384a5508f1ea7e033af4a71
parentab88c5a6b62cb31ff723f87e54d25dcafd884169 (diff)
kernel/module.c: define find_symbol_in_section_t as function type to simplify the code
It is not elegant if we use function directly as the argument, like following: bool each_symbol_section(bool (*fn)(const struct symsearch *arr, struct module *owner, void *data), void *data); Here introduce a type defined function find_symbol_in_section_t. Now we can use these type defined function directly, if we want to pass the function as the argument. bool each_symbol_section(find_symbol_in_section_t fn, void *data); Signed-off-by: Minfei Huang <mnfhuang@gmail.com> Cc: Rob Jones <rob.jones@codethink.co.uk> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--include/linux/module.h6
-rw-r--r--kernel/module.c9
2 files changed, 5 insertions, 10 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 3a19c79918e0..0eeae6b5a5f0 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -546,14 +546,14 @@ const struct kernel_symbol *find_symbol(const char *name,
bool gplok,
bool warn);
+typedef bool (*find_symbol_in_section_t)(const struct symsearch *arr,
+ struct module *owner, void *data);
/*
* Walk the exported symbol table
*
* Must be called with module_mutex held or preemption disabled.
*/
-bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
- struct module *owner,
- void *data), void *data);
+bool each_symbol_section(find_symbol_in_section_t fn, void *data);
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
symnum out of range. */
diff --git a/kernel/module.c b/kernel/module.c
index 4d2b82e610e2..1400c0b9ad2c 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -426,9 +426,7 @@ extern const unsigned long __start___kcrctab_unused_gpl[];
static bool each_symbol_in_section(const struct symsearch *arr,
unsigned int arrsize,
struct module *owner,
- bool (*fn)(const struct symsearch *syms,
- struct module *owner,
- void *data),
+ find_symbol_in_section_t fn,
void *data)
{
unsigned int j;
@@ -442,10 +440,7 @@ static bool each_symbol_in_section(const struct symsearch *arr,
}
/* Returns true as soon as fn returns true, otherwise false. */
-bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
- struct module *owner,
- void *data),
- void *data)
+bool each_symbol_section(find_symbol_in_section_t fn, void *data)
{
struct module *mod;
static const struct symsearch arr[] = {