summaryrefslogtreecommitdiffstats
path: root/kernel/params.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/params.c')
-rw-r--r--kernel/params.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/kernel/params.c b/kernel/params.c
index 65aae11eb93f..32ee04308285 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -25,12 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/ctype.h> 26#include <linux/ctype.h>
27 27
28#if 0
29#define DEBUGP printk
30#else
31#define DEBUGP(fmt, a...)
32#endif
33
34/* Protects all parameters, and incidentally kmalloced_param list. */ 28/* Protects all parameters, and incidentally kmalloced_param list. */
35static DEFINE_MUTEX(param_lock); 29static DEFINE_MUTEX(param_lock);
36 30
@@ -105,7 +99,7 @@ static int parse_one(char *param,
105 /* No one handled NULL, so do it here. */ 99 /* No one handled NULL, so do it here. */
106 if (!val && params[i].ops->set != param_set_bool) 100 if (!val && params[i].ops->set != param_set_bool)
107 return -EINVAL; 101 return -EINVAL;
108 DEBUGP("They are equal! Calling %p\n", 102 pr_debug("They are equal! Calling %p\n",
109 params[i].ops->set); 103 params[i].ops->set);
110 mutex_lock(&param_lock); 104 mutex_lock(&param_lock);
111 err = params[i].ops->set(val, &params[i]); 105 err = params[i].ops->set(val, &params[i]);
@@ -115,11 +109,11 @@ static int parse_one(char *param,
115 } 109 }
116 110
117 if (handle_unknown) { 111 if (handle_unknown) {
118 DEBUGP("Unknown argument: calling %p\n", handle_unknown); 112 pr_debug("Unknown argument: calling %p\n", handle_unknown);
119 return handle_unknown(param, val); 113 return handle_unknown(param, val);
120 } 114 }
121 115
122 DEBUGP("Unknown argument `%s'\n", param); 116 pr_debug("Unknown argument `%s'\n", param);
123 return -ENOENT; 117 return -ENOENT;
124} 118}
125 119
@@ -184,7 +178,7 @@ int parse_args(const char *name,
184{ 178{
185 char *param, *val; 179 char *param, *val;
186 180
187 DEBUGP("Parsing ARGS: %s\n", args); 181 pr_debug("Parsing ARGS: %s\n", args);
188 182
189 /* Chew leading spaces */ 183 /* Chew leading spaces */
190 args = skip_spaces(args); 184 args = skip_spaces(args);
@@ -369,6 +363,30 @@ struct kernel_param_ops param_ops_invbool = {
369}; 363};
370EXPORT_SYMBOL(param_ops_invbool); 364EXPORT_SYMBOL(param_ops_invbool);
371 365
366int param_set_bint(const char *val, const struct kernel_param *kp)
367{
368 struct kernel_param boolkp;
369 bool v;
370 int ret;
371
372 /* Match bool exactly, by re-using it. */
373 boolkp = *kp;
374 boolkp.arg = &v;
375 boolkp.flags |= KPARAM_ISBOOL;
376
377 ret = param_set_bool(val, &boolkp);
378 if (ret == 0)
379 *(int *)kp->arg = v;
380 return ret;
381}
382EXPORT_SYMBOL(param_set_bint);
383
384struct kernel_param_ops param_ops_bint = {
385 .set = param_set_bint,
386 .get = param_get_int,
387};
388EXPORT_SYMBOL(param_ops_bint);
389
372/* We break the rule and mangle the string. */ 390/* We break the rule and mangle the string. */
373static int param_array(const char *name, 391static int param_array(const char *name,
374 const char *val, 392 const char *val,