]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
module: remove module_text_address()
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 19:05:31 +0000 (13:05 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 02:35:32 +0000 (13:05 +1030)
Impact: Replace and remove risky (non-EXPORTed) API

module_text_address() returns a pointer to the module, which given locking
improvements in module.c, is useless except to test for NULL:

1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().

Cc: linux-mtd@lists.infradead.org
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/mtd/nand/nand_base.c
include/linux/module.h
kernel/extable.c
kernel/module.c

index 0c3afccde8a238167d1466b7bd13f317c9b496c1..5f71371eb1b085ce6ad469d0120264dbc5bb1f33 100644 (file)
@@ -2720,14 +2720,14 @@ int nand_scan_tail(struct mtd_info *mtd)
        return chip->scan_bbt(mtd);
 }
 
-/* module_text_address() isn't exported, and it's mostly a pointless
+/* is_module_text_address() isn't exported, and it's mostly a pointless
    test if this is a module _anyway_ -- they'd have to try _really_ hard
    to call us from in-kernel code if the core NAND support is modular. */
 #ifdef MODULE
 #define caller_is_module() (1)
 #else
 #define caller_is_module() \
-       module_text_address((unsigned long)__builtin_return_address(0))
+       is_module_text_address((unsigned long)__builtin_return_address(0))
 #endif
 
 /**
index fd1241e1416f98863a53ff5d69bfd2a0c5989974..69761ce0dbf03bcffe367aa1b4e7ef468fd09168 100644 (file)
@@ -362,8 +362,6 @@ static inline int module_is_live(struct module *mod)
        return mod->state != MODULE_STATE_GOING;
 }
 
-/* Is this address in a module? (second is with no locks, for oops) */
-struct module *module_text_address(unsigned long addr);
 struct module *__module_text_address(unsigned long addr);
 struct module *__module_address(unsigned long addr);
 bool is_module_address(unsigned long addr);
@@ -496,11 +494,6 @@ search_module_extables(unsigned long addr)
        return NULL;
 }
 
-static inline struct module *module_text_address(unsigned long addr)
-{
-       return NULL;
-}
-
 static inline struct module *__module_address(unsigned long addr)
 {
        return NULL;
index e136ed8d82ba56ab81283a48fe3d6cfb41c23c79..384f0da8a03e9997a6d06ffa624cfbdad7a9063f 100644 (file)
@@ -58,14 +58,14 @@ __notrace_funcgraph int __kernel_text_address(unsigned long addr)
 {
        if (core_kernel_text(addr))
                return 1;
-       return __module_text_address(addr) != NULL;
+       return is_module_text_address(addr);
 }
 
 int kernel_text_address(unsigned long addr)
 {
        if (core_kernel_text(addr))
                return 1;
-       return module_text_address(addr) != NULL;
+       return is_module_text_address(addr);
 }
 
 /*
@@ -81,5 +81,5 @@ int func_ptr_is_kernel_text(void *ptr)
        addr = (unsigned long) dereference_function_descriptor(ptr);
        if (core_kernel_text(addr))
                return 1;
-       return module_text_address(addr) != NULL;
+       return is_module_text_address(addr);
 }
index bd15a94f91c10f2394cbf0fad307911716a761dd..8ddca629e07942631e3eaa6e7cf7c875c328792e 100644 (file)
@@ -908,8 +908,10 @@ void symbol_put_addr(void *addr)
        if (core_kernel_text((unsigned long)addr))
                return;
 
-       if (!(modaddr = module_text_address((unsigned long)addr)))
-               BUG();
+       /* module_text_address is safe here: we're supposed to have reference
+        * to module from symbol_get, so it can't go away. */
+       modaddr = __module_text_address((unsigned long)addr);
+       BUG_ON(!modaddr);
        module_put(modaddr);
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
@@ -2821,17 +2823,6 @@ struct module *__module_text_address(unsigned long addr)
        return mod;
 }
 
-struct module *module_text_address(unsigned long addr)
-{
-       struct module *mod;
-
-       preempt_disable();
-       mod = __module_text_address(addr);
-       preempt_enable();
-
-       return mod;
-}
-
 /* Don't grab lock, we're oopsing. */
 void print_modules(void)
 {