diff options
-rw-r--r-- | drivers/regulator/core.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 236ca3f1df73..d70f00f8fc66 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -844,13 +844,22 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, | |||
844 | /* do we need to apply the constraint voltage */ | 844 | /* do we need to apply the constraint voltage */ |
845 | if (rdev->constraints->apply_uV && | 845 | if (rdev->constraints->apply_uV && |
846 | rdev->constraints->min_uV == rdev->constraints->max_uV) { | 846 | rdev->constraints->min_uV == rdev->constraints->max_uV) { |
847 | ret = _regulator_do_set_voltage(rdev, | 847 | int current_uV = _regulator_get_voltage(rdev); |
848 | rdev->constraints->min_uV, | 848 | if (current_uV < 0) { |
849 | rdev->constraints->max_uV); | 849 | rdev_err(rdev, "failed to get the current voltage\n"); |
850 | if (ret < 0) { | 850 | return current_uV; |
851 | rdev_err(rdev, "failed to apply %duV constraint\n", | 851 | } |
852 | rdev->constraints->min_uV); | 852 | if (current_uV < rdev->constraints->min_uV || |
853 | return ret; | 853 | current_uV > rdev->constraints->max_uV) { |
854 | ret = _regulator_do_set_voltage( | ||
855 | rdev, rdev->constraints->min_uV, | ||
856 | rdev->constraints->max_uV); | ||
857 | if (ret < 0) { | ||
858 | rdev_err(rdev, | ||
859 | "failed to apply %duV constraint\n", | ||
860 | rdev->constraints->min_uV); | ||
861 | return ret; | ||
862 | } | ||
854 | } | 863 | } |
855 | } | 864 | } |
856 | 865 | ||