* [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
@ 2011-12-15 3:02 ` Rusty Russell
0 siblings, 0 replies; 9+ messages in thread
From: Rusty Russell @ 2011-12-15 3:02 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Pawel Moll, Steve Glendinning, Jean Delvare, Guenter Roeck,
Hoang-Nam Nguyen, Christoph Raisch, Roland Dreier, Sean Hefty,
Hal Rosenstock, linux390-tA70FqPdS9bQT0dZR+AlfA,
Anton Altaparmakov, Jaroslav Kysela, Takashi Iwai,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-s390-u79uwXL29TY76Z2rM5mHXA,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
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-sdUf+H5yV5I@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
Cc: Hoang-Nam Nguyen <hnguyen-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Cc: Christoph Raisch <raisch-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Hal Rosenstock <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux390-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
Cc: Anton Altaparmakov <anton-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org>
Cc: Jaroslav Kysela <perex-/Fr2/VpizcU@public.gmane.org>
Cc: Takashi Iwai <tiwai-l3A5Bk7waGM@public.gmane.org>
Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
---
drivers/hwmon/emc2103.c | 2 +-
drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
drivers/s390/cio/cmf.c | 2 +-
fs/ntfs/super.c | 2 +-
include/linux/moduleparam.h | 6 ++++++
kernel/params.c | 24 ++++++++++++++++++++++++
sound/pci/intel8x0.c | 4 ++--
7 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
* it. Default is to leave the device in the state it's already in (-1).
* This parameter allows APD mode to be optionally forced on or off */
static int apd = -1;
-module_param(apd, bool, 0);
+module_param(apd, bint, 0);
MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
struct temperature {
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
--- 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_p
module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
-module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
+module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -98,7 +98,7 @@ enum cmb_format {
* enum cmb_format.
*/
static int format = CMF_AUTODETECT;
-module_param(format, bool, 0444);
+module_param(format, bint, 0444);
/**
* struct cmb_operations - functions to use depending on cmb_format
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
MODULE_VERSION(NTFS_VERSION);
MODULE_LICENSE("GPL");
#ifdef DEBUG
-module_param(debug_msgs, bool, 0);
+module_param(debug_msgs, bint, 0);
MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -367,6 +367,12 @@ extern int param_set_invbool(const char
extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
#define param_check_invbool(name, p) __param_check(name, p, bool)
+/* An int, which can only be set like a bool (though it shows as an int). */
+extern struct kernel_param_ops param_ops_bint;
+extern int param_set_bint(const char *val, const struct kernel_param *kp);
+#define param_get_bint param_get_int
+#define param_check_bint param_check_int
+
/**
* module_param_array - a parameter which is an array of some type
* @name: the name of the array variable
diff --git a/kernel/params.c b/kernel/params.c
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
};
EXPORT_SYMBOL(param_ops_invbool);
+int param_set_bint(const char *val, const struct kernel_param *kp)
+{
+ struct kernel_param boolkp;
+ bool v;
+ int ret;
+
+ /* Match bool exactly, by re-using it. */
+ boolkp = *kp;
+ boolkp.arg = &v;
+ boolkp.flags |= KPARAM_ISBOOL;
+
+ ret = param_set_bool(val, &boolkp);
+ if (ret == 0)
+ *(int *)kp->arg = v;
+ return ret;
+}
+EXPORT_SYMBOL(param_set_bint);
+
+struct kernel_param_ops param_ops_bint = {
+ .set = param_set_bint,
+ .get = param_get_int,
+};
+EXPORT_SYMBOL(param_ops_bint);
+
/* We break the rule and mangle the string. */
static int param_array(const char *name,
const char *val,
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
module_param(buggy_semaphore, bool, 0444);
MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
-module_param(buggy_irq, bool, 0444);
+module_param(buggy_irq, bint, 0444);
MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
module_param(xbox, bool, 0444);
MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
module_param(spdif_aclink, int, 0444);
MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
-module_param(inside_vm, bool, 0444);
+module_param(inside_vm, bint, 0444);
MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
/* just for backward compatibility */
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
@ 2011-12-15 3:02 ` Rusty Russell
0 siblings, 0 replies; 9+ messages in thread
From: Rusty Russell @ 2011-12-15 3:02 UTC (permalink / raw)
To: linux-kernel
Cc: Pawel Moll, Steve Glendinning, Jean Delvare, Guenter Roeck,
Hoang-Nam Nguyen, Christoph Raisch, Roland Dreier, Sean Hefty,
Hal Rosenstock, linux390, Anton Altaparmakov, Jaroslav Kysela,
Takashi Iwai, lm-sensors, linux-rdma, linux-s390, linux-ntfs-dev,
alsa-devel
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
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/hwmon/emc2103.c | 2 +-
drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
drivers/s390/cio/cmf.c | 2 +-
fs/ntfs/super.c | 2 +-
include/linux/moduleparam.h | 6 ++++++
kernel/params.c | 24 ++++++++++++++++++++++++
sound/pci/intel8x0.c | 4 ++--
7 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
* it. Default is to leave the device in the state it's already in (-1).
* This parameter allows APD mode to be optionally forced on or off */
static int apd = -1;
-module_param(apd, bool, 0);
+module_param(apd, bint, 0);
MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
struct temperature {
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
--- 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_p
module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
-module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
+module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -98,7 +98,7 @@ enum cmb_format {
* enum cmb_format.
*/
static int format = CMF_AUTODETECT;
-module_param(format, bool, 0444);
+module_param(format, bint, 0444);
/**
* struct cmb_operations - functions to use depending on cmb_format
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
MODULE_VERSION(NTFS_VERSION);
MODULE_LICENSE("GPL");
#ifdef DEBUG
-module_param(debug_msgs, bool, 0);
+module_param(debug_msgs, bint, 0);
MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -367,6 +367,12 @@ extern int param_set_invbool(const char
extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
#define param_check_invbool(name, p) __param_check(name, p, bool)
+/* An int, which can only be set like a bool (though it shows as an int). */
+extern struct kernel_param_ops param_ops_bint;
+extern int param_set_bint(const char *val, const struct kernel_param *kp);
+#define param_get_bint param_get_int
+#define param_check_bint param_check_int
+
/**
* module_param_array - a parameter which is an array of some type
* @name: the name of the array variable
diff --git a/kernel/params.c b/kernel/params.c
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
};
EXPORT_SYMBOL(param_ops_invbool);
+int param_set_bint(const char *val, const struct kernel_param *kp)
+{
+ struct kernel_param boolkp;
+ bool v;
+ int ret;
+
+ /* Match bool exactly, by re-using it. */
+ boolkp = *kp;
+ boolkp.arg = &v;
+ boolkp.flags |= KPARAM_ISBOOL;
+
+ ret = param_set_bool(val, &boolkp);
+ if (ret == 0)
+ *(int *)kp->arg = v;
+ return ret;
+}
+EXPORT_SYMBOL(param_set_bint);
+
+struct kernel_param_ops param_ops_bint = {
+ .set = param_set_bint,
+ .get = param_get_int,
+};
+EXPORT_SYMBOL(param_ops_bint);
+
/* We break the rule and mangle the string. */
static int param_array(const char *name,
const char *val,
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
module_param(buggy_semaphore, bool, 0444);
MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
-module_param(buggy_irq, bool, 0444);
+module_param(buggy_irq, bint, 0444);
MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
module_param(xbox, bool, 0444);
MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
module_param(spdif_aclink, int, 0444);
MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
-module_param(inside_vm, bool, 0444);
+module_param(inside_vm, bint, 0444);
MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
/* just for backward compatibility */
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse,
@ 2011-12-15 3:02 ` Rusty Russell
0 siblings, 0 replies; 9+ messages in thread
From: Rusty Russell @ 2011-12-15 3:14 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Pawel Moll, Steve Glendinning, Jean Delvare, Guenter Roeck,
Hoang-Nam Nguyen, Christoph Raisch, Roland Dreier, Sean Hefty,
Hal Rosenstock, linux390-tA70FqPdS9bQT0dZR+AlfA,
Anton Altaparmakov, Jaroslav Kysela, Takashi Iwai,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-s390-u79uwXL29TY76Z2rM5mHXA,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
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
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/hwmon/emc2103.c | 2 +-
drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
drivers/s390/cio/cmf.c | 2 +-
fs/ntfs/super.c | 2 +-
include/linux/moduleparam.h | 6 ++++++
kernel/params.c | 24 ++++++++++++++++++++++++
sound/pci/intel8x0.c | 4 ++--
7 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
* it. Default is to leave the device in the state it's already in (-1).
* This parameter allows APD mode to be optionally forced on or off */
static int apd = -1;
-module_param(apd, bool, 0);
+module_param(apd, bint, 0);
MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
struct temperature {
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
--- 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_p
module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
-module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
+module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -98,7 +98,7 @@ enum cmb_format {
* enum cmb_format.
*/
static int format = CMF_AUTODETECT;
-module_param(format, bool, 0444);
+module_param(format, bint, 0444);
/**
* struct cmb_operations - functions to use depending on cmb_format
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
MODULE_VERSION(NTFS_VERSION);
MODULE_LICENSE("GPL");
#ifdef DEBUG
-module_param(debug_msgs, bool, 0);
+module_param(debug_msgs, bint, 0);
MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -367,6 +367,12 @@ extern int param_set_invbool(const char
extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
#define param_check_invbool(name, p) __param_check(name, p, bool)
+/* An int, which can only be set like a bool (though it shows as an int). */
+extern struct kernel_param_ops param_ops_bint;
+extern int param_set_bint(const char *val, const struct kernel_param *kp);
+#define param_get_bint param_get_int
+#define param_check_bint param_check_int
+
/**
* module_param_array - a parameter which is an array of some type
* @name: the name of the array variable
diff --git a/kernel/params.c b/kernel/params.c
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
};
EXPORT_SYMBOL(param_ops_invbool);
+int param_set_bint(const char *val, const struct kernel_param *kp)
+{
+ struct kernel_param boolkp;
+ bool v;
+ int ret;
+
+ /* Match bool exactly, by re-using it. */
+ boolkp = *kp;
+ boolkp.arg = &v;
+ boolkp.flags |= KPARAM_ISBOOL;
+
+ ret = param_set_bool(val, &boolkp);
+ if (ret = 0)
+ *(int *)kp->arg = v;
+ return ret;
+}
+EXPORT_SYMBOL(param_set_bint);
+
+struct kernel_param_ops param_ops_bint = {
+ .set = param_set_bint,
+ .get = param_get_int,
+};
+EXPORT_SYMBOL(param_ops_bint);
+
/* We break the rule and mangle the string. */
static int param_array(const char *name,
const char *val,
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
module_param(buggy_semaphore, bool, 0444);
MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
-module_param(buggy_irq, bool, 0444);
+module_param(buggy_irq, bint, 0444);
MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
module_param(xbox, bool, 0444);
MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
module_param(spdif_aclink, int, 0444);
MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
-module_param(inside_vm, bool, 0444);
+module_param(inside_vm, bint, 0444);
MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
/* just for backward compatibility */
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
[not found] ` <877h1ytu4d.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-12-15 12:31 ` [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse, Takashi Iwai
@ 2011-12-15 12:31 ` Takashi Iwai
1 sibling, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2011-12-15 12:31 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pawel Moll,
Steve Glendinning, Jean Delvare, Guenter Roeck, Hoang-Nam Nguyen,
Christoph Raisch, Roland Dreier, Sean Hefty, Hal Rosenstock,
linux390-tA70FqPdS9bQT0dZR+AlfA, Anton Altaparmakov,
Jaroslav Kysela, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-s390-u79uwXL29TY76Z2rM5mHXA,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
At Thu, 15 Dec 2011 13:32:26 +1030,
Rusty Russell wrote:
>
> 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-sdUf+H5yV5I@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
> Cc: Hoang-Nam Nguyen <hnguyen-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> Cc: Christoph Raisch <raisch-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Hal Rosenstock <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: linux390-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
> Cc: Anton Altaparmakov <anton-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org>
> Cc: Jaroslav Kysela <perex-/Fr2/VpizcU@public.gmane.org>
> Cc: Takashi Iwai <tiwai-l3A5Bk7waGM@public.gmane.org>
For the sound part,
Acked-by: Takashi Iwai <tiwai-l3A5Bk7waGM@public.gmane.org>
It's a nice feature. I know many drivers can be replaced with bint
gracefully now (e.g. i915 driver).
thanks,
Takashi
> Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
> Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
> Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
> ---
> drivers/hwmon/emc2103.c | 2 +-
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret == 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse,
@ 2011-12-15 12:31 ` Takashi Iwai
0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2011-12-15 12:31 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Pawel Moll,
Steve Glendinning, Jean Delvare, Guenter Roeck, Hoang-Nam Nguyen,
Christoph Raisch, Roland Dreier, Sean Hefty, Hal Rosenstock,
linux390-tA70FqPdS9bQT0dZR+AlfA, Anton Altaparmakov,
Jaroslav Kysela, lm-sensors-GZX6beZjE8VD60Wz+7aTrA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-s390-u79uwXL29TY76Z2rM5mHXA,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
At Thu, 15 Dec 2011 13:32:26 +1030,
Rusty Russell wrote:
>
> 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>
For the sound part,
Acked-by: Takashi Iwai <tiwai@suse.de>
It's a nice feature. I know many drivers can be replaced with bint
gracefully now (e.g. i915 driver).
thanks,
Takashi
> 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
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/hwmon/emc2103.c | 2 +-
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret = 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
@ 2011-12-15 12:31 ` Takashi Iwai
0 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2011-12-15 12:31 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel, Pawel Moll, Steve Glendinning, Jean Delvare,
Guenter Roeck, Hoang-Nam Nguyen, Christoph Raisch, Roland Dreier,
Sean Hefty, Hal Rosenstock, linux390, Anton Altaparmakov,
Jaroslav Kysela, lm-sensors, linux-rdma, linux-s390,
linux-ntfs-dev, alsa-devel
At Thu, 15 Dec 2011 13:32:26 +1030,
Rusty Russell wrote:
>
> 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>
For the sound part,
Acked-by: Takashi Iwai <tiwai@suse.de>
It's a nice feature. I know many drivers can be replaced with bint
gracefully now (e.g. i915 driver).
thanks,
Takashi
> 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
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/hwmon/emc2103.c | 2 +-
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret == 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
[not found] ` <877h1ytu4d.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-12-15 12:31 ` [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse, Takashi Iwai
@ 2011-12-15 20:41 ` Guenter Roeck
1 sibling, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2011-12-15 20:41 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Pawel Moll,
Steve Glendinning, Jean Delvare, Hoang-Nam Nguyen,
Christoph Raisch, Roland Dreier, Sean Hefty, Hal Rosenstock,
linux390-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org,
Anton Altaparmakov, Jaroslav Kysela, Takashi Iwai,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
On Wed, Dec 14, 2011 at 10:02:26PM -0500, Rusty Russell wrote:
> 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-sdUf+H5yV5I@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
> Cc: Hoang-Nam Nguyen <hnguyen-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> Cc: Christoph Raisch <raisch-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
> Cc: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: Hal Rosenstock <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: linux390-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
> Cc: Anton Altaparmakov <anton-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org>
> Cc: Jaroslav Kysela <perex-/Fr2/VpizcU@public.gmane.org>
> Cc: Takashi Iwai <tiwai-l3A5Bk7waGM@public.gmane.org>
> Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
> Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
> Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
> ---
> drivers/hwmon/emc2103.c | 2 +-
For the hwmon driver:
Acked-by: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret == 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
--
Guenter Roeck
Distinguished Engineer
PDU IP Systems
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse,
@ 2011-12-15 20:41 ` Guenter Roeck
0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2011-12-15 20:41 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Pawel Moll,
Steve Glendinning, Jean Delvare, Hoang-Nam Nguyen,
Christoph Raisch, Roland Dreier, Sean Hefty, Hal Rosenstock,
linux390-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org,
Anton Altaparmakov, Jaroslav Kysela, Takashi Iwai,
lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-ntfs-dev-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
On Wed, Dec 14, 2011 at 10:02:26PM -0500, Rusty Russell wrote:
> 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
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/hwmon/emc2103.c | 2 +-
For the hwmon driver:
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret = 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
--
Guenter Roeck
Distinguished Engineer
PDU IP Systems
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases.
@ 2011-12-15 20:41 ` Guenter Roeck
0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2011-12-15 20:41 UTC (permalink / raw)
To: Rusty Russell
Cc: linux-kernel@vger.kernel.org, Pawel Moll, Steve Glendinning,
Jean Delvare, Hoang-Nam Nguyen, Christoph Raisch, Roland Dreier,
Sean Hefty, Hal Rosenstock, linux390@de.ibm.com,
Anton Altaparmakov, Jaroslav Kysela, Takashi Iwai,
lm-sensors@lm-sensors.org, linux-rdma@vger.kernel.org,
linux-s390@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net,
alsa-devel@alsa-project.org
On Wed, Dec 14, 2011 at 10:02:26PM -0500, Rusty Russell wrote:
> 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
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/hwmon/emc2103.c | 2 +-
For the hwmon driver:
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
> drivers/infiniband/hw/ehca/ehca_main.c | 2 +-
> drivers/s390/cio/cmf.c | 2 +-
> fs/ntfs/super.c | 2 +-
> include/linux/moduleparam.h | 6 ++++++
> kernel/params.c | 24 ++++++++++++++++++++++++
> sound/pci/intel8x0.c | 4 ++--
> 7 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
> --- a/drivers/hwmon/emc2103.c
> +++ b/drivers/hwmon/emc2103.c
> @@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34
> * it. Default is to leave the device in the state it's already in (-1).
> * This parameter allows APD mode to be optionally forced on or off */
> static int apd = -1;
> -module_param(apd, bool, 0);
> +module_param(apd, bint, 0);
> MODULE_PARM_DESC(init, "Set to zero to disable anti-parallel diode mode");
>
> struct temperature {
> diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
> --- 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_p
> module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO);
> module_param_named(static_rate, ehca_static_rate, int, S_IRUGO);
> module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO);
> -module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO);
> +module_param_named(lock_hcalls, ehca_lock_hcalls, bint, S_IRUGO);
> module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO);
> module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO);
>
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -98,7 +98,7 @@ enum cmb_format {
> * enum cmb_format.
> */
> static int format = CMF_AUTODETECT;
> -module_param(format, bool, 0444);
> +module_param(format, bint, 0444);
>
> /**
> * struct cmb_operations - functions to use depending on cmb_format
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver
> MODULE_VERSION(NTFS_VERSION);
> MODULE_LICENSE("GPL");
> #ifdef DEBUG
> -module_param(debug_msgs, bool, 0);
> +module_param(debug_msgs, bint, 0);
> MODULE_PARM_DESC(debug_msgs, "Enable debug messages.");
> #endif
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -367,6 +367,12 @@ extern int param_set_invbool(const char
> extern int param_get_invbool(char *buffer, const struct kernel_param *kp);
> #define param_check_invbool(name, p) __param_check(name, p, bool)
>
> +/* An int, which can only be set like a bool (though it shows as an int). */
> +extern struct kernel_param_ops param_ops_bint;
> +extern int param_set_bint(const char *val, const struct kernel_param *kp);
> +#define param_get_bint param_get_int
> +#define param_check_bint param_check_int
> +
> /**
> * module_param_array - a parameter which is an array of some type
> * @name: the name of the array variable
> diff --git a/kernel/params.c b/kernel/params.c
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -369,6 +369,30 @@ struct kernel_param_ops param_ops_invboo
> };
> EXPORT_SYMBOL(param_ops_invbool);
>
> +int param_set_bint(const char *val, const struct kernel_param *kp)
> +{
> + struct kernel_param boolkp;
> + bool v;
> + int ret;
> +
> + /* Match bool exactly, by re-using it. */
> + boolkp = *kp;
> + boolkp.arg = &v;
> + boolkp.flags |= KPARAM_ISBOOL;
> +
> + ret = param_set_bool(val, &boolkp);
> + if (ret == 0)
> + *(int *)kp->arg = v;
> + return ret;
> +}
> +EXPORT_SYMBOL(param_set_bint);
> +
> +struct kernel_param_ops param_ops_bint = {
> + .set = param_set_bint,
> + .get = param_get_int,
> +};
> +EXPORT_SYMBOL(param_ops_bint);
> +
> /* We break the rule and mangle the string. */
> static int param_array(const char *name,
> const char *val,
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -95,13 +95,13 @@ module_param(ac97_quirk, charp, 0444);
> MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
> module_param(buggy_semaphore, bool, 0444);
> MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
> -module_param(buggy_irq, bool, 0444);
> +module_param(buggy_irq, bint, 0444);
> MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
> module_param(xbox, bool, 0444);
> MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
> module_param(spdif_aclink, int, 0444);
> MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
> -module_param(inside_vm, bool, 0444);
> +module_param(inside_vm, bint, 0444);
> MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
>
> /* just for backward compatibility */
--
Guenter Roeck
Distinguished Engineer
PDU IP Systems
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-12-15 20:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15 3:02 [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases Rusty Russell
2011-12-15 3:14 ` [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse, Rusty Russell
2011-12-15 3:02 ` [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases Rusty Russell
[not found] ` <877h1ytu4d.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-12-15 12:31 ` Takashi Iwai
2011-12-15 12:31 ` Takashi Iwai
2011-12-15 12:31 ` [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse, Takashi Iwai
2011-12-15 20:41 ` [PATCH 2/15] module_param: avoid bool abuse, add bint for special cases Guenter Roeck
2011-12-15 20:41 ` Guenter Roeck
2011-12-15 20:41 ` [lm-sensors] [PATCH 2/15] module_param: avoid bool abuse, Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.