Commit 783d444c authored by Markus Pargmann's avatar Markus Pargmann Committed by Greg Kroah-Hartman

regulator: core: Replace direct ops->enable usage

commit 30c21971 upstream.

There are some direct ops->enable in the regulator core driver. This is
a potential issue as the function _regulator_do_enable() handles gpio
regulators and the normal ops->enable calls. These gpio regulators are
simply ignored when ops->enable is called directly.

One possible bug is that boot-on and always-on gpio regulators are not
enabled on registration.

This patch replaces all ops->enable calls by _regulator_do_enable.

[Handle missing enable operations -- broonie]
Signed-off-by: default avatarMarkus Pargmann <mpa@pengutronix.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f5a82d2f
...@@ -919,6 +919,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, ...@@ -919,6 +919,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
return 0; return 0;
} }
static int _regulator_do_enable(struct regulator_dev *rdev);
/** /**
* set_machine_constraints - sets regulator constraints * set_machine_constraints - sets regulator constraints
* @rdev: regulator source * @rdev: regulator source
...@@ -975,10 +977,9 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -975,10 +977,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
/* If the constraints say the regulator should be on at this point /* If the constraints say the regulator should be on at this point
* and we have control then make sure it is enabled. * and we have control then make sure it is enabled.
*/ */
if ((rdev->constraints->always_on || rdev->constraints->boot_on) && if (rdev->constraints->always_on || rdev->constraints->boot_on) {
ops->enable) { ret = _regulator_do_enable(rdev);
ret = ops->enable(rdev); if (ret < 0 && ret != -EINVAL) {
if (ret < 0) {
rdev_err(rdev, "failed to enable\n"); rdev_err(rdev, "failed to enable\n");
goto out; goto out;
} }
...@@ -3790,9 +3791,8 @@ int regulator_suspend_finish(void) ...@@ -3790,9 +3791,8 @@ int regulator_suspend_finish(void)
struct regulator_ops *ops = rdev->desc->ops; struct regulator_ops *ops = rdev->desc->ops;
mutex_lock(&rdev->mutex); mutex_lock(&rdev->mutex);
if ((rdev->use_count > 0 || rdev->constraints->always_on) && if (rdev->use_count > 0 || rdev->constraints->always_on) {
ops->enable) { error = _regulator_do_enable(rdev);
error = ops->enable(rdev);
if (error) if (error)
ret = error; ret = error;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment