aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-01-12 18:02:17 -0500
committerRusty Russell <rusty@rustcorp.com.au>2012-01-12 18:02:17 -0500
commit69116f279a9eaf4c540934269342d9149538fc79 (patch)
treeeb335b97a99fb25ce548dd06f053a81e3c56016f
parentbafeafeab94b8d3019aac15c2df2ce47b08a6363 (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>
-rw-r--r--drivers/hwmon/emc2103.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/s390/cio/cmf.c2
-rw-r--r--fs/ntfs/super.c2
-rw-r--r--include/linux/moduleparam.h6
-rw-r--r--kernel/params.c24
-rw-r--r--sound/pci/intel8x0.c4
7 files changed, 36 insertions, 6 deletions
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 848a2b0bc83f..865063914d76 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34, 0x30, 0x31, 0x32 };
55 * it. Default is to leave the device in the state it's already in (-1). 55 * it. Default is to leave the device in the state it's already in (-1).
56 * This parameter allows APD mode to be optionally forced on or off */ 56 * This parameter allows APD mode to be optionally forced on or off */
57static int apd = -1; 57static int apd = -1;
58module_param(apd, bool, 0); 58module_param(apd, bint, 0);
59MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode"); 59MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
60 60
61struct temperature { 61struct temperature {
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index c240e9972cb0..8af8d4f7bdb1 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -82,7 +82,7 @@ module_param_named(port_act_time, ehca_port_act_time, int, S_IRUGO);
82module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO); 82module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
83module_param_named(static_rate, ehca_static_rate, int, S_IRUGO); 83module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
84module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO); 84module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
85module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO); 85module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
86module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO); 86module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
87module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO); 87module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
88 88
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 2985eb439485..204ca728e7fd 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -98,7 +98,7 @@ enum cmb_format {
98 * enum cmb_format. 98 * enum cmb_format.
99 */ 99 */
100static int format = CMF_AUTODETECT; 100static int format = CMF_AUTODETECT;
101module_param(format, bool, 0444); 101module_param(format, bint, 0444);
102 102
103/** 103/**
104 * struct cmb_operations - functions to use depending on cmb_format 104 * struct cmb_operations - functions to use depending on cmb_format
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 608be4516091..5a4a8af5c406 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2011 Anton Altaparm
3198MODULE_VERSION(NTFS_VERSION); 3198MODULE_VERSION(NTFS_VERSION);
3199MODULE_LICENSE("GPL"); 3199MODULE_LICENSE("GPL");
3200#ifdef DEBUG 3200#ifdef DEBUG
3201module_param(debug_msgs, bool, 0); 3201module_param(debug_msgs, bint, 0);
3202MODULE_PARM_DESC(debug_msgs, "Enable debug messages."); 3202MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
3203#endif 3203#endif
3204 3204
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 794d4b0f1215..6bdde0c3bcca 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -367,6 +367,12 @@ extern int param_set_invbool(const char *val, const struct kernel_param *kp);
367extern int param_get_invbool(char *buffer, const struct kernel_param *kp); 367extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
368#define param_check_invbool(name, p) __param_check(name, p, bool) 368#define param_check_invbool(name, p) __param_check(name, p, bool)
369 369
370/* An int, which can only be set like a bool (though it shows as an int). */
371extern struct kernel_param_ops param_ops_bint;
372extern int param_set_bint(const char *val, const struct kernel_param *kp);
373#define param_get_bint param_get_int
374#define param_check_bint param_check_int
375
370/** 376/**
371 * module_param_array - a parameter which is an array of some type 377 * module_param_array - a parameter which is an array of some type
372 * @name: the name of the array variable 378 * @name: the name of the array variable
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};
364EXPORT_SYMBOL(param_ops_invbool); 364EXPORT_SYMBOL(param_ops_invbool);
365 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
366/* We break the rule and mangle the string. */ 390/* We break the rule and mangle the string. */
367static int param_array(const char *name, 391static int param_array(const char *name,
368 const char *val, 392 const char *val,
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 40b181bab930..9f3b01bb72c8 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
95MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 95MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
96module_param(buggy_semaphore, bool, 0444); 96module_param(buggy_semaphore, bool, 0444);
97MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores."); 97MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
98module_param(buggy_irq, bool, 0444); 98module_param(buggy_irq, bint, 0444);
99MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards."); 99MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
100module_param(xbox, bool, 0444); 100module_param(xbox, bool, 0444);
101MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection."); 101MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
102module_param(spdif_aclink, int, 0444); 102module_param(spdif_aclink, int, 0444);
103MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); 103MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
104module_param(inside_vm, bool, 0444); 104module_param(inside_vm, bint, 0444);
105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization."); 105MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
106 106
107/* just for backward compatibility */ 107/* just for backward compatibility */