1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
10 #include <ecoli_init.h>
12 static struct ec_init_list init_list = TAILQ_HEAD_INITIALIZER(init_list);
14 /* register an init function */
15 void ec_init_register(struct ec_init *init)
19 if (TAILQ_EMPTY(&init_list)) {
20 TAILQ_INSERT_HEAD(&init_list, init, next);
25 TAILQ_FOREACH(cur, &init_list, next) {
26 if (init->priority > cur->priority)
29 TAILQ_INSERT_BEFORE(cur, init, next);
33 TAILQ_INSERT_TAIL(&init_list, init, next);
40 TAILQ_FOREACH(init, &init_list, next) {
41 if (init->init != NULL && init->init() < 0)
52 TAILQ_FOREACH_REVERSE(init, &init_list, ec_init_list, next) {
53 if (init->exit != NULL)