diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2003-04-29 17:17:42 -0700 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2003-04-29 17:17:42 -0700 |
| commit | fbf7eda6f4f1e3d5b9a26d82a6884755d34923b7 (patch) | |
| tree | 288b6fc4de89a142f68c249dbdd286042916034a /include/linux | |
| parent | 67ac5b866bda838d9838faedad0435e3e84fb2bd (diff) | |
[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.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/module.h | 19 |
1 files changed, 19 insertions, 0 deletions
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; |
