diff options
Diffstat (limited to 'userspace/src/module.c')
-rw-r--r-- | userspace/src/module.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/userspace/src/module.c b/userspace/src/module.c index c111c6cb..779c52d3 100644 --- a/userspace/src/module.c +++ b/userspace/src/module.c | |||
@@ -99,6 +99,23 @@ static struct unit_module *load_one_module(struct unit_fw *fw, | |||
99 | return mod; | 99 | return mod; |
100 | } | 100 | } |
101 | 101 | ||
102 | static int cmp_module_prio(const void *__mod_a, const void *__mod_b) | ||
103 | { | ||
104 | const struct unit_module *mod_a = __mod_a; | ||
105 | const struct unit_module *mod_b = __mod_b; | ||
106 | |||
107 | return mod_a->prio > mod_b->prio; | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * Sort the module list according to prio. | ||
112 | */ | ||
113 | static void sort_modules_by_prio(struct unit_module **modules, int nr) | ||
114 | { | ||
115 | qsort(modules, (size_t)nr, sizeof(struct unit_module *), | ||
116 | cmp_module_prio); | ||
117 | } | ||
118 | |||
102 | /* | 119 | /* |
103 | * Load all the modules we can from the module load path. Return the list of | 120 | * Load all the modules we can from the module load path. Return the list of |
104 | * loaded module as an array of pointers to modules. The returned list of | 121 | * loaded module as an array of pointers to modules. The returned list of |
@@ -159,6 +176,9 @@ struct unit_module **core_load_modules(struct unit_fw *fw) | |||
159 | } | 176 | } |
160 | 177 | ||
161 | modules[i] = NULL; | 178 | modules[i] = NULL; |
179 | |||
180 | sort_modules_by_prio(modules, i); | ||
181 | |||
162 | return modules; | 182 | return modules; |
163 | 183 | ||
164 | err: | 184 | err: |