Return-path: Received: from mail-pa0-f46.google.com ([209.85.220.46]:36849 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932540AbbDVWGN (ORCPT ); Wed, 22 Apr 2015 18:06:13 -0400 From: "Luis R. Rodriguez" To: rusty@rustcorp.com.au Cc: akpm@linux-foundation.org, mingo@kernel.org, tj@kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, keescook@chromium.org, casey@schaufler-ca.com, cocci@systeme.lip6.fr, "Luis R. Rodriguez" , Jani Nikula Subject: [PATCH v2 4/8] moduleparam.h: add module_param_config_*() helpers Date: Wed, 22 Apr 2015 14:55:07 -0700 Message-Id: <1429739711-9415-5-git-send-email-mcgrof@do-not-panic.com> (sfid-20150423_000628_173777_6B92D518) In-Reply-To: <1429739711-9415-1-git-send-email-mcgrof@do-not-panic.com> References: <1429739711-9415-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-wireless-owner@vger.kernel.org List-ID: From: "Luis R. Rodriguez" This adds a couple of bool module_param_config_*() helpers which are designed to let us easily associate a boolean module parameter with an associated kernel configuration option. Folks can use this to avoid what typically would be #ifdef eyesores around module parameter declarations. Cc: Rusty Russell Cc: Jani Nikula Cc: Andrew Morton Cc: Kees Cook Cc: Tejun Heo Cc: Ingo Molnar Cc: linux-kernel@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by: Luis R. Rodriguez --- include/linux/moduleparam.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 7e00799..5416372 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 parameter 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 parameter 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