regulator: core: create unlocked version of regulator_list_voltage
The unlocked version will be needed when we start propagating voltage changes to the supply regulators. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
9f01cd4a91
commit
3a40cfc36b
|
@ -2348,6 +2348,40 @@ static int _regulator_is_enabled(struct regulator_dev *rdev)
|
||||||
return rdev->desc->ops->is_enabled(rdev);
|
return rdev->desc->ops->is_enabled(rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _regulator_list_voltage(struct regulator *regulator,
|
||||||
|
unsigned selector, int lock)
|
||||||
|
{
|
||||||
|
struct regulator_dev *rdev = regulator->rdev;
|
||||||
|
const struct regulator_ops *ops = rdev->desc->ops;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
|
||||||
|
return rdev->desc->fixed_uV;
|
||||||
|
|
||||||
|
if (ops->list_voltage) {
|
||||||
|
if (selector >= rdev->desc->n_voltages)
|
||||||
|
return -EINVAL;
|
||||||
|
if (lock)
|
||||||
|
mutex_lock(&rdev->mutex);
|
||||||
|
ret = ops->list_voltage(rdev, selector);
|
||||||
|
if (lock)
|
||||||
|
mutex_unlock(&rdev->mutex);
|
||||||
|
} else if (rdev->supply) {
|
||||||
|
ret = _regulator_list_voltage(rdev->supply, selector, lock);
|
||||||
|
} else {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret > 0) {
|
||||||
|
if (ret < rdev->constraints->min_uV)
|
||||||
|
ret = 0;
|
||||||
|
else if (ret > rdev->constraints->max_uV)
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* regulator_is_enabled - is the regulator output enabled
|
* regulator_is_enabled - is the regulator output enabled
|
||||||
* @regulator: regulator source
|
* @regulator: regulator source
|
||||||
|
@ -2437,33 +2471,7 @@ EXPORT_SYMBOL_GPL(regulator_count_voltages);
|
||||||
*/
|
*/
|
||||||
int regulator_list_voltage(struct regulator *regulator, unsigned selector)
|
int regulator_list_voltage(struct regulator *regulator, unsigned selector)
|
||||||
{
|
{
|
||||||
struct regulator_dev *rdev = regulator->rdev;
|
return _regulator_list_voltage(regulator, selector, 1);
|
||||||
const struct regulator_ops *ops = rdev->desc->ops;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector)
|
|
||||||
return rdev->desc->fixed_uV;
|
|
||||||
|
|
||||||
if (ops->list_voltage) {
|
|
||||||
if (selector >= rdev->desc->n_voltages)
|
|
||||||
return -EINVAL;
|
|
||||||
mutex_lock(&rdev->mutex);
|
|
||||||
ret = ops->list_voltage(rdev, selector);
|
|
||||||
mutex_unlock(&rdev->mutex);
|
|
||||||
} else if (rdev->supply) {
|
|
||||||
ret = regulator_list_voltage(rdev->supply, selector);
|
|
||||||
} else {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret > 0) {
|
|
||||||
if (ret < rdev->constraints->min_uV)
|
|
||||||
ret = 0;
|
|
||||||
else if (ret > rdev->constraints->max_uV)
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regulator_list_voltage);
|
EXPORT_SYMBOL_GPL(regulator_list_voltage);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue