aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-08-05 13:29:17 -0400
committerMark Brown <broonie@linaro.org>2014-08-05 13:29:17 -0400
commitb7b045a55065647768ca11203d42029114c0dc80 (patch)
tree8e13b14138d5f3fbbbc1e2bef32339ce15272250
parent9950756d77221da69ed8761624cc03f3b526d932 (diff)
parent26988efe11b1dc44853035122927ced25578f302 (diff)
Merge remote-tracking branch 'regulator/topic/core' into regulator-next
-rw-r--r--drivers/regulator/core.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 4c1f999041dd..5299456d07ee 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -846,7 +846,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
846 rdev->constraints->min_uV == rdev->constraints->max_uV) { 846 rdev->constraints->min_uV == rdev->constraints->max_uV) {
847 int current_uV = _regulator_get_voltage(rdev); 847 int current_uV = _regulator_get_voltage(rdev);
848 if (current_uV < 0) { 848 if (current_uV < 0) {
849 rdev_err(rdev, "failed to get the current voltage\n"); 849 rdev_err(rdev,
850 "failed to get the current voltage(%d)\n",
851 current_uV);
850 return current_uV; 852 return current_uV;
851 } 853 }
852 if (current_uV < rdev->constraints->min_uV || 854 if (current_uV < rdev->constraints->min_uV ||
@@ -856,8 +858,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
856 rdev->constraints->max_uV); 858 rdev->constraints->max_uV);
857 if (ret < 0) { 859 if (ret < 0) {
858 rdev_err(rdev, 860 rdev_err(rdev,
859 "failed to apply %duV constraint\n", 861 "failed to apply %duV constraint(%d)\n",
860 rdev->constraints->min_uV); 862 rdev->constraints->min_uV, ret);
861 return ret; 863 return ret;
862 } 864 }
863 } 865 }
@@ -2180,7 +2182,13 @@ int regulator_count_voltages(struct regulator *regulator)
2180{ 2182{
2181 struct regulator_dev *rdev = regulator->rdev; 2183 struct regulator_dev *rdev = regulator->rdev;
2182 2184
2183 return rdev->desc->n_voltages ? : -EINVAL; 2185 if (rdev->desc->n_voltages)
2186 return rdev->desc->n_voltages;
2187
2188 if (!rdev->supply)
2189 return -EINVAL;
2190
2191 return regulator_count_voltages(rdev->supply);
2184} 2192}
2185EXPORT_SYMBOL_GPL(regulator_count_voltages); 2193EXPORT_SYMBOL_GPL(regulator_count_voltages);
2186 2194
@@ -2203,12 +2211,17 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
2203 if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) 2211 if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
2204 return rdev->desc->fixed_uV; 2212 return rdev->desc->fixed_uV;
2205 2213
2206 if (!ops->list_voltage || selector >= rdev->desc->n_voltages) 2214 if (ops->list_voltage) {
2215 if (selector >= rdev->desc->n_voltages)
2216 return -EINVAL;
2217 mutex_lock(&rdev->mutex);
2218 ret = ops->list_voltage(rdev, selector);
2219 mutex_unlock(&rdev->mutex);
2220 } else if (rdev->supply) {
2221 ret = regulator_list_voltage(rdev->supply, selector);
2222 } else {
2207 return -EINVAL; 2223 return -EINVAL;
2208 2224 }
2209 mutex_lock(&rdev->mutex);
2210 ret = ops->list_voltage(rdev, selector);
2211 mutex_unlock(&rdev->mutex);
2212 2225
2213 if (ret > 0) { 2226 if (ret > 0) {
2214 if (ret < rdev->constraints->min_uV) 2227 if (ret < rdev->constraints->min_uV)
@@ -2618,6 +2631,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
2618 ret = rdev->desc->ops->list_voltage(rdev, 0); 2631 ret = rdev->desc->ops->list_voltage(rdev, 0);
2619 } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { 2632 } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) {
2620 ret = rdev->desc->fixed_uV; 2633 ret = rdev->desc->fixed_uV;
2634 } else if (rdev->supply) {
2635 ret = regulator_get_voltage(rdev->supply);
2621 } else { 2636 } else {
2622 return -EINVAL; 2637 return -EINVAL;
2623 } 2638 }