aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2014-07-26 17:54:01 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-07-27 07:22:43 -0400
commit9b20a352d78a7651aa68a9220f77ccb03009d892 (patch)
tree35db0592980536ae7cde8472d21a27edf51b7fd5
parent3a611c3cfba2106aed3187b90903855e776e2761 (diff)
module: add within_module() function
It is just a small optimization that allows to replace few occurrences of within_module_init() || within_module_core() with a single call. Signed-off-by: Petr Mladek <pmladek@suse.cz> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--include/linux/module.h5
-rw-r--r--kernel/module.c12
2 files changed, 9 insertions, 8 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index f520a767c86c..61d8fb2d0873 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -408,6 +408,11 @@ static inline int within_module_init(unsigned long addr, const struct module *mo
408 addr < (unsigned long)mod->module_init + mod->init_size; 408 addr < (unsigned long)mod->module_init + mod->init_size;
409} 409}
410 410
411static inline int within_module(unsigned long addr, const struct module *mod)
412{
413 return within_module_init(addr, mod) || within_module_core(addr, mod);
414}
415
411/* Search for module by name: must hold module_mutex. */ 416/* Search for module by name: must hold module_mutex. */
412struct module *find_module(const char *name); 417struct module *find_module(const char *name);
413 418
diff --git a/kernel/module.c b/kernel/module.c
index 81e727cf6df9..e87fdd2fc3c2 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3448,8 +3448,7 @@ const char *module_address_lookup(unsigned long addr,
3448 list_for_each_entry_rcu(mod, &modules, list) { 3448 list_for_each_entry_rcu(mod, &modules, list) {
3449 if (mod->state == MODULE_STATE_UNFORMED) 3449 if (mod->state == MODULE_STATE_UNFORMED)
3450 continue; 3450 continue;
3451 if (within_module_init(addr, mod) || 3451 if (within_module(addr, mod)) {
3452 within_module_core(addr, mod)) {
3453 if (modname) 3452 if (modname)
3454 *modname = mod->name; 3453 *modname = mod->name;
3455 ret = get_ksymbol(mod, addr, size, offset); 3454 ret = get_ksymbol(mod, addr, size, offset);
@@ -3473,8 +3472,7 @@ int lookup_module_symbol_name(unsigned long addr, char *symname)
3473 list_for_each_entry_rcu(mod, &modules, list) { 3472 list_for_each_entry_rcu(mod, &modules, list) {
3474 if (mod->state == MODULE_STATE_UNFORMED) 3473 if (mod->state == MODULE_STATE_UNFORMED)
3475 continue; 3474 continue;
3476 if (within_module_init(addr, mod) || 3475 if (within_module(addr, mod)) {
3477 within_module_core(addr, mod)) {
3478 const char *sym; 3476 const char *sym;
3479 3477
3480 sym = get_ksymbol(mod, addr, NULL, NULL); 3478 sym = get_ksymbol(mod, addr, NULL, NULL);
@@ -3499,8 +3497,7 @@ int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
3499 list_for_each_entry_rcu(mod, &modules, list) { 3497 list_for_each_entry_rcu(mod, &modules, list) {
3500 if (mod->state == MODULE_STATE_UNFORMED) 3498 if (mod->state == MODULE_STATE_UNFORMED)
3501 continue; 3499 continue;
3502 if (within_module_init(addr, mod) || 3500 if (within_module(addr, mod)) {
3503 within_module_core(addr, mod)) {
3504 const char *sym; 3501 const char *sym;
3505 3502
3506 sym = get_ksymbol(mod, addr, size, offset); 3503 sym = get_ksymbol(mod, addr, size, offset);
@@ -3764,8 +3761,7 @@ struct module *__module_address(unsigned long addr)
3764 list_for_each_entry_rcu(mod, &modules, list) { 3761 list_for_each_entry_rcu(mod, &modules, list) {
3765 if (mod->state == MODULE_STATE_UNFORMED) 3762 if (mod->state == MODULE_STATE_UNFORMED)
3766 continue; 3763 continue;
3767 if (within_module_core(addr, mod) 3764 if (within_module(addr, mod))
3768 || within_module_init(addr, mod))
3769 return mod; 3765 return mod;
3770 } 3766 }
3771 return NULL; 3767 return NULL;