diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-01-12 18:02:17 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-01-12 18:02:17 -0500 |
commit | 69116f279a9eaf4c540934269342d9149538fc79 (patch) | |
tree | eb335b97a99fb25ce548dd06f053a81e3c56016f /kernel | |
parent | bafeafeab94b8d3019aac15c2df2ce47b08a6363 (diff) |
module_param: avoid bool abuse, add bint for special cases.
For historical reasons, we allow module_param(bool) to take an int (or
an unsigned int). That's going away.
A few drivers really want an int: they set it to -1 and a parameter
will set it to 0 or 1. This sucks: reading them from sysfs will give
'Y' for both -1 and 1, but if we change it to an int, then the users
might be broken (if they did "param" instead of "param=1").
Use a new 'bint' parser for them.
(ntfs has a different problem: it needs an int for debug_msgs because
it's also exposed via sysctl.)
Cc: Steve Glendinning <steve.glendinning@smsc.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
Cc: Christoph Raisch <raisch@de.ibm.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: linux390@de.ibm.com
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: lm-sensors@lm-sensors.org
Cc: linux-rdma@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-ntfs-dev@lists.sourceforge.net
Cc: alsa-devel@alsa-project.org
Acked-by: Takashi Iwai <tiwai@suse.de> (For the sound part)
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com> (For the hwmon driver)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/params.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/params.c b/kernel/params.c index 9240664af110..32ee04308285 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -363,6 +363,30 @@ struct kernel_param_ops param_ops_invbool = { | |||
363 | }; | 363 | }; |
364 | EXPORT_SYMBOL(param_ops_invbool); | 364 | EXPORT_SYMBOL(param_ops_invbool); |
365 | 365 | ||
366 | int 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 | } | ||
382 | EXPORT_SYMBOL(param_set_bint); | ||
383 | |||
384 | struct kernel_param_ops param_ops_bint = { | ||
385 | .set = param_set_bint, | ||
386 | .get = param_get_int, | ||
387 | }; | ||
388 | EXPORT_SYMBOL(param_ops_bint); | ||
389 | |||
366 | /* We break the rule and mangle the string. */ | 390 | /* We break the rule and mangle the string. */ |
367 | static int param_array(const char *name, | 391 | static int param_array(const char *name, |
368 | const char *val, | 392 | const char *val, |