mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
1bae4ce27c
commit
e94965ed5b
3 changed files with 88 additions and 11 deletions
|
@ -58,6 +58,12 @@ struct module_attribute {
|
|||
void (*free)(struct module *);
|
||||
};
|
||||
|
||||
struct module_version_attribute {
|
||||
struct module_attribute mattr;
|
||||
const char *module_name;
|
||||
const char *version;
|
||||
};
|
||||
|
||||
struct module_kobject
|
||||
{
|
||||
struct kobject kobj;
|
||||
|
@ -161,7 +167,28 @@ extern struct module __this_module;
|
|||
Using this automatically adds a checksum of the .c files and the
|
||||
local headers in "srcversion".
|
||||
*/
|
||||
|
||||
#ifdef MODULE
|
||||
#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
|
||||
#else
|
||||
#define MODULE_VERSION(_version) \
|
||||
extern ssize_t __modver_version_show(struct module_attribute *, \
|
||||
struct module *, char *); \
|
||||
static struct module_version_attribute __modver_version_attr \
|
||||
__used \
|
||||
__attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \
|
||||
= { \
|
||||
.mattr = { \
|
||||
.attr = { \
|
||||
.name = "version", \
|
||||
.mode = S_IRUGO, \
|
||||
}, \
|
||||
.show = __modver_version_show, \
|
||||
}, \
|
||||
.module_name = KBUILD_MODNAME, \
|
||||
.version = _version, \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Optional firmware file (or files) needed by the module
|
||||
* format is simply firmware file name. Multiple firmware
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue