summaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorAlex Frid <afrid@nvidia.com>2013-12-14 23:50:39 -0800
committerYu-Huan Hsu <yhsu@nvidia.com>2013-12-17 16:32:01 -0800
commit5aa576d25a16782e8487dfd02692a482bcae7596 (patch)
tree1886c78f8063a4c3bdcbb8eeb92cfb314e102e05 /drivers/regulator/core.c
parent8d560a06013312dd1e64ebc2bdab8f85ac12ec2c (diff)
regulator: Fix voltage level change notification
- Do not sent pre-/post- change notification in case selector is equal to old_selector, and regulator control interface is not called - Pass voltage value (not selector) to post-change notification to be consistent with pre-change notification. Change-Id: I8fe6ee149f8f34f1818abf0b1cbcbd9c437cab7f Signed-off-by: Alex Frid <afrid@nvidia.com> Reviewed-on: http://git-master/r/345608 GVS: Gerrit_Virtual_Submit Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 021df6a92b35..d8429824086f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2702,6 +2702,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
int best_val = 0;
unsigned int selector;
int old_selector = -1;
+ bool tried_change = false;
trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV);
@@ -2721,9 +2722,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}
if (rdev->desc->ops->set_voltage) {
- if (_regulator_is_enabled(rdev))
+ if (_regulator_is_enabled(rdev)) {
_notifier_call_chain(rdev,
- REGULATOR_EVENT_OUT_PRECHANGE, (void *)min_uV);
+ REGULATOR_EVENT_OUT_PRECHANGE, (void *)((long)min_uV));
+ tried_change = true;
+ }
ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
&selector);
@@ -2753,15 +2756,19 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
if (ret >= 0) {
best_val = rdev->desc->ops->list_voltage(rdev, ret);
if (min_uV <= best_val && max_uV >= best_val) {
- if (_regulator_is_enabled(rdev))
- _notifier_call_chain(rdev,
- REGULATOR_EVENT_OUT_PRECHANGE, (void *)ret);
selector = ret;
if (old_selector == selector)
ret = 0;
- else
+ else {
+ if (_regulator_is_enabled(rdev)) {
+ _notifier_call_chain(rdev,
+ REGULATOR_EVENT_OUT_PRECHANGE,
+ (void *)((long)best_val));
+ tried_change = true;
+ }
ret = rdev->desc->ops->set_voltage_sel(
rdev, ret);
+ }
} else {
ret = -EINVAL;
}
@@ -2798,11 +2805,10 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
(void *)data);
}
- if (_regulator_is_enabled(rdev)) {
- if (selector != -1)
- min_uV = selector;
+ if (tried_change) {
+ long val = ret == 0 ? best_val : -1;
_notifier_call_chain(rdev, REGULATOR_EVENT_OUT_POSTCHANGE,
- (void *)min_uV);
+ (void *)val);
}
trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val);