From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Mark Brown <broonie@kernel.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>,
Doug Anderson <dianders@chromium.org>,
Olof Johansson <olof@lixom.net>,
Yuvaraj Kumar C D <yuvaraj.cd@gmail.com>,
linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [RFC 2/5] regulator: core: Allow to get voltage count and list from parent
Date: Tue, 29 Jul 2014 18:28:56 +0200 [thread overview]
Message-ID: <1406651339-28901-3-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1406651339-28901-1-git-send-email-javier.martinez@collabora.co.uk>
Load switches are modeled as regulators but they just provide
the voltage of their parent input supply. So, the drivers for
these switches usually neither provide a .list_voltage handler
not set a .n_voltages count. But there is code in the kernel
that assumes that all regulators should be able to provide this
information (e.g: cpufreq and mmc subsystems).
If the voltage count and list are not available for a regulator
and it has a parent input supply, then use the parent values.
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
drivers/regulator/core.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 089cea8..a3c3785 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2186,7 +2186,13 @@ int regulator_count_voltages(struct regulator *regulator)
{
struct regulator_dev *rdev = regulator->rdev;
- return rdev->desc->n_voltages ? : -EINVAL;
+ if (rdev->desc->n_voltages)
+ return rdev->desc->n_voltages;
+
+ if (!rdev->supply)
+ return -EINVAL;
+
+ return regulator_count_voltages(rdev->supply);
}
EXPORT_SYMBOL_GPL(regulator_count_voltages);
@@ -2209,12 +2215,17 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
return rdev->desc->fixed_uV;
- if (!ops->list_voltage || selector >= rdev->desc->n_voltages)
+ if (ops->list_voltage) {
+ if (selector >= rdev->desc->n_voltages)
+ return -EINVAL;
+ mutex_lock(&rdev->mutex);
+ ret = ops->list_voltage(rdev, selector);
+ mutex_unlock(&rdev->mutex);
+ } else if (rdev->supply) {
+ ret = regulator_list_voltage(rdev->supply, selector);
+ } else {
return -EINVAL;
-
- mutex_lock(&rdev->mutex);
- ret = ops->list_voltage(rdev, selector);
- mutex_unlock(&rdev->mutex);
+ }
if (ret > 0) {
if (ret < rdev->constraints->min_uV)
--
2.0.0.rc2
next prev parent reply other threads:[~2014-07-29 16:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 16:28 [RFC 0/5] Get voltage from parent if not available on child Javier Martinez Canillas
2014-07-29 16:28 ` [RFC 1/5] regulator: core: Get voltage from parent if not available Javier Martinez Canillas
2014-07-29 18:26 ` Mark Brown
2014-07-30 9:01 ` Javier Martinez Canillas
2014-07-29 16:28 ` Javier Martinez Canillas [this message]
2014-07-29 18:25 ` [RFC 2/5] regulator: core: Allow to get voltage count and list from parent Mark Brown
2014-07-29 16:28 ` [RFC 3/5] regulator: core: Only apply constraints if available on list voltage Javier Martinez Canillas
2014-07-29 17:18 ` Mark Brown
2014-07-30 8:49 ` Javier Martinez Canillas
2014-07-30 10:42 ` Mark Brown
2014-07-29 16:28 ` [RFC 4/5] regulator: tps65090: Set voltage for fixed regulators Javier Martinez Canillas
2014-07-29 17:36 ` Mark Brown
2014-07-30 8:55 ` Javier Martinez Canillas
2014-07-29 16:28 ` [RFC 5/5] ARM: dts: Improve Peach Pit and Pi power scheme model Javier Martinez Canillas
2014-07-29 17:20 ` Mark Brown
2014-07-30 8:53 ` Javier Martinez Canillas
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=1406651339-28901-3-git-send-email-javier.martinez@collabora.co.uk \
--to=javier.martinez@collabora.co.uk \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=olof@lixom.net \
--cc=yuvaraj.cd@gmail.com \
/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
all inboxes | Powered by JetHome®