Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1245575 > unrolled thread

[PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage

Started bySascha Hauer <s.hauer@pengutronix.de>
First post2015-10-13 12:50 +0200
Last post2015-10-16 17:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage Sascha Hauer <s.hauer@pengutronix.de> - 2015-10-13 12:50 +0200
    Re: [PATCH 1/8] regulator: core: create unlocked version of  regulator_list_voltage Mark Brown <broonie@kernel.org> - 2015-10-16 17:30 +0200

#1245575 — [PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage

FromSascha Hauer <s.hauer@pengutronix.de>
Date2015-10-13 12:50 +0200
Subject[PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage
Message-ID<qj5jA-45m-23@gated-at.bofh.it>
The unlocked version will be needed when we start propagating voltage
changes to the supply regulators.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/regulator/core.c | 62 +++++++++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8a34f6a..bab426d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2312,6 +2312,40 @@ static int _regulator_is_enabled(struct regulator_dev *rdev)
 	return rdev->desc->ops->is_enabled(rdev);
 }
 
+static int _regulator_list_voltage(struct regulator *regulator,
+				    unsigned selector, int lock)
+{
+	struct regulator_dev *rdev = regulator->rdev;
+	const struct regulator_ops *ops = rdev->desc->ops;
+	int ret;
+
+	if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
+		return rdev->desc->fixed_uV;
+
+	if (ops->list_voltage) {
+		if (selector >= rdev->desc->n_voltages)
+			return -EINVAL;
+		if (lock)
+			mutex_lock(&rdev->mutex);
+		ret = ops->list_voltage(rdev, selector);
+		if (lock)
+			mutex_unlock(&rdev->mutex);
+	} else if (rdev->supply) {
+		ret = _regulator_list_voltage(rdev->supply, selector, lock);
+	} else {
+		return -EINVAL;
+	}
+
+	if (ret > 0) {
+		if (ret < rdev->constraints->min_uV)
+			ret = 0;
+		else if (ret > rdev->constraints->max_uV)
+			ret = 0;
+	}
+
+	return ret;
+}
+
 /**
  * regulator_is_enabled - is the regulator output enabled
  * @regulator: regulator source
@@ -2401,33 +2435,7 @@ EXPORT_SYMBOL_GPL(regulator_count_voltages);
  */
 int regulator_list_voltage(struct regulator *regulator, unsigned selector)
 {
-	struct regulator_dev *rdev = regulator->rdev;
-	const struct regulator_ops *ops = rdev->desc->ops;
-	int ret;
-
-	if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
-		return rdev->desc->fixed_uV;
-
-	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;
-	}
-
-	if (ret > 0) {
-		if (ret < rdev->constraints->min_uV)
-			ret = 0;
-		else if (ret > rdev->constraints->max_uV)
-			ret = 0;
-	}
-
-	return ret;
+	return _regulator_list_voltage(regulator, selector, 1);
 }
 EXPORT_SYMBOL_GPL(regulator_list_voltage);
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1248880 — Re: [PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage

FromMark Brown <broonie@kernel.org>
Date2015-10-16 17:30 +0200
SubjectRe: [PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage
Message-ID<qkf7e-1SN-61@gated-at.bofh.it>
In reply to#1245575

[Multipart message — attachments visible in raw view] — view raw

On Tue, Oct 13, 2015 at 12:45:24PM +0200, Sascha Hauer wrote:
> The unlocked version will be needed when we start propagating voltage
> changes to the supply regulators.

Please don't resend already applied patches, if there are any changes
that need making send incremental changes on top of what's already
applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web