Merge remote-tracking branch 'regulator/topic/core' into regulator-next
authorMark Brown <broonie@linaro.org>
Wed, 26 Mar 2014 16:57:44 +0000 (16:57 +0000)
committerMark Brown <broonie@linaro.org>
Wed, 26 Mar 2014 16:57:44 +0000 (16:57 +0000)
drivers/regulator/core.c
drivers/regulator/dummy.c
drivers/regulator/pfuze100-regulator.c
drivers/regulator/s2mps11.c

index afca1bc24f262251abf3352d2e09d6452959805b..bac485acc7f37dd83d472b4601daa7ef814cb30d 100644 (file)
@@ -2399,6 +2399,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        struct regulator_dev *rdev = regulator->rdev;
        int ret = 0;
        int old_min_uV, old_max_uV;
+       int current_uV;
 
        mutex_lock(&rdev->mutex);
 
@@ -2409,6 +2410,19 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        if (regulator->min_uV == min_uV && regulator->max_uV == max_uV)
                goto out;
 
+       /* If we're trying to set a range that overlaps the current voltage,
+        * return succesfully even though the regulator does not support
+        * changing the voltage.
+        */
+       if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
+               current_uV = _regulator_get_voltage(rdev);
+               if (min_uV <= current_uV && current_uV <= max_uV) {
+                       regulator->min_uV = min_uV;
+                       regulator->max_uV = max_uV;
+                       goto out;
+               }
+       }
+
        /* sanity check */
        if (!rdev->desc->ops->set_voltage &&
            !rdev->desc->ops->set_voltage_sel) {
index df9f42524abb3fd1164f61e7bee4065985d59d24..2436db9e2ca35f60875ab56cc825050c0d6a3ff2 100644 (file)
 
 struct regulator_dev *dummy_regulator_rdev;
 
-static struct regulator_init_data dummy_initdata;
+static struct regulator_init_data dummy_initdata = {
+       .constraints = {
+               .always_on = 1,
+       },
+};
 
 static struct regulator_ops dummy_ops;
 
index ab174f20ca11f473c889848b1d7e6b7545a9e3ef..b699d4e7acc5b125e0b42eee2858c7ff1b225271 100644 (file)
@@ -92,7 +92,7 @@ MODULE_DEVICE_TABLE(of, pfuze_dt_ids);
 static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
 {
        struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
-       int id = rdev->desc->id;
+       int id = rdev_get_id(rdev);
        unsigned int ramp_bits;
        int ret;
 
index cd0b9e35a56d90ccc4fd78fe5fe781f2f009cd77..89966213315cd1e13708e7c0502bdd31d2044ceb 100644 (file)
@@ -65,7 +65,7 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
        unsigned int ramp_delay = 0;
        int old_volt, new_volt;
 
-       switch (rdev->desc->id) {
+       switch (rdev_get_id(rdev)) {
        case S2MPS11_BUCK2:
                ramp_delay = s2mps11->ramp_delay2;
                break;
@@ -105,7 +105,7 @@ static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
        unsigned int ramp_enable = 1, enable_shift = 0;
        int ret;
 
-       switch (rdev->desc->id) {
+       switch (rdev_get_id(rdev)) {
        case S2MPS11_BUCK1:
                if (ramp_delay > s2mps11->ramp_delay16)
                        s2mps11->ramp_delay16 = ramp_delay;