From patchwork Wed Apr 22 21:55:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6258501 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5440ABF4A6 for ; Wed, 22 Apr 2015 22:06:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BE022035E for ; Wed, 22 Apr 2015 22:06:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 679A020376 for ; Wed, 22 Apr 2015 22:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932996AbbDVWGP (ORCPT ); Wed, 22 Apr 2015 18:06:15 -0400 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 Received: by pabsx10 with SMTP id sx10so38803pab.3; Wed, 22 Apr 2015 15:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4qovS405afCaGgXJd/LLaDrthv6j0orPMdIXjjpq/qg=; b=XwZcHDQL6/uBxKEl72JH4qd2fip11U2WcKoQXr/d27R0AS2xRqarcAhhizZJcf8/ya I1BNnWDhMKod5OjKsA5DmIl2vRLbFHfAI8t4Xm1opvk3ajj6fqf5iKjmdCgosHc5TfKH v63P4OLd5IYobpF+DOxJoTqypmw1JbrFSX2oxLcicsjcOkPSwuiXx0mQZ3xETHFOl2vn KJZddat5Qy3r1Ych/pMqUGDYZcbmS2W3LjKyDbFKqfIkHCR+wtS7eDH/RgSXXPzLJlxC EeyJC7aRZVq6ljnlP5z0i2SHap1PhNtgt2nq45fp4kEBK9Fza/T42roouAhCp5p+4WtB QJLg== X-Received: by 10.68.107.69 with SMTP id ha5mr50318451pbb.140.1429740372536; Wed, 22 Apr 2015 15:06:12 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id b10sm6050281pdj.0.2015.04.22.15.06.10 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Apr 2015 15:06:11 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 22 Apr 2015 15:04:02 -0700 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> X-Mailer: git-send-email 2.1.0 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 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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.