mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	kernel@pengutronix.de, alkml@pengutronix.de,
	Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/8] regulator: core: create unlocked version of regulator_set_voltage
Date: Tue, 13 Oct 2015 12:45:25 +0200	[thread overview]
Message-ID: <1444733131-26995-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1444733131-26995-1-git-send-email-s.hauer@pengutronix.de>

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 | 57 +++++++++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index bab426d..b814451 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2725,33 +2725,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
 	return ret;
 }
 
-/**
- * regulator_set_voltage - set regulator output voltage
- * @regulator: regulator source
- * @min_uV: Minimum required voltage in uV
- * @max_uV: Maximum acceptable voltage in uV
- *
- * Sets a voltage regulator to the desired output voltage. This can be set
- * during any regulator state. IOW, regulator can be disabled or enabled.
- *
- * If the regulator is enabled then the voltage will change to the new value
- * immediately otherwise if the regulator is disabled the regulator will
- * output at the new voltage when enabled.
- *
- * NOTE: If the regulator is shared between several devices then the lowest
- * request voltage that meets the system constraints will be used.
- * Regulator system constraints must be set for this regulator before
- * calling this function otherwise this call will fail.
- */
-int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
+static int regulator_set_voltage_unlocked(struct regulator *regulator,
+					  int min_uV, int max_uV)
 {
 	struct regulator_dev *rdev = regulator->rdev;
 	int ret = 0;
 	int old_min_uV, old_max_uV;
 	int current_uV;
 
-	mutex_lock(&rdev->mutex);
-
 	/* If we're setting the same range as last time the change
 	 * should be a noop (some cpufreq implementations use the same
 	 * voltage for multiple frequencies, for example).
@@ -2799,12 +2780,42 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 		goto out2;
 
 out:
-	mutex_unlock(&rdev->mutex);
 	return ret;
 out2:
 	regulator->min_uV = old_min_uV;
 	regulator->max_uV = old_max_uV;
-	mutex_unlock(&rdev->mutex);
+
+	return ret;
+}
+
+/**
+ * regulator_set_voltage - set regulator output voltage
+ * @regulator: regulator source
+ * @min_uV: Minimum required voltage in uV
+ * @max_uV: Maximum acceptable voltage in uV
+ *
+ * Sets a voltage regulator to the desired output voltage. This can be set
+ * during any regulator state. IOW, regulator can be disabled or enabled.
+ *
+ * If the regulator is enabled then the voltage will change to the new value
+ * immediately otherwise if the regulator is disabled the regulator will
+ * output at the new voltage when enabled.
+ *
+ * NOTE: If the regulator is shared between several devices then the lowest
+ * request voltage that meets the system constraints will be used.
+ * Regulator system constraints must be set for this regulator before
+ * calling this function otherwise this call will fail.
+ */
+int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
+{
+	int ret = 0;
+
+	mutex_lock(&regulator->rdev->mutex);
+
+	ret = regulator_set_voltage_unlocked(regulator, min_uV, max_uV);
+
+	mutex_unlock(&regulator->rdev->mutex);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(regulator_set_voltage);
-- 
2.6.1


  parent reply	other threads:[~2015-10-13 10:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13 10:45 [PATCH v2] regulator: Propagate voltage changes to supply regulators Sascha Hauer
2015-10-13 10:45 ` [PATCH 1/8] regulator: core: create unlocked version of regulator_list_voltage Sascha Hauer
2015-10-16 15:26   ` Mark Brown
2015-10-13 10:45 ` Sascha Hauer [this message]
2015-10-16 17:04   ` Applied "regulator: core: create unlocked version of regulator_set_voltage" to the regulator tree Mark Brown
2015-10-13 10:45 ` [PATCH 3/8] regulator: introduce min_dropout_uv Sascha Hauer
2015-10-16 16:11   ` Mark Brown
2015-10-16 16:41   ` Applied "regulator: introduce min_dropout_uv" to the regulator tree Mark Brown
2015-10-16 16:57     ` Mark Brown
2015-10-13 10:45 ` [PATCH 4/8] regulator: core: introduce function to lock regulators and its supplies Sascha Hauer
2015-10-13 10:45 ` [PATCH 5/8] regulator: introduce regulator_get_voltage_floor Sascha Hauer
2015-10-16 16:50   ` Mark Brown
2015-10-20 12:26     ` Sascha Hauer
2015-10-13 10:45 ` [PATCH 6/8] regulator: core: Propagate voltage changes to supply regulators Sascha Hauer
2015-10-16 16:55   ` Mark Brown
2015-10-13 10:45 ` [PATCH 7/8] regulator: i.MX anatop: Allow supply regulator Sascha Hauer
2015-10-13 10:45 ` [PATCH 8/8] ARM: i.MX6 Phytec PFLA02: Add supplies for the SoC internal regulators Sascha Hauer

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=1444733131-26995-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=alkml@pengutronix.de \
    --cc=broonie@kernel.org \
    --cc=kernel@pengutronix.de \
    --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®