From patchwork Fri Oct 31 04:27:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 5202141 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1341C9F318 for ; Fri, 31 Oct 2014 04:28:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 422B0201B4 for ; Fri, 31 Oct 2014 04:28:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A8B020172 for ; Fri, 31 Oct 2014 04:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754310AbaJaE2S (ORCPT ); Fri, 31 Oct 2014 00:28:18 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:64484 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752779AbaJaE1V (ORCPT ); Fri, 31 Oct 2014 00:27:21 -0400 Received: by mail-pd0-f179.google.com with SMTP id g10so6440836pdj.24 for ; Thu, 30 Oct 2014 21:27:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UMTOpc2XkK+derDJaX2YlZHt6Kp8KaLzMjqUmPqqu8c=; b=OOgn8LdaigKpYMnnGSKqgFEUTT7K76uehkyZHARSQxTGNA9BiVjw3A93nX96J/pB0c 58+HDVWubu8zQeJ0hhrU7nl3VcVT2O0Yd8MnIt9ZDgPwPyZhiFmpJEdEMLwHvM/NSdnC sPbZc7Cz/oUDN7Ogz4ospGk+srLc8oMe6PiZxDbBZm1FsMQWKB7/LaDGyJSaDYFf2VtE z+E1XPVGl6uoRf9s16fDSUr63P4QVphw/Km3UmVzhoatHLP2+nw6A5O/Jmru7FdHEgQU 9FgPCMFiykwpYGMJL91CPhwSu9xUb4WpWE3oj8PVCRwf3D70vcDAuy/HCjSn3o5MAL7K fVEQ== X-Gm-Message-State: ALoCoQk0SxMKNUgcqkaJ028MzB2/HkUtbokyzgIcjMXCzUnvCNw8m6/2iW9ZIi8rvLYO2imEwNZH X-Received: by 10.68.132.225 with SMTP id ox1mr21838406pbb.85.1414729640735; Thu, 30 Oct 2014 21:27:20 -0700 (PDT) Received: from tharvey-gw.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id mp5sm8542239pbc.33.2014.10.30.21.27.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 21:27:20 -0700 (PDT) From: Tim Harvey To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Philipp Zabel , Fabio Estevam , Shawn Guo , Lucas Stach , Silvio F , Christian Hemp , Russell King , Iain Paton , linux-pm@vger.kernel.org Subject: [PATCH 2/5] regulator: add function to determine if a regulator is in bypass mode Date: Thu, 30 Oct 2014 21:27:08 -0700 Message-Id: <1414729631-11005-3-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414729631-11005-1-git-send-email-tharvey@gateworks.com> References: <1414729631-11005-1-git-send-email-tharvey@gateworks.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Regulators can be configured to allow bypass mode and can be told by a consumer that they are allowed to go into bypass mode from that consumer's perspective. This adds a function to determine if the regulator actually has gone into bypass mode (meaning all consumers allowed it to do so). Cc: linux-pm@vger.kernel.org Signed-off-by: Tim Harvey --- drivers/regulator/core.c | 23 +++++++++++++++++++++++ include/linux/regulator/consumer.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6d4a627..904c271 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3150,6 +3150,29 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable) EXPORT_SYMBOL_GPL(regulator_allow_bypass); /** + * regulator_is_bypass - determine if a regulator is in bypass mode + * + * @regulator: Regulator to configure + * + * return positive if regulator is in bypass mode. + */ +int regulator_is_bypass(struct regulator *regulator) +{ + struct regulator_dev *rdev = regulator->rdev; + int ret; + + if (!regulator) + return -EINVAL; + + mutex_lock(&rdev->mutex); + ret = regulator->bypass ? 1 : 0; + mutex_unlock(&rdev->mutex); + + return ret; +} +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 972090a..a766946 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -237,6 +237,7 @@ unsigned int regulator_get_mode(struct regulator *regulator); int regulator_set_optimum_mode(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, @@ -493,6 +494,11 @@ static inline int regulator_allow_bypass(struct regulator *regulator, return 0; } +static inline int regulator_is_bypass(struct regulator *regulator) +{ + return 0; +} + static inline struct regmap *regulator_get_regmap(struct regulator *regulator) { return ERR_PTR(-EOPNOTSUPP);