From fbf7eda6f4f1e3d5b9a26d82a6884755d34923b7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 29 Apr 2003 17:17:42 -0700 Subject: [PATCH] __module_get Introduces __module_get for places where we know we already hold a reference and ignoring the fact that the module is being "rmmod --wait"ed is simpler. --- include/linux/module.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/linux') diff --git a/include/linux/module.h b/include/linux/module.h index 9511614b024a..4ddc5edcd22f 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -265,6 +265,7 @@ struct module *module_text_address(unsigned long addr); #ifdef CONFIG_MODULE_UNLOAD +unsigned int module_refcount(struct module *mod); void __symbol_put(const char *symbol); #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) void symbol_put_addr(void *addr); @@ -275,6 +276,17 @@ void symbol_put_addr(void *addr); #define local_dec(x) atomic_dec(x) #endif +/* Sometimes we know we already have a refcount, and it's easier not + to handle the error case (which only happens with rmmod --wait). */ +static inline void __module_get(struct module *module) +{ + if (module) { + BUG_ON(module_refcount(module) == 0); + local_inc(&module->ref[get_cpu()].count); + put_cpu(); + } +} + static inline int try_module_get(struct module *module) { int ret = 1; @@ -310,6 +322,9 @@ static inline int try_module_get(struct module *module) static inline void module_put(struct module *module) { } +static inline void __module_get(struct module *module) +{ +} #define symbol_put(x) do { } while(0) #define symbol_put_addr(p) do { } while(0) @@ -367,6 +382,10 @@ static inline struct module *module_text_address(unsigned long addr) #define symbol_put(x) do { } while(0) #define symbol_put_addr(x) do { } while(0) +static inline void __module_get(struct module *module) +{ +} + static inline int try_module_get(struct module *module) { return 1; -- cgit v1.2.3