linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Jon Hunter <jonathanh@nvidia.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] regulator: core: Use parent voltage from the supply when bypassed
Date: Thu,  7 Apr 2016 16:22:36 +0200	[thread overview]
Message-ID: <1460038959-21592-2-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1460038959-21592-1-git-send-email-thierry.reding@gmail.com>

From: Mark Brown <broonie@kernel.org>

When a regulator is in bypass mode it is functioning as a switch
returning the voltage set in the regulator will not give the voltage
being output by the regulator as it's just passing through its supply.
This means that when we are getting the voltage from a regulator we
should check to see if it is in bypass mode and if it is we should
report the voltage from the supply rather than that which is set on the
regulator.

Reported-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
[treding@nvidia.com: return early for bypass mode]
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/regulator/core.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cc0333a79924..23c8c4c86389 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3118,6 +3118,20 @@ EXPORT_SYMBOL_GPL(regulator_sync_voltage);
 static int _regulator_get_voltage(struct regulator_dev *rdev)
 {
 	int sel, ret;
+	bool bypassed;
+
+	if (rdev->desc->ops->get_bypass) {
+		ret = rdev->desc->ops->get_bypass(rdev, &bypassed);
+		if (ret < 0)
+			return ret;
+		if (bypassed) {
+			/* if bypassed the regulator must have a supply */
+			if (!rdev->supply)
+				return -EINVAL;
+
+			return _regulator_get_voltage(rdev->supply->rdev);
+		}
+	}
 
 	if (rdev->desc->ops->get_voltage_sel) {
 		sel = rdev->desc->ops->get_voltage_sel(rdev);
-- 
2.8.0

  reply	other threads:[~2016-04-07 14:22 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 14:22 [PATCH 1/5] regulator: core: Resolve supply earlier Thierry Reding
2016-04-07 14:22 ` Thierry Reding [this message]
2016-04-12  6:31   ` Applied "regulator: core: Use parent voltage from the supply when bypassed" to the regulator tree Mark Brown
2016-04-07 14:22 ` [PATCH 3/5] regulator: helpers: Ensure bypass register field matches ON value Thierry Reding
2016-04-22 10:49   ` Applied "regulator: helpers: Ensure bypass register field matches ON value" to the regulator tree Mark Brown
2016-04-07 14:22 ` [PATCH 4/5] regulator: as3722: Add bypass support for LDO6 Thierry Reding
2016-04-11 16:15   ` Applied "regulator: as3722: Add bypass support for LDO6" to the regulator tree Mark Brown
2016-04-07 14:22 ` [PATCH 5/5] regulator: as3722: Constify regulator ops Thierry Reding
2016-04-11 16:15   ` Applied "regulator: as3722: Constify regulator ops" to the regulator tree Mark Brown
2016-04-11 10:59 ` [PATCH 1/5] regulator: core: Resolve supply earlier Jon Hunter
2016-04-11 11:46   ` Thierry Reding
2016-04-11 12:19     ` Jon Hunter
2016-04-11 12:49       ` Mark Brown
2016-04-11 14:03       ` Javier Martinez Canillas
2016-04-11 12:58     ` Mark Brown
2016-04-11 13:09       ` Thierry Reding
2016-04-11 13:45         ` Javier Martinez Canillas
2016-04-11 13:57           ` Mark Brown
2016-04-11 14:07             ` Thierry Reding
2016-04-11 14:32               ` Mark Brown
2016-04-11 14:49                 ` Thierry Reding
2016-04-11 15:50                   ` Mark Brown
2016-04-11 13:56         ` Mark Brown
2016-04-11 14:03 ` Mark Brown
2016-04-11 14:11   ` Thierry Reding
2016-04-11 14:16     ` Mark Brown
2016-04-19 10:16       ` Jon Hunter
2016-04-19 11:03         ` Thierry Reding
2016-04-19 15:40         ` Mark Brown
2016-04-19 16:09           ` Jon Hunter
2016-04-20 15:21             ` Mark Brown
2016-04-21 15:34               ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460038959-21592-2-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).