regulator: core: Do not set voltage if already set
Philip Rakity [Tue, 13 Aug 2013 11:07:49 +0000 (12:07 +0100)]
if we choose the same value for the voltage selector
as we had previously do not set the voltage.

bug 1330022

Change-Id: Ifa0b5b29fb12597f7cabb408c139fd69f2b2892b
Signed-off-by: Philip Rakity <prakity@nvidia.com>
Reviewed-on: http://git-master/r/261029
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/regulator/core.c

index 57a806a..ca0c802 100644 (file)
@@ -2044,6 +2044,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
                        if (ret < 0)
                                return ret;
                        old_selector = ret;
+                       /* exit if no change */
+                       if (old_selector == selector) {
+                               ret = 0;
+                               goto out;
+                       }
                        ret = rdev->desc->ops->set_voltage_time_sel(rdev,
                                                old_selector, selector);
                        if (ret < 0)
@@ -2085,6 +2090,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
                                     (void *)min_uV);
        }
 
+out:
        trace_regulator_set_voltage_complete(rdev_get_name(rdev), selector);
 
        return ret;