Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / drivers / regulator / pwm-regulator.c
index 90f8b7fd04374ee7796baef7e7a654b776d44e5d..666bc3bb52ef83790df5df9afab68306a39d766a 100644 (file)
@@ -145,6 +145,7 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
        unsigned int duty_pulse;
        u64 req_period;
        u32 rem;
+       int old_uV = pwm_regulator_get_voltage(rdev);
        int ret;
 
        pwm_get_args(drvdata->pwm, &pargs);
@@ -174,8 +175,12 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
 
        drvdata->volt_uV = min_uV;
 
-       /* Delay required by PWM regulator to settle to the new voltage */
-       usleep_range(ramp_delay, ramp_delay + 1000);
+       if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev))
+               return 0;
+
+       /* Ramp delay is in uV/uS. Adjust to uS and delay */
+       ramp_delay = DIV_ROUND_UP(abs(min_uV - old_uV), ramp_delay);
+       usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10));
 
        return 0;
 }
This page took 0.025436 seconds and 5 git commands to generate.