aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2006-11-24 06:15:25 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-13 18:38:45 -0500
commit1f71740ab9714bf5ae9ee04c724ff0d5c67ca3dc (patch)
tree0573d4f21472e7eb3509f71f74dfc8443a415db4 /kernel/module.c
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/module.c')
-rw-r--r--kernel/module.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c
index d9eae45d0145..b565eaeff7e6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -824,9 +824,34 @@ static inline void module_unload_init(struct module *mod)
824} 824}
825#endif /* CONFIG_MODULE_UNLOAD */ 825#endif /* CONFIG_MODULE_UNLOAD */
826 826
827static ssize_t show_initstate(struct module_attribute *mattr,
828 struct module *mod, char *buffer)
829{
830 const char *state = "unknown";
831
832 switch (mod->state) {
833 case MODULE_STATE_LIVE:
834 state = "live";
835 break;
836 case MODULE_STATE_COMING:
837 state = "coming";
838 break;
839 case MODULE_STATE_GOING:
840 state = "going";
841 break;
842 }
843 return sprintf(buffer, "%s\n", state);
844}
845
846static struct module_attribute initstate = {
847 .attr = { .name = "initstate", .mode = 0444, .owner = THIS_MODULE },
848 .show = show_initstate,
849};
850
827static struct module_attribute *modinfo_attrs[] = { 851static struct module_attribute *modinfo_attrs[] = {
828 &modinfo_version, 852 &modinfo_version,
829 &modinfo_srcversion, 853 &modinfo_srcversion,
854 &initstate,
830#ifdef CONFIG_MODULE_UNLOAD 855#ifdef CONFIG_MODULE_UNLOAD
831 &refcnt, 856 &refcnt,
832#endif 857#endif