From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932754AbbCELvN (ORCPT ); Thu, 5 Mar 2015 06:51:13 -0500 Received: from terminus.zytor.com ([198.137.202.10]:47915 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932663AbbCELvJ (ORCPT ); Thu, 5 Mar 2015 06:51:09 -0500 Date: Thu, 5 Mar 2015 03:50:15 -0800 From: "tip-bot for Luis R. Rodriguez" Message-ID: Cc: mingo@kernel.org, david.vrabel@citrix.com, iamjoonsoo.kim@lge.com, linux-kernel@vger.kernel.org, vbabka@suse.cz, bp@suse.de, torvalds@linux-foundation.org, JBeulich@suse.com, jgross@suse.com, tony@atomide.com, mcgrof@suse.com, tglx@linutronix.de, bp@alien8.de, qiuxishi@huawei.com, gregkh@linuxfoundation.org, dave.hansen@linux.intel.com, luto@amacapital.net, hpa@zytor.com, akpm@linux-foundation.org, decui@microsoft.com, pavel@ucw.cz, toshi.kani@hp.com Reply-To: jgross@suse.com, JBeulich@suse.com, torvalds@linux-foundation.org, bp@suse.de, vbabka@suse.cz, linux-kernel@vger.kernel.org, iamjoonsoo.kim@lge.com, david.vrabel@citrix.com, mingo@kernel.org, mcgrof@suse.com, tony@atomide.com, bp@alien8.de, tglx@linutronix.de, toshi.kani@hp.com, pavel@ucw.cz, akpm@linux-foundation.org, decui@microsoft.com, hpa@zytor.com, luto@amacapital.net, dave.hansen@linux.intel.com, gregkh@linuxfoundation.org, qiuxishi@huawei.com In-Reply-To: <1425518654-3403-4-git-send-email-mcgrof@do-not-panic.com> References: <1425518654-3403-4-git-send-email-mcgrof@do-not-panic.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] init.h: Add early_param_on_off() Git-Commit-ID: bfb33bad83f650f265ed65cbfe8352b7c3ce8c76 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: bfb33bad83f650f265ed65cbfe8352b7c3ce8c76 Gitweb: http://git.kernel.org/tip/bfb33bad83f650f265ed65cbfe8352b7c3ce8c76 Author: Luis R. Rodriguez AuthorDate: Wed, 4 Mar 2015 17:24:13 -0800 Committer: Ingo Molnar CommitDate: Thu, 5 Mar 2015 08:02:12 +0100 init.h: Add early_param_on_off() At times all you need is a kconfig variable to enable a feature, by default but you may want to also enable / disable it through a kernel parameter. In such cases the parameter routines to turn the thing on / off are really simple. Just use a wrapper for this, it lets us generalize the code and makes it easier to associate parameters with related kernel configuration options. Signed-off-by: Luis R. Rodriguez Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Borislav Petkov Cc: Dave Hansen Cc: David Vrabel Cc: Dexuan Cui Cc: Greg Kroah-Hartman Cc: H. Peter Anvin Cc: JBeulich@suse.com Cc: Jan Beulich Cc: Joonsoo Kim Cc: Juergen Gross Cc: Linus Torvalds Cc: Pavel Machek Cc: Thomas Gleixner Cc: Tony Lindgren Cc: Toshi Kani Cc: Vlastimil Babka Cc: Xishi Qiu Cc: julia.lawall@lip6.fr Link: http://lkml.kernel.org/r/1425518654-3403-4-git-send-email-mcgrof@do-not-panic.com Signed-off-by: Ingo Molnar --- include/linux/init.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/init.h b/include/linux/init.h index 2df8e8d..bc11ff9 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -268,6 +268,21 @@ struct obs_kernel_param { #define early_param(str, fn) \ __setup_param(str, fn, fn, 1) +#define early_param_on_off(str_on, str_off, var, config) \ + int var = IS_ENABLED(config); \ + static int __init parse_##var##_on(char *arg) \ + { \ + var = 1; \ + return 0; \ + } \ + static int __init parse_##var##_off(char *arg) \ + { \ + var = 0; \ + return 0; \ + } \ + __setup_param(str_on, parse_##var##_on, parse_##var##_on, 1); \ + __setup_param(str_off, parse_##var##_off, parse_##var##_off, 1) + /* Relies on boot_command_line being set */ void __init parse_early_param(void); void __init parse_early_options(char *cmdline);