Skip to content

Commit

Permalink
regulator: core: Replace direct ops->enable usage
Browse files Browse the repository at this point in the history
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]

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>

regulator: Handle invalid enable operation for always/boot on regulators

Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Markus Pargmann authored and Mark Brown committed Feb 25, 2014
1 parent acc3d5c commit 30c2197
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev,
return 0;
}

static int _regulator_do_enable(struct regulator_dev *rdev);

/**
* set_machine_constraints - sets regulator constraints
* @rdev: regulator source
Expand Down Expand Up @@ -1013,10 +1015,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
/* If the constraints say the regulator should be on at this point
* and we have control then make sure it is enabled.
*/
if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
ops->enable) {
ret = ops->enable(rdev);
if (ret < 0) {
if (rdev->constraints->always_on || rdev->constraints->boot_on) {
ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable\n");
goto out;
}
Expand Down Expand Up @@ -3626,9 +3627,8 @@ int regulator_suspend_finish(void)
struct regulator_ops *ops = rdev->desc->ops;

mutex_lock(&rdev->mutex);
if ((rdev->use_count > 0 || rdev->constraints->always_on) &&
ops->enable) {
error = ops->enable(rdev);
if (rdev->use_count > 0 || rdev->constraints->always_on) {
error = _regulator_do_enable(rdev);
if (error)
ret = error;
} else {
Expand Down

0 comments on commit 30c2197

Please sign in to comment.