Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69116f27 authored by Rusty Russell's avatar Rusty Russell
Browse files

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: default avatarRusty Russell <rusty@rustcorp.com.au>
parent bafeafea
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ static const u8 REG_TEMP_MAX[4] = { 0x34, 0x30, 0x31, 0x32 };
 * 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 {
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ module_param_named(port_act_time, ehca_port_act_time, int, S_IRUGO);
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);

+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -3198,7 +3198,7 @@ MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2011 Anton Altaparm
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

+6 −0
Original line number Diff line number Diff line
@@ -367,6 +367,12 @@ extern int param_set_invbool(const char *val, const struct kernel_param *kp);
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
Loading