aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2013-08-20 02:03:19 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-08-20 02:07:42 -0400
commitab013c5f60b7ead254863c75b9adc2a47992d01b (patch)
tree9631f1731699398802646d43b170c133c6988fbc /kernel
parent7cb14ba75d57910cc4b62115dd5db7bd83c93684 (diff)
module: Add flag to allow mod params to have no arguments
Currently the params.c code allows only two "set" functions to have no arguments. If a parameter does not have an argument, then it looks at the set function and tests if it is either param_set_bool() or param_set_bint(). If it is not one of these functions, then it fails the loading of the module. But there may be module parameters that have different set functions and still allow no arguments. But unless each of these cases adds their function to the if statement, it wont be allowed to have no arguments. This method gets rather messing and does not scale. Instead, introduce a flags field to the kernel_param_ops, where if the flag KERNEL_PARAM_FL_NOARG is set, the parameter will not fail if it does not contain an argument. It will be expected that the corresponding set function can handle a NULL pointer as "val". Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/params.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/params.c b/kernel/params.c
index 59f7ac7bec04..ec4299cfade8 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -103,8 +103,8 @@ static int parse_one(char *param,
103 || params[i].level > max_level) 103 || params[i].level > max_level)
104 return 0; 104 return 0;
105 /* No one handled NULL, so do it here. */ 105 /* No one handled NULL, so do it here. */
106 if (!val && params[i].ops->set != param_set_bool 106 if (!val &&
107 && params[i].ops->set != param_set_bint) 107 !(params[i].ops->flags & KERNEL_PARAM_FL_NOARG))
108 return -EINVAL; 108 return -EINVAL;
109 pr_debug("handling %s with %p\n", param, 109 pr_debug("handling %s with %p\n", param,
110 params[i].ops->set); 110 params[i].ops->set);
@@ -320,6 +320,7 @@ int param_get_bool(char *buffer, const struct kernel_param *kp)
320EXPORT_SYMBOL(param_get_bool); 320EXPORT_SYMBOL(param_get_bool);
321 321
322struct kernel_param_ops param_ops_bool = { 322struct kernel_param_ops param_ops_bool = {
323 .flags = KERNEL_PARAM_FL_NOARG,
323 .set = param_set_bool, 324 .set = param_set_bool,
324 .get = param_get_bool, 325 .get = param_get_bool,
325}; 326};
@@ -370,6 +371,7 @@ int param_set_bint(const char *val, const struct kernel_param *kp)
370EXPORT_SYMBOL(param_set_bint); 371EXPORT_SYMBOL(param_set_bint);
371 372
372struct kernel_param_ops param_ops_bint = { 373struct kernel_param_ops param_ops_bint = {
374 .flags = KERNEL_PARAM_FL_NOARG,
373 .set = param_set_bint, 375 .set = param_set_bint,
374 .get = param_get_int, 376 .get = param_get_int,
375}; 377};