diff options
Diffstat (limited to 'drivers/regulator/core.c')
| -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 afca1bc24f26..bac485acc7f3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -2399,6 +2399,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
| 2399 | struct regulator_dev *rdev = regulator->rdev; | 2399 | struct regulator_dev *rdev = regulator->rdev; |
| 2400 | int ret = 0; | 2400 | int ret = 0; |
| 2401 | int old_min_uV, old_max_uV; | 2401 | int old_min_uV, old_max_uV; |
| 2402 | int current_uV; | ||
| 2402 | 2403 | ||
| 2403 | mutex_lock(&rdev->mutex); | 2404 | mutex_lock(&rdev->mutex); |
| 2404 | 2405 | ||
| @@ -2409,6 +2410,19 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
| 2409 | if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) | 2410 | if (regulator->min_uV == min_uV && regulator->max_uV == max_uV) |
| 2410 | goto out; | 2411 | goto out; |
| 2411 | 2412 | ||
| 2413 | /* If we're trying to set a range that overlaps the current voltage, | ||
| 2414 | * return succesfully even though the regulator does not support | ||
| 2415 | * changing the voltage. | ||
| 2416 | */ | ||
| 2417 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { | ||
| 2418 | current_uV = _regulator_get_voltage(rdev); | ||
| 2419 | if (min_uV <= current_uV && current_uV <= max_uV) { | ||
| 2420 | regulator->min_uV = min_uV; | ||
| 2421 | regulator->max_uV = max_uV; | ||
| 2422 | goto out; | ||
| 2423 | } | ||
| 2424 | } | ||
| 2425 | |||
| 2412 | /* sanity check */ | 2426 | /* sanity check */ |
| 2413 | if (!rdev->desc->ops->set_voltage && | 2427 | if (!rdev->desc->ops->set_voltage && |
| 2414 | !rdev->desc->ops->set_voltage_sel) { | 2428 | !rdev->desc->ops->set_voltage_sel) { |
