summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2006-11-24 12:15:25 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-13 15:38:45 -0800
commit1f71740ab9714bf5ae9ee04c724ff0d5c67ca3dc (patch)
tree0573d4f21472e7eb3509f71f74dfc8443a415db4 /kernel
parentaef6fba4f97bbec1dc5a253f388be9a4c7a30e41 (diff)
Driver core: show "initstate" of module
Show the initialization state(live, coming, going) of the module: $ cat /sys/module/usbcore/initstate live Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c
index d9eae45d014..b565eaeff7e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -824,9 +824,34 @@ static inline void module_unload_init(struct module *mod)
}
#endif /* CONFIG_MODULE_UNLOAD */
+static ssize_t show_initstate(struct module_attribute *mattr,
+ struct module *mod, char *buffer)
+{
+ const char *state = "unknown";
+
+ switch (mod->state) {
+ case MODULE_STATE_LIVE:
+ state = "live";
+ break;
+ case MODULE_STATE_COMING:
+ state = "coming";
+ break;
+ case MODULE_STATE_GOING:
+ state = "going";
+ break;
+ }
+ return sprintf(buffer, "%s\n", state);
+}
+
+static struct module_attribute initstate = {
+ .attr = { .name = "initstate", .mode = 0444, .owner = THIS_MODULE },
+ .show = show_initstate,
+};
+
static struct module_attribute *modinfo_attrs[] = {
&modinfo_version,
&modinfo_srcversion,
+ &initstate,
#ifdef CONFIG_MODULE_UNLOAD
&refcnt,
#endif