aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-13 06:45:25 -0400
committerMark Brown <broonie@kernel.org>2015-10-16 12:55:55 -0400
commita9f226bcd9bb1941e581806e83d2c03d4043c367 (patch)
treeda601a23920d78bb688d04faa30b63f3a9ae6d0b
parent3a40cfc36bb3d2e25c9af31e56863ea7144c5324 (diff)
regulator: core: create unlocked version of regulator_set_voltage
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> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f28c133693ad..5d161e11d5e6 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2761,33 +2761,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2761 return ret; 2761 return ret;
2762} 2762}
2763 2763
2764/** 2764static int regulator_set_voltage_unlocked(struct regulator *regulator,
2765 * regulator_set_voltage - set regulator output voltage 2765 int min_uV, int max_uV)
2766 * @regulator: regulator source
2767 * @min_uV: Minimum required voltage in uV
2768 * @max_uV: Maximum acceptable voltage in uV
2769 *
2770 * Sets a voltage regulator to the desired output voltage. This can be set
2771 * during any regulator state. IOW, regulator can be disabled or enabled.
2772 *
2773 * If the regulator is enabled then the voltage will change to the new value
2774 * immediately otherwise if the regulator is disabled the regulator will
2775 * output at the new voltage when enabled.
2776 *
2777 * NOTE: If the regulator is shared between several devices then the lowest
2778 * request voltage that meets the system constraints will be used.
2779 * Regulator system constraints must be set for this regulator before
2780 * calling this function otherwise this call will fail.
2781 */
2782int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
2783{ 2766{
2784 struct regulator_dev *rdev = regulator->rdev; 2767 struct regulator_dev *rdev = regulator->rdev;
2785 int ret = 0; 2768 int ret = 0;
2786 int old_min_uV, old_max_uV; 2769 int old_min_uV, old_max_uV;
2787 int current_uV; 2770 int current_uV;
2788 2771
2789 mutex_lock(&rdev->mutex);
2790
2791 /* If we're setting the same range as last time the change 2772 /* If we're setting the same range as last time the change
2792 * should be a noop (some cpufreq implementations use the same 2773 * should be a noop (some cpufreq implementations use the same
2793 * voltage for multiple frequencies, for example). 2774 * voltage for multiple frequencies, for example).
@@ -2835,12 +2816,42 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
2835 goto out2; 2816 goto out2;
2836 2817
2837out: 2818out:
2838 mutex_unlock(&rdev->mutex);
2839 return ret; 2819 return ret;
2840out2: 2820out2:
2841 regulator->min_uV = old_min_uV; 2821 regulator->min_uV = old_min_uV;
2842 regulator->max_uV = old_max_uV; 2822 regulator->max_uV = old_max_uV;
2843 mutex_unlock(&rdev->mutex); 2823
2824 return ret;
2825}
2826
2827/**
2828 * regulator_set_voltage - set regulator output voltage
2829 * @regulator: regulator source
2830 * @min_uV: Minimum required voltage in uV
2831 * @max_uV: Maximum acceptable voltage in uV
2832 *
2833 * Sets a voltage regulator to the desired output voltage. This can be set
2834 * during any regulator state. IOW, regulator can be disabled or enabled.
2835 *
2836 * If the regulator is enabled then the voltage will change to the new value
2837 * immediately otherwise if the regulator is disabled the regulator will
2838 * output at the new voltage when enabled.
2839 *
2840 * NOTE: If the regulator is shared between several devices then the lowest
2841 * request voltage that meets the system constraints will be used.
2842 * Regulator system constraints must be set for this regulator before
2843 * calling this function otherwise this call will fail.
2844 */
2845int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
2846{
2847 int ret = 0;
2848
2849 mutex_lock(&regulator->rdev->mutex);
2850
2851 ret = regulator_set_voltage_unlocked(regulator, min_uV, max_uV);
2852
2853 mutex_unlock(&regulator->rdev->mutex);
2854
2844 return ret; 2855 return ret;
2845} 2856}
2846EXPORT_SYMBOL_GPL(regulator_set_voltage); 2857EXPORT_SYMBOL_GPL(regulator_set_voltage);