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: 5202191 Return-Path: X-Original-To: patchwork-linux-arm@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 3DDCF9F318 for ; Fri, 31 Oct 2014 04:30:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72C9320176 for ; Fri, 31 Oct 2014 04:30:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FB79201C7 for ; Fri, 31 Oct 2014 04:30:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk3oT-0006IX-DB; Fri, 31 Oct 2014 04:27:49 +0000 Received: from mail-pa0-f51.google.com ([209.85.220.51]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk3oJ-0006FH-U1 for linux-arm-kernel@lists.infradead.org; Fri, 31 Oct 2014 04:27:40 +0000 Received: by mail-pa0-f51.google.com with SMTP id kq14so6903242pab.38 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=drQIT6EM5IfCHbhJJsIsfHsYGlNFr3T68vzvMvAfdzNl6e4hl3nu4CLhfA/vHrmI7Q utAuQ0h/Xj0ggi0qHehoub1oC4f5rGx8ieWnEjHmR4mrLzE8BVaT9tRS86iD/5zogVva zONAt6XsfvCievjK/PlTPAJQosVIWRuJoRwWXLWjTjmyNLNTcXxV/wNANKm5cFUwbIS+ KtoCet3vCJHacEhF5kGPevu9pYFHQLvRjvLWdV6XBh8ZcbHIRAP/bBC2iJXzO7KofGlz p8cmfyHw0gtZ5lPqrjloQO91dTArD2Y5J5uTwR9LIThViNfbLIhhH2vNFzoOJMEJ6cRB gWqw== X-Gm-Message-State: ALoCoQnwuXgOXaVrBHzwYIaCjDtcx/NL8yJNTnLCSkLpK+a1PxXFETI+nLjPMNq9biXSRy1uGu6b 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141030_212739_989515_932F5EAF X-CRM114-Status: GOOD ( 13.12 ) X-Spam-Score: -0.7 (/) Cc: linux-pm@vger.kernel.org, Silvio F , linux-arm-kernel@lists.infradead.org, Philipp Zabel , Christian Hemp , Russell King , Iain Paton , Fabio Estevam , Shawn Guo , Lucas Stach X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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);