UPSTREAM: regulator: core: Rely on regulator_dev_release to free constraints
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Tue, 26 Jan 2016 16:38:59 +0000 (16:38 +0000)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 6 Mar 2017 10:28:40 +0000 (18:28 +0800)
As we now free the constraints in regulator_dev_release we will still
call free on the constraints pointer even if we went down an error
path in regulator_register, because it is only allocated after the
device_register. As such we no longer need to free rdev->constraints
on the error paths, so this patch removes said frees.

Fixes: 29f5f4860a8e ("regulator: core: Move more deallocation into class unregister")
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 6333ef46bbe514a8ece6c432aab6bcf8637b2d7c)

Change-Id: I731b81e175ef9fb519e2090590f5e7c081f748a2
Signed-off-by: David Wu <david.wu@rock-chips.com>
drivers/regulator/core.c

index c07f434154246e5dc6ca32e79715c9fb52b3c220..1036ea0a431aa5ca28e8588deff7c46185e4ca3e 100644 (file)
@@ -1055,18 +1055,18 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 
        ret = machine_constraints_voltage(rdev, rdev->constraints);
        if (ret != 0)
-               goto out;
+               return ret;
 
        ret = machine_constraints_current(rdev, rdev->constraints);
        if (ret != 0)
-               goto out;
+               return ret;
 
        if (rdev->constraints->ilim_uA && ops->set_input_current_limit) {
                ret = ops->set_input_current_limit(rdev,
                                                   rdev->constraints->ilim_uA);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set input limit\n");
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1075,21 +1075,20 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = suspend_prepare(rdev, rdev->constraints->initial_state);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set suspend state\n");
-                       goto out;
+                       return ret;
                }
        }
 
        if (rdev->constraints->initial_mode) {
                if (!ops->set_mode) {
                        rdev_err(rdev, "no set_mode operation\n");
-                       ret = -EINVAL;
-                       goto out;
+                       return -EINVAL;
                }
 
                ret = ops->set_mode(rdev, rdev->constraints->initial_mode);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set initial mode: %d\n", ret);
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1100,7 +1099,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = _regulator_do_enable(rdev);
                if (ret < 0 && ret != -EINVAL) {
                        rdev_err(rdev, "failed to enable\n");
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1109,7 +1108,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set ramp_delay\n");
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1117,7 +1116,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = ops->set_pull_down(rdev);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set pull down\n");
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1125,7 +1124,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = ops->set_soft_start(rdev);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set soft start\n");
-                       goto out;
+                       return ret;
                }
        }
 
@@ -1134,16 +1133,12 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                ret = ops->set_over_current_protection(rdev);
                if (ret < 0) {
                        rdev_err(rdev, "failed to set over current protection\n");
-                       goto out;
+                       return ret;
                }
        }
 
        print_constraints(rdev);
        return 0;
-out:
-       kfree(rdev->constraints);
-       rdev->constraints = NULL;
-       return ret;
 }
 
 /**
@@ -3977,7 +3972,7 @@ unset_supplies:
 
 scrub:
        regulator_ena_gpio_free(rdev);
-       kfree(rdev->constraints);
+
 wash:
        device_unregister(&rdev->dev);
        /* device core frees rdev */