diff options
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 |