regulator: Use regulator_lock_supply() for get_voltage() too
authorMark Brown <broonie@kernel.org>
Tue, 3 Nov 2015 05:58:14 +0000 (05:58 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 4 Nov 2015 10:16:05 +0000 (10:16 +0000)
Since we need to read voltages of parents as part of setting supply
voltages we need to be able to do get_voltage() internally without
taking locks so reorganize the locking to take locks on the full tree on
entry rather than as we recurse when called externally.

Reported-by: John Stultz <john.stultz@linaro.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index 771c6235ccedda1ced886df1a5a6cc3feb307681..b4970eb85357983021c04fa770b4ab1077627e7d 100644 (file)
@@ -3055,7 +3055,7 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
        } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) {
                ret = rdev->desc->fixed_uV;
        } else if (rdev->supply) {
-               ret = regulator_get_voltage(rdev->supply);
+               ret = _regulator_get_voltage(rdev->supply->rdev);
        } else {
                return -EINVAL;
        }
@@ -3078,11 +3078,11 @@ int regulator_get_voltage(struct regulator *regulator)
 {
        int ret;
 
-       mutex_lock(&regulator->rdev->mutex);
+       regulator_lock_supply(regulator->rdev);
 
        ret = _regulator_get_voltage(regulator->rdev);
 
-       mutex_unlock(&regulator->rdev->mutex);
+       regulator_unlock_supply(regulator->rdev);
 
        return ret;
 }