diff options
author | Thomas Graf <tgraf@suug.ch> | 2013-07-13 13:05:20 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-07-13 13:05:20 +0200 |
commit | 509d64bd1821b086c62737ea1bf8e01524ee2c05 (patch) | |
tree | 0b021d797a013127e2629b78c5df31a28cab6836 /include | |
parent | 2c047d2af35fa40b4ef916df2ea2753686e49358 (diff) |
module: Support auto enabling and enforce single registration of module
Enforces a single registration of a module with a subsystem.
module_register() now returns -EBUSY if module is already
registered.
Adds support for BMON_MODULE_AUTO to flag modules that should
be autoloaded upon the first call to module_set(). Loading
will succeed if the probe() function succeeds.
Diffstat (limited to 'include')
-rw-r--r-- | include/bmon/module.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/bmon/module.h b/include/bmon/module.h index bd1405a..16ddabf 100644 --- a/include/bmon/module.h +++ b/include/bmon/module.h @@ -29,8 +29,11 @@ #include <bmon/bmon.h> #include <bmon/conf.h> -#define BMON_MODULE_ENABLED 1 -#define BMON_MODULE_DEFAULT 2 +#define BMON_MODULE_ENABLED (1 << 0) /* Enabled */ +#define BMON_MODULE_DEFAULT (1 << 1) /* Suitable as default */ +#define BMON_MODULE_AUTO (1 << 2) /* Auto enable */ + +struct bmon_subsys; struct bmon_module { @@ -48,6 +51,7 @@ struct bmon_module int m_flags; struct list_head m_list; + struct bmon_subsys *m_subsys; }; struct bmon_subsys @@ -65,7 +69,7 @@ extern void module_foreach_run_enabled_pre(struct bmon_subsys *); extern void module_foreach_run_enabled(struct bmon_subsys *); extern void module_foreach_run_enabled_post(struct bmon_subsys *); -extern void module_register(struct bmon_subsys *, struct bmon_module *); +extern int module_register(struct bmon_subsys *, struct bmon_module *); extern int module_set(struct bmon_subsys *, const char *); extern void module_init(void); |