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:04 +1000
commit92371e12e46a65da9569df6d9285ba7a5ba72af6 (patch)
tree069ce3fec125683bfbcca975b7d2e506d24a8ff7
parent0d31ce7978f1cb2f459b818764ce1c238b512381 (diff)
kernel/kallsyns.c: define kallsyms_cmp_symbol_t as function type to simplify the code
It is not elegant if we use function directly as the argument, like following: int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data); Here introduce a type defined function kallsyms_cmp_symbol_t. Now we can use these type defined function directly, if we want to pass the function as the argument. int module_kallsyms_on_each_symbol(kallsyms_cmp_symbol_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/kallsyms.h10
-rw-r--r--include/linux/module.h13
-rw-r--r--kernel/kallsyms.c4
-rw-r--r--kernel/module.c4
4 files changed, 11 insertions, 20 deletions
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 6883e197acb9..e8ed37d1f53c 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -8,6 +8,7 @@
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
+#include <linux/module.h>
#define KSYM_NAME_LEN 128
#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
@@ -20,9 +21,7 @@ struct module;
unsigned long kallsyms_lookup_name(const char *name);
/* Call a function on each kallsyms symbol in the core kernel */
-int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
- unsigned long),
- void *data);
+int kallsyms_on_each_symbol(kallsyms_cmp_symbol_t fn, void *data);
extern int kallsyms_lookup_size_offset(unsigned long addr,
unsigned long *symbolsize,
@@ -52,10 +51,7 @@ static inline unsigned long kallsyms_lookup_name(const char *name)
return 0;
}
-static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *,
- struct module *,
- unsigned long),
- void *data)
+static inline int kallsyms_on_each_symbol(kallsyms_cmp_symbol_t fn, void *data)
{
return 0;
}
diff --git a/include/linux/module.h b/include/linux/module.h
index 0eeae6b5a5f0..a5739a689eba 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -563,9 +563,10 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
/* Look for this name: can be of form module:name. */
unsigned long module_kallsyms_lookup_name(const char *name);
-int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
- struct module *, unsigned long),
- void *data);
+typedef int (*kallsyms_cmp_symbol_t)(void *, const char *,
+ struct module *, unsigned long);
+
+int module_kallsyms_on_each_symbol(kallsyms_cmp_symbol_t fn, void *data);
extern void __module_put_and_exit(struct module *mod, long code)
__attribute__((noreturn));
@@ -721,10 +722,8 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name)
return 0;
}
-static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
- struct module *,
- unsigned long),
- void *data)
+static inline int module_kallsyms_on_each_symbol(
+ kallsyms_cmp_symbol_t fn, void *data)
{
return 0;
}
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 5c5987f10819..be5786b6cc94 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -193,9 +193,7 @@ unsigned long kallsyms_lookup_name(const char *name)
}
EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
-int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
- unsigned long),
- void *data)
+int kallsyms_on_each_symbol(kallsyms_cmp_symbol_t fn, void *data)
{
char namebuf[KSYM_NAME_LEN];
unsigned long i;
diff --git a/kernel/module.c b/kernel/module.c
index 1400c0b9ad2c..67ed39be50f8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3811,9 +3811,7 @@ unsigned long module_kallsyms_lookup_name(const char *name)
return ret;
}
-int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
- struct module *, unsigned long),
- void *data)
+int module_kallsyms_on_each_symbol(kallsyms_cmp_symbol_t fn, void *data)
{
struct module *mod;
unsigned int i;