summaryrefslogtreecommitdiff
path: root/include/linux/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/module.h')
-rw-r--r--include/linux/module.h19
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;