From patchwork Wed Mar 22 16:53:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 9639415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C985E6020B for ; Wed, 22 Mar 2017 16:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6CD528452 for ; Wed, 22 Mar 2017 16:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A926728458; Wed, 22 Mar 2017 16:55:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4561028452 for ; Wed, 22 Mar 2017 16:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mU6oTZyWUhu9k2TWawh/Sq4XpYlow5QwtCOVrYeBBwU=; b=TPC3dmgnDsLA32 qXM/1iCDoW9HmW748RahKfYRcPaiW4FGkomHu6NW9JW/UwD1AIgZD60qJ1LrHS0ycoOOKJUXCw2qB iyMTz62H87t5hAs6u4Gdkwwcc13UlT6seKNIIcBOD/2L1ieFJm+qIY6WdbfW9QCZP3FAuHdC1rUQ/ Ecr5Uo70FS2SL7l9zcp+A1DhrgkuQOQiFc+wDHDIFJLQ38Z35+OvTSqbOyEpIVJEhKvuVduhlJd6M Q7ZepgCBDnL1O/HMblJS65ph+6WF7Vi34piWX1RBs0P6y4o5Vi0KyyQR3mukJx1ygAGMoG5VaZLku hwlS9W0aPpPazNG4fmng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqjXK-00044U-9y; Wed, 22 Mar 2017 16:55:02 +0000 Received: from mail-co1nam03on0051.outbound.protection.outlook.com ([104.47.40.51] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqjWQ-0002v6-0q for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2017 16:54:10 +0000 Received: from BN6PR03CA0016.namprd03.prod.outlook.com (10.168.230.154) by CY1PR03MB2268.namprd03.prod.outlook.com (10.166.207.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Wed, 22 Mar 2017 16:53:49 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::159) by BN6PR03CA0016.outlook.office365.com (2603:10b6:404:23::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.977.11 via Frontend Transport; Wed, 22 Mar 2017 16:53:49 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Wed, 22 Mar 2017 16:53:48 +0000 Received: from fsr-ub1664-115.ea.freescale.net (fsr-ub1664-115.ea.freescale.net [10.171.73.212]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2MGrKXe024800; Wed, 22 Mar 2017 09:53:45 -0700 From: Leonard Crestez To: Mark Brown , Liam Girdwood , Viresh Kumar , "Rafael J. Wysocki" , Shawn Guo , Sascha Hauer Subject: [RFC 6/8] regulator: core: Add regulator_is_bypass function Date: Wed, 22 Mar 2017 18:53:08 +0200 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131346752292005914; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39860400002)(39400400002)(39840400002)(39410400002)(39450400003)(39380400002)(39850400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(305945005)(2950100002)(356003)(86362001)(6666003)(50986999)(39060400002)(5660300001)(4326008)(38730400002)(50466002)(575784001)(76176999)(7416002)(106466001)(105606002)(5003940100001)(33646002)(47776003)(48376002)(104016004)(53936002)(8936002)(50226002)(36756003)(8656002)(54906002)(85426001)(118296001)(2906002)(81166006)(77096006)(8676002)(189998001)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2268; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:gAWr5UtfVtBDWaET6OGny9Jmp1trJ2Od+6WLYNmkHTcZGeJo+i5HvFajV4dhdFnuUN71mEFh/EZore+XLBFhdlytIs26g6f5XtlU1ZLEktHkV4Bl9866E59wdBGBZVeGL8WMv/HWNoMRHPic7CwXdaL70qWJv6XDcjGn8yKME/zfsu48zqE3MSbO8pGA7PO2UHYXI7BnW+2NHXIhiSW1QzT1gegdR7XUYF9716OAdTnH7SzdClI5Ksnvq6VKpK1RCFQfYZZhoCf1Ublh9046v+4Q7ehjgfQAiNmS567/4QdoYIbpKODVxsggldywjcf0cl1eTnUbSaRnYRxGQcgbLuChiunpebfVxMO2I+HuugL5C3+w6TKd3rca67ddxzVWqIF+pAOBGEAc4/jSJa4lMP0IqDihpPawV7rjZX1Dixfo3MKBGMrXaels2CC1/Qu+yZ2DKbBvVk3kpJrQC6FaGroWR6RTFU8IztLnnRWCABjbWLJF1qOuVjgHsLQldIWnk4HdwZggyA6by+QQqnPsYrA9UZx6rwOWtlohKsQNmKO0gZuDNlUA35w65BYUS6AIkUc3YO3vFhXEQ+kNy0Q6fc4XKzZTfOMwPH1YBwrlCFcMFPpSEQxQT3bMNxbuJhg2 MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 66b8a7eb-0590-4b5d-1d12-08d471440328 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR03MB2268; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2268; 3:hO0Ycw6eEePuG5f940N5/QkmmqzXOgjsySieE7ma0Ec+eZeWmpupF7n06S5Hp9Yi3Mk/LejGQOexZ5U4rKTswoAiiMH19PMs9nAWaupvw8gRazMF5VMHHSnlQchfUUEepx8CP6vLynEv23p544VD9Lz4ctbp1pPdVyIiwCKb6X9UCYrZtrxYC5FjDA507h9JHgkYloc8pJCIsI/8cn7Ef1erIw9eWOhjHm3yCKrj4y8/vJTggg0FSlcQhe9VsYeDXNZD1lUPKNFry51Uwdyx82bipTXQ8DnUzM6UWkmr56/k4u6ym0+K75WTS3Az2k3oghTvlRc3Ky6vyeIUOKNTZqjwoc1Yr8LUE+HhN9oOXNjV95mHvtZthblwl1tUE/tc; 25:iLWU0zG5iw+8ckf8E7V36zmO8ijsk5aghAwau1beS5AFXp3FLd4DMS+FKeePKVp7SxSOn4YcGNqqplbl1URp8Ue4fsQWQjrUqpPr8BREA4kpbV8/vjb1vUi+tM/kA/pCdA8RaFlP+5k27FLZFaVjseXaO3zcQS6hFqLNlwiqFUYZQrvwauSDjONLaEhqH2IWiWRzHBABYMnPQdI8ClQUtj3pnRDtQG1mEYBpghHhmj6nBsxJ5xFZz+O1FEXHKV87Qd/dnaUaLHjvriLH8ClV6JHPoW49YYOmF3lAbSDB+dc2fffRj14OdB+SphACXi5VhLA9ikkoVAJD89n06aNRVtAwaSkHC8gFxo/bNQvMprq6tzpbn35CDeGTIJ+yNRl9bAf2UXqfIFeR5PdPSDl3TcDGnnvWeb71s/KngJQH5ljRiJgY6Mg4TQHlBhII6k44PzCZ7MlMdBt1Z/opqRBtYw== X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2268; 31:wXe/Y1xcSQQMwdjyFS+b6gQ1/OaUZuv1DtuRYwA6kqdShLz6XI1DtfiCG9ntFdzA0U0UZ8xKL0d9gZsM/pT/MOOnttoKuVJynb8cAIUwDo/Fnau/D+Ky03ZqTwzu3mQkzMzbMS3eLPznb9lTdHimeieAP7V1bQX+8Z5MHOhDKqGtL0esEm1Y8UK0yuYRBkCS4l6QdBf1Ev5klbM80sWyUnhlxIYdaLAYZrNgYYTXCAr0YzwQio9PFUmHQJTOgtmpTDhCPEY7xueA/d5+bFm7Hg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13024025)(8121501046)(5005006)(13015025)(13017025)(13018025)(13023025)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123559025)(20161123556025)(20161123563025)(20161123561025); SRVR:CY1PR03MB2268; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2268; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2268; 4:HSsZ/9sHEI2LSSKDPlBHKXiE1BSfO1g7Q0sHVwaRLKoLxDJW2iZGkx+r3m41U9s0OUS6b8vaiQTQYFz0ylwgDhEI7l1W7YS6i7ECi1ob/GXe4uci8wSKtb6wYIJ8iA4OMzTlJmuprW2N1HpgojDudkg7bf71V4+i+ce/BqBHmJ0amj5JqVyQqLZ80pUlNZXt6MxIHVu0/WWk8ZidvklYKEOu3nZ2VTvmbmx7aZ/c8wes6fyzmbn8AvmtacRqwnqVWM6IhEiP/SWER9qRKcnUHchFdDYrDARjHd+7pLli7f/zcgp2CUXX3RANPexOj7woI4rBZTkNXf/GVj4SJ9RWLHyupyejhCG2iYP6bfu9fKNMqeHRNmjqhrLhZqpUxSw9tjIzvCBLkbNN22laMkGHb40h97jzdzyiZCJnrtVVi/bbsBwUEH4XQH7K/YisjP8CPRo2flthMi08IAB8KdWEIouP6NNAdbO0PMIcd3REGp2h7j3IfJQkTZa342mWYCB5c0+/iYCn7TIL/DhZJAFUMvZPHI6fOTGJPQ1a5pDdOzNFrikx6Z7dW0++zOFIV6MUQ1lxxUboqXFufooTAspJkHnkldetygB0db8Y86Y2vGp1Y1iu9Sbshsj1tXLxNCkb5fODhN+5zrvCtZsJiu6GDDAfs2orsXAXl3Z1Da2TXNwcdQv21G+WRYu226pgyEkHlBASqV8zIOgRxhcowDvhTFjFPAyXvDfQRb4TAo8VH91I88jk8NQgT/lrRY87fUBB X-Forefront-PRVS: 02543CD7CD X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2268; 23:BlQx0z8xo97yg2o3AB5uAO+PZ705mjaBQ0FY2EZqp?= =?us-ascii?Q?JVDWT4hSqkwop6sH1zyjmD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y6OUNLlfJb8Msfdq/lyHbD/Eky/gsUkArdb78Fw3TNkucBzSr2x+CMo7KFuFKJNW2sjoPclFT4Ai5GIJCCk9IngvWwOnrBhEMLDvszo00= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2268; 7:Eor30yw1iqqygu2iVCcMtn/llQNcSsjtNFvznrnTZkrR/eGw25NnNk5VUX0eImgXmc59pm0dS6IcQj0LFA2ai9PVWfY37oHY3JfCOxN0IdxLX37If/fD26bgipCre2Ts5InsfjwtAchpkDq4tc7jPoFe5fH4CtnalFJLcnJ7VERC35SFG10mqLx0wqDAmBHtTpX/8MeYHOb/sHROVeYT3UyqO2sePJbuwYSmZ+XMAKaaufWbrIw5MkYdemjEUkTNoSwCLLl63BUT/foi9OvmqPI9sJICNuhvo4ky3MvFK5EtSk+XjarcsG4jDiiqE+KUnDXZ3KBNPOSm7cNsIU+gmQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 16:53:48.8417 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB2268 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_095407_094291_F1330F18 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Leonard Crestez , Anson Huang , Irina Tirdea , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Octavian Purdila , Fabio Estevam , Robin Gong , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is a simple kernel API to query the bypass state of a regulator. Signed-off-by: Leonard Crestez --- drivers/regulator/core.c | 26 ++++++++++++++++++++++++++ include/linux/regulator/consumer.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9d893aa..7d4f59e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3554,6 +3554,32 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable) EXPORT_SYMBOL_GPL(regulator_allow_bypass); /** + * regulator_is_bypass - Determine if the regulator is in bypass mode + * + * @regulator: Regulator to examine + * + * @return 0 or 1 for true/false or errno on failure + * + * Returns zero on a regulator without bypass support. + */ +int regulator_is_bypass(struct regulator *regulator) +{ + struct regulator_dev *rdev = regulator->rdev; + bool bypass; + int ret = 0; + + if (!rdev->desc->ops->get_bypass) + return 0; + + mutex_lock(&rdev->mutex); + ret = rdev->desc->ops->get_bypass(rdev, &bypass); + mutex_unlock(&rdev->mutex); + + return ret ? ret : !!bypass; +} +EXPORT_SYMBOL_GPL(regulator_is_bypass); + +/** * regulator_register_notifier - register regulator event notifier * @regulator: regulator source * @nb: notifier block diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index ea0fffa..ba78511 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -261,6 +261,7 @@ int regulator_get_error_flags(struct regulator *regulator, int regulator_set_load(struct regulator *regulator, int load_uA); int regulator_allow_bypass(struct regulator *regulator, bool allow); +int regulator_is_bypass(struct regulator *regulator); struct regmap *regulator_get_regmap(struct regulator *regulator); int regulator_get_hardware_vsel_register(struct regulator *regulator,