Commit 1f71740a authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

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: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent aef6fba4
...@@ -824,9 +824,34 @@ static inline void module_unload_init(struct module *mod) ...@@ -824,9 +824,34 @@ static inline void module_unload_init(struct module *mod)
} }
#endif /* CONFIG_MODULE_UNLOAD */ #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[] = { static struct module_attribute *modinfo_attrs[] = {
&modinfo_version, &modinfo_version,
&modinfo_srcversion, &modinfo_srcversion,
&initstate,
#ifdef CONFIG_MODULE_UNLOAD #ifdef CONFIG_MODULE_UNLOAD
&refcnt, &refcnt,
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment