mirror of https://github.com/schoebel/mars
infra: add constructor for mars_global
This commit is contained in:
parent
21b4874e30
commit
aed146691a
|
@ -119,6 +119,23 @@ struct mars_global {
|
|||
bool main_trigger;
|
||||
};
|
||||
|
||||
extern void _init_mars_global(struct mars_global *global);
|
||||
#define init_mars_global(__global) \
|
||||
do { \
|
||||
_init_mars_global(__global); \
|
||||
init_rwsem(&(__global)->dent_mutex); \
|
||||
init_rwsem(&(__global)->brick_mutex); \
|
||||
} while(0)
|
||||
|
||||
#define alloc_mars_global() \
|
||||
({ \
|
||||
struct mars_global *__global; \
|
||||
\
|
||||
__global = brick_mem_alloc(sizeof(struct mars_global)); \
|
||||
init_mars_global(__global); \
|
||||
__global; \
|
||||
})
|
||||
|
||||
extern void bind_to_dent(struct mars_dent *dent, struct say_channel **ch);
|
||||
|
||||
typedef int (*mars_dent_checker_fn)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel);
|
||||
|
|
|
@ -1081,6 +1081,20 @@ EXPORT_SYMBOL_GPL(bind_to_dent);
|
|||
struct mars_global *mars_global = NULL;
|
||||
EXPORT_SYMBOL_GPL(mars_global);
|
||||
|
||||
void _init_mars_global(struct mars_global *global)
|
||||
{
|
||||
int i;
|
||||
|
||||
memset(global, 0, sizeof(struct mars_global));
|
||||
INIT_LIST_HEAD(&global->dent_anchor);
|
||||
INIT_LIST_HEAD(&global->dent_quick_anchor);
|
||||
INIT_LIST_HEAD(&global->brick_anchor);
|
||||
global->global_power.button = true;
|
||||
init_waitqueue_head(&global->main_event);
|
||||
for (i = 0; i < MARS_GLOBAL_HASH; i++)
|
||||
INIT_LIST_HEAD(&global->dent_hash_anchor[i]);
|
||||
}
|
||||
|
||||
static
|
||||
void __mars_trigger(int mode)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue