From patchwork Mon Apr 20 23:30:35 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: 6244901 X-Patchwork-Delegate: johannes@sipsolutions.net 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 AF4BEBF4A6 for ; Mon, 20 Apr 2015 23:32:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B86B620266 for ; Mon, 20 Apr 2015 23:32:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A765C20421 for ; Mon, 20 Apr 2015 23:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754240AbbDTXbd (ORCPT ); Mon, 20 Apr 2015 19:31:33 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33398 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754167AbbDTXb3 (ORCPT ); Mon, 20 Apr 2015 19:31:29 -0400 Received: by paboj16 with SMTP id oj16so221882629pab.0; Mon, 20 Apr 2015 16:31:28 -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=Ttjz1MWBpNu8V8La4VKDAipZNoa5nIrk/NvYn8+BQz8=; b=I8RDwqEwHILPkFJX5PPjwSmePewYJb+Bb+zYHt1qSCvYw0iO4JPhVF0EYMSrWXKx19 exzv9J2VvsrmFbzKE5RltaPDt14p0+OGLdLINFStz6YOuN6NK0B6yvOoSmGMVIU5jeum Cdsubrd5OxnTDtV4m4Ff7UcZrEKpQv3qCg6R+OjunntCVQkb28ge4pgrAeTw2LopMa6Q dIrzr3oUmLF+t6Cdj9xexgtKWtU7qHDp9VBsDCzD0kal9bZhXXD+8S+Xd97VJw6KRoKq dqHKprlW3PEe8KwcN7eTo/1K81Go9XWYbxwcxXbEvXNwqle5dgVEgG/+f6xtKUkUCu1t GwrA== X-Received: by 10.70.55.199 with SMTP id u7mr32067547pdp.42.1429572688751; Mon, 20 Apr 2015 16:31:28 -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 b10sm82980pdj.0.2015.04.20.16.31.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Apr 2015 16:31:27 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Mon, 20 Apr 2015 16:31:25 -0700 From: "Luis R. Rodriguez" To: rusty@rustcorp.com.au Cc: 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 , Christoph Hellwig , Andrew Morton , Geert Uytterhoeven , Hannes Reinecke , Tejun Heo , Ingo Molnar Subject: [PATCH v1 4/6] moduleparam.h: add module_param_config_*() helpers Date: Mon, 20 Apr 2015 16:30:35 -0700 Message-Id: <1429572637-30234-5-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429572637-30234-1-git-send-email-mcgrof@do-not-panic.com> References: <1429572637-30234-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 booloean module parameter with an associated kernel configuration option, and to help us remove #ifdef'ery eyesores. Cc: Rusty Russell Cc: Jani Nikula Cc: Christoph Hellwig Cc: Andrew Morton Cc: Geert Uytterhoeven Cc: Hannes Reinecke 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..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.