diff options
author | Bjorn Andersson <bjorn@kryo.se> | 2014-02-05 15:30:26 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-07 07:14:19 -0500 |
commit | c00dc359e5e0b10de993651d8e73e60c41bf29cd (patch) | |
tree | e749b8fefe82b51a8f7f9850d5a8d1ae395e0635 | |
parent | d55efa4d9bff20c98ca05e0bf458691e6869b5a1 (diff) |
regulator: core: Allow regulator_set_voltage for fixed regulators
Make it okay to call regulator_set_voltage on regulators with fixed
voltage if the requested range overlaps the current/configured voltage.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/core.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b38a6b669e8c..0cd1a3b8e589 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2395,6 +2395,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
2395 | struct regulator_dev *rdev = regulator->rdev; | 2395 | struct regulator_dev *rdev = regulator->rdev; |
2396 | int ret = 0; | 2396 | int ret = 0; |
2397 | int old_min_uV, old_max_uV; | 2397 | int old_min_uV, old_max_uV; |
2398 | int current_uV; | ||
2398 | 2399 | ||
2399 | mutex_lock(&rdev->mutex); | 2400 | mutex_lock(&rdev->mutex); |
2400 | 2401 | ||
@@ -2405,6 +2406,19 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
2405 | if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) | 2406 | if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) |
2406 | goto out; | 2407 | goto out; |
2407 | 2408 | ||
2409 | /* If we're trying to set a range that overlaps the current voltage, | ||
2410 | * return succesfully even though the regulator does not support | ||
2411 | * changing the voltage. | ||
2412 | */ | ||
2413 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { | ||
2414 | current_uV = _regulator_get_voltage(rdev); | ||
2415 | if (min_uV <= current_uV && current_uV <= max_uV) { | ||
2416 | regulator->min_uV = min_uV; | ||
2417 | regulator->max_uV = max_uV; | ||
2418 | goto out; | ||
2419 | } | ||
2420 | } | ||
2421 | |||
2408 | /* sanity check */ | 2422 | /* sanity check */ |
2409 | if (!rdev->desc->ops->set_voltage && | 2423 | if (!rdev->desc->ops->set_voltage && |
2410 | !rdev->desc->ops->set_voltage_sel) { | 2424 | !rdev->desc->ops->set_voltage_sel) { |