path: root/drivers/regulator/core.c
diff options
authorMark Brown <>2010-12-16 13:59:10 +0000
committerLiam Girdwood <>2011-01-12 14:33:05 +0000
commitded06a5270ddd6c3c3e25d9ddcaaaa4cb8385c2f (patch)
treea845d31f0bdc663fbbd3fde7dcd9ed638b963c66 /drivers/regulator/core.c
parente8eef82b2c652d031bee9dff9762325672f5a1e0 (diff)
regulator: Only notify voltage changes when they succeed
Currently we notify a voltage change whenever we exit set_voltage(), even if the change failed for some reason (eg, a constraints issue). This shouldn't cause any substantial ill effects but is wasteful as listeners get notified on noops. Fix this by moving the notification into _do_set_voltage() and only notifying if we don't return an error. Reported-by: Saravana Kannan <> Signed-off-by: Mark Brown <> Signed-off-by: Liam Girdwood <>
Diffstat (limited to 'drivers/regulator/core.c')
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a0579f069002..3d72cc8e2f3e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1667,6 +1667,10 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
ret = -EINVAL;
+ if (ret == 0)
+ _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
+ NULL);
trace_regulator_set_voltage_complete(rdev_get_name(rdev), selector);
return ret;
@@ -1718,7 +1722,6 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
- _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL);
return ret;