Merge remote-tracking branch 'regulator/topic/core' into regulator-next

This commit is contained in:
Mark Brown 2014-08-05 18:29:17 +01:00
commit b7b045a550
1 changed files with 24 additions and 9 deletions

View File

@ -846,7 +846,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
rdev->constraints->min_uV == rdev->constraints->max_uV) { rdev->constraints->min_uV == rdev->constraints->max_uV) {
int current_uV = _regulator_get_voltage(rdev); int current_uV = _regulator_get_voltage(rdev);
if (current_uV < 0) { if (current_uV < 0) {
rdev_err(rdev, "failed to get the current voltage\n"); rdev_err(rdev,
"failed to get the current voltage(%d)\n",
current_uV);
return current_uV; return current_uV;
} }
if (current_uV < rdev->constraints->min_uV || if (current_uV < rdev->constraints->min_uV ||
@ -856,8 +858,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
rdev->constraints->max_uV); rdev->constraints->max_uV);
if (ret < 0) { if (ret < 0) {
rdev_err(rdev, rdev_err(rdev,
"failed to apply %duV constraint\n", "failed to apply %duV constraint(%d)\n",
rdev->constraints->min_uV); rdev->constraints->min_uV, ret);
return ret; return ret;
} }
} }
@ -2180,7 +2182,13 @@ int regulator_count_voltages(struct regulator *regulator)
{ {
struct regulator_dev *rdev = regulator->rdev; struct regulator_dev *rdev = regulator->rdev;
return rdev->desc->n_voltages ? : -EINVAL; if (rdev->desc->n_voltages)
return rdev->desc->n_voltages;
if (!rdev->supply)
return -EINVAL;
return regulator_count_voltages(rdev->supply);
} }
EXPORT_SYMBOL_GPL(regulator_count_voltages); EXPORT_SYMBOL_GPL(regulator_count_voltages);
@ -2203,12 +2211,17 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
return rdev->desc->fixed_uV; return rdev->desc->fixed_uV;
if (!ops->list_voltage || selector >= rdev->desc->n_voltages) if (ops->list_voltage) {
if (selector >= rdev->desc->n_voltages)
return -EINVAL; return -EINVAL;
mutex_lock(&rdev->mutex); mutex_lock(&rdev->mutex);
ret = ops->list_voltage(rdev, selector); ret = ops->list_voltage(rdev, selector);
mutex_unlock(&rdev->mutex); mutex_unlock(&rdev->mutex);
} else if (rdev->supply) {
ret = regulator_list_voltage(rdev->supply, selector);
} else {
return -EINVAL;
}
if (ret > 0) { if (ret > 0) {
if (ret < rdev->constraints->min_uV) if (ret < rdev->constraints->min_uV)
@ -2618,6 +2631,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
ret = rdev->desc->ops->list_voltage(rdev, 0); ret = rdev->desc->ops->list_voltage(rdev, 0);
} else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) {
ret = rdev->desc->fixed_uV; ret = rdev->desc->fixed_uV;
} else if (rdev->supply) {
ret = regulator_get_voltage(rdev->supply);
} else { } else {
return -EINVAL; return -EINVAL;
} }