aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c1a49917af24..1848a3f0980e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -676,6 +676,22 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
676 const char *name, struct regulation_constraints *constraints) 676 const char *name, struct regulation_constraints *constraints)
677{ 677{
678 struct regulator_ops *ops = rdev->desc->ops; 678 struct regulator_ops *ops = rdev->desc->ops;
679 int ret;
680
681 /* do we need to apply the constraint voltage */
682 if (rdev->constraints->apply_uV &&
683 rdev->constraints->min_uV == rdev->constraints->max_uV &&
684 ops->set_voltage) {
685 ret = ops->set_voltage(rdev,
686 rdev->constraints->min_uV, rdev->constraints->max_uV);
687 if (ret < 0) {
688 printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
689 __func__,
690 rdev->constraints->min_uV, name);
691 rdev->constraints = NULL;
692 return ret;
693 }
694 }
679 695
680 /* constrain machine-level voltage specs to fit 696 /* constrain machine-level voltage specs to fit
681 * the actual range supported by this regulator. 697 * the actual range supported by this regulator.
@@ -773,27 +789,12 @@ static int set_machine_constraints(struct regulator_dev *rdev,
773 else 789 else
774 name = "regulator"; 790 name = "regulator";
775 791
792 rdev->constraints = constraints;
793
776 ret = machine_constraints_voltage(rdev, name, constraints); 794 ret = machine_constraints_voltage(rdev, name, constraints);
777 if (ret != 0) 795 if (ret != 0)
778 goto out; 796 goto out;
779 797
780 rdev->constraints = constraints;
781
782 /* do we need to apply the constraint voltage */
783 if (rdev->constraints->apply_uV &&
784 rdev->constraints->min_uV == rdev->constraints->max_uV &&
785 ops->set_voltage) {
786 ret = ops->set_voltage(rdev,
787 rdev->constraints->min_uV, rdev->constraints->max_uV);
788 if (ret < 0) {
789 printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
790 __func__,
791 rdev->constraints->min_uV, name);
792 rdev->constraints = NULL;
793 goto out;
794 }
795 }
796
797 /* do we need to setup our suspend state */ 798 /* do we need to setup our suspend state */
798 if (constraints->initial_state) { 799 if (constraints->initial_state) {
799 ret = suspend_prepare(rdev, constraints->initial_state); 800 ret = suspend_prepare(rdev, constraints->initial_state);