[PATCH 1/2] regulator: core: Check before enabling regulator whilesetting constraints.

From: Yadwinder Singh Brar
Date: Tue Oct 16 2012 - 01:27:44 EST


This patch adds check, whether regulator is already enabled before enabling it
while setting machine constraints. Since some PMICs have same register bits
for setting opmode and enabling/disabling the regulator, so it will overwrite
the settings (if any)done by set_mode/set_suspend_mode callbacks when it
enables regulator without checking previous status.

Signed-off-by: Yadwinder Singh Brar <yadi.brar@xxxxxxxxxxx>
---
drivers/regulator/core.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f7c74db..9e3a0c7 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -958,6 +958,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
*/
if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
ops->enable) {
+ if (ops->is_enabled && ops->is_enabled(rdev))
+ goto enabled;
+
ret = ops->enable(rdev);
if (ret < 0) {
rdev_err(rdev, "failed to enable\n");
@@ -965,6 +968,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
}
}

+enabled:
if (rdev->constraints->ramp_delay && ops->set_ramp_delay) {
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
if (ret < 0) {
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/