mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>
Cc: linux-kernel@vger.kernel.org,
	Douglas Anderson <dianders@chromium.org>,
	Brian Norris <briannorris@chromium.org>,
	Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH] regulator: core: Limit propagation of parent voltage count and list
Date: Fri, 24 Mar 2017 13:09:52 -0700	[thread overview]
Message-ID: <20170324200952.103303-1-mka@chromium.org> (raw)

Commit 26988efe11b1 ("regulator: core: Allow to get voltage count and
list from parent") introduces the propagation of the parent voltage
count and list for regulators that don't provide this information
themselves. The goal is to support simple switch regulators, however as
a side effect normal continuous regulators can leak details of their
supplies and provide consumers with inconsistent information.

Limit the propagation of the voltage count and list to regulators which
don't have get_voltage(_sel) and list_voltage ops.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 drivers/regulator/core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 53d4fc70dbd0..121838e0125b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2487,6 +2487,10 @@ static int _regulator_list_voltage(struct regulator *regulator,
 		if (lock)
 			mutex_unlock(&rdev->mutex);
 	} else if (rdev->supply) {
+		// Limit propagation of parent values to switch regulators
+		if (ops->get_voltage || ops->get_voltage_sel)
+			return -EINVAL;
+
 		ret = _regulator_list_voltage(rdev->supply, selector, lock);
 	} else {
 		return -EINVAL;
@@ -2540,6 +2544,7 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled);
 int regulator_count_voltages(struct regulator *regulator)
 {
 	struct regulator_dev	*rdev = regulator->rdev;
+	const struct regulator_ops *ops = rdev->desc->ops;
 
 	if (rdev->desc->n_voltages)
 		return rdev->desc->n_voltages;
@@ -2547,6 +2552,10 @@ int regulator_count_voltages(struct regulator *regulator)
 	if (!rdev->supply)
 		return -EINVAL;
 
+	// Limit propagation of parent value to switch regulators
+	if (ops->get_voltage || ops->get_voltage_sel || ops->list_voltage)
+		return -EINVAL;
+
 	return regulator_count_voltages(rdev->supply);
 }
 EXPORT_SYMBOL_GPL(regulator_count_voltages);
-- 
2.12.1.578.ge9c3154ca4-goog

             reply	other threads:[~2017-03-24 20:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 20:09 Matthias Kaehlcke [this message]
2017-03-24 20:38 ` Brian Norris
2017-03-25  5:05   ` Javier Martinez Canillas
2017-03-27 10:21     ` Mark Brown
2017-03-27 17:39     ` Matthias Kaehlcke
2017-03-27 17:54       ` Javier Martinez Canillas
2017-03-27 18:13         ` Mark Brown
2017-03-27 18:20         ` Matthias Kaehlcke

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=20170324200952.103303-1-mka@chromium.org \
    --to=mka@chromium.org \
    --cc=briannorris@chromium.org \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=javier@osg.samsung.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

all inboxes | Powered by JetHome®