From 67ac5b866bda838d9838faedad0435e3e84fb2bd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 29 Apr 2003 17:17:33 -0700 Subject: [PATCH] complete modinfo section Restores .modinfo section, and uses it to store license and vermagic. --- include/linux/module.h | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'include/linux/module.h') diff --git a/include/linux/module.h b/include/linux/module.h index 657802c8af75..9511614b024a 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -20,10 +20,7 @@ #include /* Not Yet Implemented */ -#define MODULE_AUTHOR(name) -#define MODULE_DESCRIPTION(desc) #define MODULE_SUPPORTED_DEVICE(name) -#define MODULE_PARM_DESC(var,desc) #define print_modules() /* v850 toolchain uses a `_' prefix for all user symbols */ @@ -58,12 +55,11 @@ search_extable(const struct exception_table_entry *first, unsigned long value); #ifdef MODULE -#define ___module_cat(a,b) a ## b +#define ___module_cat(a,b) __mod_ ## a ## b #define __module_cat(a,b) ___module_cat(a,b) -/* For userspace: you can also call me... */ -#define MODULE_ALIAS(alias) \ - static const char __module_cat(__alias_,__LINE__)[] \ - __attribute__((section(".modinfo"),unused)) = "alias=" alias +#define __MODULE_INFO(tag, name, info) \ +static const char __module_cat(name,__LINE__)[] \ + __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info #define MODULE_GENERIC_TABLE(gtype,name) \ extern const struct gtype##_id __mod_##gtype##_table \ @@ -71,6 +67,19 @@ extern const struct gtype##_id __mod_##gtype##_table \ #define THIS_MODULE (&__this_module) +#else /* !MODULE */ + +#define MODULE_GENERIC_TABLE(gtype,name) +#define __MODULE_INFO(tag, name, info) +#define THIS_MODULE ((struct module *)0) +#endif + +/* Generic info of form tag = "info" */ +#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) + +/* For userspace: you can also call me... */ +#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) + /* * The following license idents are currently accepted as indicating free * software modules @@ -97,17 +106,18 @@ extern const struct gtype##_id __mod_##gtype##_table \ * 2. So the community can ignore bug reports including proprietary modules * 3. So vendors can do likewise based on their own policies */ -#define MODULE_LICENSE(license) \ - static const char __module_license[] \ - __attribute__((section(".init.license"), unused)) = license - -#else /* !MODULE */ - -#define MODULE_ALIAS(alias) -#define MODULE_GENERIC_TABLE(gtype,name) -#define THIS_MODULE ((struct module *)0) -#define MODULE_LICENSE(license) -#endif +#define MODULE_LICENSE(_license) MODULE_INFO(license, _license) + +/* Author, ideally of form NAME [, NAME ]*[ and NAME ] */ +#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) + +/* What your module does. */ +#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) + +/* One for each parameter, describing how to use it. Some files do + multiple of these per line, so can't just use MODULE_INFO. */ +#define MODULE_PARM_DESC(_parm, desc) \ + __MODULE_INFO(parm, _parm, #_parm ":" desc) #define MODULE_DEVICE_TABLE(type,name) \ MODULE_GENERIC_TABLE(type##_device,name) -- cgit v1.2.3 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. --- fs/filesystems.c | 12 +----------- include/linux/module.h | 19 +++++++++++++++++++ kernel/module.c | 3 ++- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'include/linux/module.h') diff --git a/fs/filesystems.c b/fs/filesystems.c index a87d637e168a..c4b467fb67dd 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -32,17 +32,7 @@ static rwlock_t file_systems_lock = RW_LOCK_UNLOCKED; /* WARNING: This can be used only if we _already_ own a reference */ void get_filesystem(struct file_system_type *fs) { - if (!try_module_get(fs->owner)) { -#ifdef CONFIG_MODULE_UNLOAD - unsigned int cpu = get_cpu(); - local_inc(&fs->owner->ref[cpu].count); - put_cpu(); -#else - /* Getting filesystem while it's starting up? We're - already supposed to have a reference. */ - BUG(); -#endif - } + __module_get(fs->owner); } void put_filesystem(struct file_system_type *fs) 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; diff --git a/kernel/module.c b/kernel/module.c index 17e2884ce495..06ff9328b30b 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -431,7 +431,7 @@ static inline void restart_refcounts(void) } #endif -static unsigned int module_refcount(struct module *mod) +unsigned int module_refcount(struct module *mod) { unsigned int i, total = 0; @@ -439,6 +439,7 @@ static unsigned int module_refcount(struct module *mod) total += atomic_read(&mod->ref[i].count); return total; } +EXPORT_SYMBOL(module_refcount); /* This exists whether we can unload or not */ static void free_module(struct module *mod); -- cgit v1.2.3