From 5cc4c1f83f1050cb47ea7e7bbc90ff35ef411e8a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 20 Feb 2012 17:41:50 +0000 Subject: [PATCH] Use 'bool' type for 'bool' module parameters, if supported. In the compatibility header for linux/moduleparam.h, define a type COMEDI_MODULE_PARAM_BOOL_T to be used for 'bool' module parameters. For kernel versions before 2.6.31, make it an 'int'. For kernel versions 2.6.31 onwards, make it a 'bool'. Support for bool module parameters of type 'int' or 'unsigned int' is going away in kernel version 3.4. In kernel version 3.3 it produces a warning. The only bool module parameter we currently have is 'comedi_autoconfig'. Moved the #include "comedi_fops.h" after the #include to get it to compile. Signed-off-by: Ian Abbott --- comedi/comedi_fops.c | 8 ++++---- comedi/comedi_fops.h | 2 +- comedi/drivers.c | 3 ++- include/linux/moduleparam.h | 13 +++++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 5437712d..53d6acaf 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -24,9 +24,6 @@ #undef DEBUG #define __NO_VERSION__ -#include "comedi_fops.h" -#include "comedi_compat32.h" - #include #include #include @@ -49,6 +46,9 @@ #include #include +#include "comedi_fops.h" +#include "comedi_compat32.h" + //#include "kvmem.h" MODULE_AUTHOR("http://www.comedi.org"); @@ -60,7 +60,7 @@ int comedi_debug; module_param(comedi_debug, int, 0644); #endif -int comedi_autoconfig = 1; +COMEDI_MODULE_PARAM_BOOL_T comedi_autoconfig = 1; module_param(comedi_autoconfig, bool, 0444); int comedi_num_legacy_minors = 0; diff --git a/comedi/comedi_fops.h b/comedi/comedi_fops.h index ef7c5cc3..d6ac451e 100644 --- a/comedi/comedi_fops.h +++ b/comedi/comedi_fops.h @@ -4,6 +4,6 @@ extern struct class *comedi_class; extern const struct file_operations comedi_fops; -extern int comedi_autoconfig; +extern COMEDI_MODULE_PARAM_BOOL_T comedi_autoconfig; #endif //_COMEDI_FOPS_H diff --git a/comedi/drivers.c b/comedi/drivers.c index 33042672..4eed3671 100644 --- a/comedi/drivers.c +++ b/comedi/drivers.c @@ -24,7 +24,6 @@ #define _GNU_SOURCE #define __NO_VERSION__ -#include "comedi_fops.h" #include #include #include @@ -47,6 +46,8 @@ #include #include +#include "comedi_fops.h" + static int postconfig(comedi_device * dev); static int insn_rw_emulate_bits(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data); diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index e80d8d29..391c04a7 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -100,4 +100,17 @@ MODULE_PARM(name, "1-" __MODULE_STRING(len) _MODULE_PARM_STRING_##type) #endif /* module_param_array */ +/* + * Define a type for 'bool' parameters.... + */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) +/* Need to use 'int' or 'unsigned int' for 'bool' module parameter. */ +typedef int COMEDI_MODULE_PARAM_BOOL_T; +#else +/* Can use 'int', 'unsigned int' or 'bool' for 'bool' module parameter, but + * only 'bool' will be allowed for kernel version 3.4 onwards. Using 'int' + * or 'unsigned int' results in a warning for kernel version 3.3. */ +typedef bool COMEDI_MODULE_PARAM_BOOL_T; +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + #endif /* _COMPAT_MODULEPARAM_H */ -- 2.26.2