aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/params.c
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2012-03-25 22:20:51 -0400
committerRusty Russell <rusty@rustcorp.com.au>2012-03-25 22:20:51 -0400
commit026cee0086fe1df4cf74691cf273062cc769617d (patch)
tree22735ecd2132de4570fbad81e5716f7fee3448d5 /kernel/params.c
parent8b8252813dee8e8cd453bb219731c36b268c69a7 (diff)
params: <level>_initcall-like kernel parameters
This patch adds a set of macros that can be used to declare kernel parameters to be parsed _before_ initcalls at a chosen level are executed. We rename the now-unused "flags" field of struct kernel_param as the level. It's signed, for when we use this for early params as well, in future. Linker macro collating init calls had to be modified in order to add additional symbols between levels that are later used by the init code to split the calls into blocks. Signed-off-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/params.c')
-rw-r--r--kernel/params.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/params.c b/kernel/params.c
index 508828afb874..f37d82631347 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -87,6 +87,8 @@ static int parse_one(char *param,
87 char *val, 87 char *val,
88 const struct kernel_param *params, 88 const struct kernel_param *params,
89 unsigned num_params, 89 unsigned num_params,
90 s16 min_level,
91 s16 max_level,
90 int (*handle_unknown)(char *param, char *val)) 92 int (*handle_unknown)(char *param, char *val))
91{ 93{
92 unsigned int i; 94 unsigned int i;
@@ -95,6 +97,9 @@ static int parse_one(char *param,
95 /* Find parameter */ 97 /* Find parameter */
96 for (i = 0; i < num_params; i++) { 98 for (i = 0; i < num_params; i++) {
97 if (parameq(param, params[i].name)) { 99 if (parameq(param, params[i].name)) {
100 if (params[i].level < min_level
101 || params[i].level > max_level)
102 return 0;
98 /* No one handled NULL, so do it here. */ 103 /* No one handled NULL, so do it here. */
99 if (!val && params[i].ops->set != param_set_bool 104 if (!val && params[i].ops->set != param_set_bool
100 && params[i].ops->set != param_set_bint) 105 && params[i].ops->set != param_set_bint)
@@ -174,6 +179,8 @@ int parse_args(const char *name,
174 char *args, 179 char *args,
175 const struct kernel_param *params, 180 const struct kernel_param *params,
176 unsigned num, 181 unsigned num,
182 s16 min_level,
183 s16 max_level,
177 int (*unknown)(char *param, char *val)) 184 int (*unknown)(char *param, char *val))
178{ 185{
179 char *param, *val; 186 char *param, *val;
@@ -189,7 +196,8 @@ int parse_args(const char *name,
189 196
190 args = next_arg(args, &param, &val); 197 args = next_arg(args, &param, &val);
191 irq_was_disabled = irqs_disabled(); 198 irq_was_disabled = irqs_disabled();
192 ret = parse_one(param, val, params, num, unknown); 199 ret = parse_one(param, val, params, num,
200 min_level, max_level, unknown);
193 if (irq_was_disabled && !irqs_disabled()) { 201 if (irq_was_disabled && !irqs_disabled()) {
194 printk(KERN_WARNING "parse_args(): option '%s' enabled " 202 printk(KERN_WARNING "parse_args(): option '%s' enabled "
195 "irq's!\n", param); 203 "irq's!\n", param);
@@ -374,7 +382,7 @@ static int param_array(const char *name,
374 unsigned int min, unsigned int max, 382 unsigned int min, unsigned int max,
375 void *elem, int elemsize, 383 void *elem, int elemsize,
376 int (*set)(const char *, const struct kernel_param *kp), 384 int (*set)(const char *, const struct kernel_param *kp),
377 u16 flags, 385 s16 level,
378 unsigned int *num) 386 unsigned int *num)
379{ 387{
380 int ret; 388 int ret;
@@ -384,7 +392,7 @@ static int param_array(const char *name,
384 /* Get the name right for errors. */ 392 /* Get the name right for errors. */
385 kp.name = name; 393 kp.name = name;
386 kp.arg = elem; 394 kp.arg = elem;
387 kp.flags = flags; 395 kp.level = level;
388 396
389 *num = 0; 397 *num = 0;
390 /* We expect a comma-separated list of values. */ 398 /* We expect a comma-separated list of values. */
@@ -425,7 +433,7 @@ static int param_array_set(const char *val, const struct kernel_param *kp)
425 unsigned int temp_num; 433 unsigned int temp_num;
426 434
427 return param_array(kp->name, val, 1, arr->max, arr->elem, 435 return param_array(kp->name, val, 1, arr->max, arr->elem,
428 arr->elemsize, arr->ops->set, kp->flags, 436 arr->elemsize, arr->ops->set, kp->level,
429 arr->num ?: &temp_num); 437 arr->num ?: &temp_num);
430} 438}
431 439