* [PATCH 1/2] regulator: core: Check before enabling regulator while setting constraints.
@ 2012-10-16 5:24 Yadwinder Singh Brar
2012-10-16 5:35 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Yadwinder Singh Brar @ 2012-10-16 5:24 UTC (permalink / raw)
To: linux-kernel; +Cc: sameo, Mark Brown, Liam Girdwood, Yadwinder Singh Brar
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@samsung.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] regulator: core: Check before enabling regulator while setting constraints.
2012-10-16 5:24 [PATCH 1/2] regulator: core: Check before enabling regulator while setting constraints Yadwinder Singh Brar
@ 2012-10-16 5:35 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-10-16 5:35 UTC (permalink / raw)
To: Yadwinder Singh Brar; +Cc: linux-kernel, sameo, Liam Girdwood
On Tue, Oct 16, 2012 at 10:54:19AM +0530, Yadwinder Singh Brar wrote:
> 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.
This sounds like a bug in the driver, these ops are supposed to be
repeatable at will. The driver needs to remember the mode setting when
doing enable or disable, and setting the mode should not change the
enable status.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-16 5:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 5:24 [PATCH 1/2] regulator: core: Check before enabling regulator while setting constraints Yadwinder Singh Brar
2012-10-16 5:35 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox