diff options
author | Dmitry Torokhov <dtor@vmware.com> | 2010-12-15 17:00:19 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-01-23 23:02:51 -0500 |
commit | e94965ed5beb23c6fabf7ed31f625e66d7ff28de (patch) | |
tree | 842e4cab961b568bcb98d8ab80d7d399110598a4 /include | |
parent | 1bae4ce27c9c90344f23c65ea6966c50ffeae2f5 (diff) |
module: show version information for built-in modules in sysfs
Currently only drivers that are built as modules have their versions
shown in /sys/module/<module_name>/version, but this information might
also be useful for built-in drivers as well. This especially important
for drivers that do not define any parameters - such drivers, if
built-in, are completely invisible from userspace.
This patch changes MODULE_VERSION() macro so that in case when we are
compiling built-in module, version information is stored in a separate
section. Kernel then uses this data to create 'version' sysfs attribute
in the same fashion it creates attributes for module parameters.
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 7 | ||||
-rw-r--r-- | include/linux/module.h | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 68649336c4ad..6ebb81030d2d 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -364,6 +364,13 @@ | |||
364 | VMLINUX_SYMBOL(__start___param) = .; \ | 364 | VMLINUX_SYMBOL(__start___param) = .; \ |
365 | *(__param) \ | 365 | *(__param) \ |
366 | VMLINUX_SYMBOL(__stop___param) = .; \ | 366 | VMLINUX_SYMBOL(__stop___param) = .; \ |
367 | } \ | ||
368 | \ | ||
369 | /* Built-in module versions. */ \ | ||
370 | __modver : AT(ADDR(__modver) - LOAD_OFFSET) { \ | ||
371 | VMLINUX_SYMBOL(__start___modver) = .; \ | ||
372 | *(__modver) \ | ||
373 | VMLINUX_SYMBOL(__stop___modver) = .; \ | ||
367 | . = ALIGN((align)); \ | 374 | . = ALIGN((align)); \ |
368 | VMLINUX_SYMBOL(__end_rodata) = .; \ | 375 | VMLINUX_SYMBOL(__end_rodata) = .; \ |
369 | } \ | 376 | } \ |
diff --git a/include/linux/module.h b/include/linux/module.h index 8b17fd8c790d..50efcd3ae850 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -58,6 +58,12 @@ struct module_attribute { | |||
58 | void (*free)(struct module *); | 58 | void (*free)(struct module *); |
59 | }; | 59 | }; |
60 | 60 | ||
61 | struct module_version_attribute { | ||
62 | struct module_attribute mattr; | ||
63 | const char *module_name; | ||
64 | const char *version; | ||
65 | }; | ||
66 | |||
61 | struct module_kobject | 67 | struct module_kobject |
62 | { | 68 | { |
63 | struct kobject kobj; | 69 | struct kobject kobj; |
@@ -161,7 +167,28 @@ extern struct module __this_module; | |||
161 | Using this automatically adds a checksum of the .c files and the | 167 | Using this automatically adds a checksum of the .c files and the |
162 | local headers in "srcversion". | 168 | local headers in "srcversion". |
163 | */ | 169 | */ |
170 | |||
171 | #ifdef MODULE | ||
164 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) | 172 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
173 | #else | ||
174 | #define MODULE_VERSION(_version) \ | ||
175 | extern ssize_t __modver_version_show(struct module_attribute *, \ | ||
176 | struct module *, char *); \ | ||
177 | static struct module_version_attribute __modver_version_attr \ | ||
178 | __used \ | ||
179 | __attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \ | ||
180 | = { \ | ||
181 | .mattr = { \ | ||
182 | .attr = { \ | ||
183 | .name = "version", \ | ||
184 | .mode = S_IRUGO, \ | ||
185 | }, \ | ||
186 | .show = __modver_version_show, \ | ||
187 | }, \ | ||
188 | .module_name = KBUILD_MODNAME, \ | ||
189 | .version = _version, \ | ||
190 | } | ||
191 | #endif | ||
165 | 192 | ||
166 | /* Optional firmware file (or files) needed by the module | 193 | /* Optional firmware file (or files) needed by the module |
167 | * format is simply firmware file name. Multiple firmware | 194 | * format is simply firmware file name. Multiple firmware |