From: "Luis R. Rodriguez" <mcg...@suse.com> This adds a couple of bool module_param_config_*() helpers which are designed to let us easily associate a booloean module parameter with an associated kernel configuration option, and to help us remove #ifdef'ery eyesores.
Cc: Rusty Russell <ru...@rustcorp.com.au> Cc: Jani Nikula <jani.nik...@intel.com> Cc: Christoph Hellwig <h...@infradead.org> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Geert Uytterhoeven <ge...@linux-m68k.org> Cc: Hannes Reinecke <h...@suse.de> Cc: Kees Cook <keesc...@chromium.org> Cc: Tejun Heo <t...@kernel.org> Cc: Ingo Molnar <mi...@kernel.org> Cc: linux-ker...@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by: Luis R. Rodriguez <mcg...@suse.com> --- include/linux/moduleparam.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 7e00799..fdf7b87 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -155,6 +155,43 @@ struct kparam_array __MODULE_PARM_TYPE(name, #type) /** + * module_param_config_on_off - bool parameter with run time override + * @name: a valid C identifier which is the parameter name. + * @value: the actual lvalue to alter. + * @perm: visibility in sysfs. + * @config: kernel parameter which will enable this option if this + * kernel configuration option has been enabled. + * + * This lets you define a bool module paramter which by default will be + * set to true if the config option has been set on your kernel's + * configuration, otherwise it is set to false. + */ +#define module_param_config_on_off(name, var, perm, config) \ + static bool var = IS_ENABLED(config); \ + module_param_named(name, var, bool, perm); + +/** + * module_param_config_on - bool parameter with run time enablement override + * @name: a valid C identifier which is the parameter name. + * @value: the actual lvalue to alter. + * @perm: visibility in sysfs. + * @config: kernel parameter which will enable this option if this + * kernel configuration option has been enabled. + * + * This lets you define a bool module paramter which by default will be + * set to true if the config option has been set on your kernel's + * configuration, otherwise it is set to false. This particular helper + * will ensure that if the kernel configuration has been set you will not + * be able to disable this kernel parameter. You can only use this to let + * the an option that was disabled on your kernel configuration be enabled + * at run time. + */ +#define module_param_config_on(name, var, perm, config) \ + static bool var = IS_ENABLED(config); \ + module_param_named(name, var, bool_enable_only, perm); + + +/** * module_param_cb - general callback for a module/cmdline parameter * @name: a valid C identifier which is the parameter name. * @ops: the set & get operations for this parameter. -- 2.3.2.209.gd67f9d5.dirty _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci