summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2016-09-14 09:52:06 -0700
committerTao Huang <huangtao@rock-chips.com>2018-03-22 11:14:38 +0800
commit8681485ecb869969462f65a5ed57892b49476364 (patch)
treefe379e2464a33e796c86686d25874ad5c6d3c6eb
parent4091ac228dfc6c3c3e9bbd34d7ade6b2eb17ab92 (diff)
UPSTREAM: regulator: core: Simplify error flow in _regulator_do_set_voltage()
If the voltage can not be set jump to the end of the function. This avoids having to check for an error multiple times and eliminates one level of nesting in a follow-up change. Change-Id: Icead960f8403e2e962cd94fc516a5f633f5c3fc7 Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Tao Huang <huangtao@rock-chips.com> (cherry picked from commit 31dfe686ed0ba5a796bcfc5a6745e77ddb5daa4e)
-rw-r--r--drivers/regulator/core.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 15c97413bbcc..5639aa01c5cd 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2829,8 +2829,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
ret = -EINVAL;
}
+ if (ret)
+ goto out;
+
/* Call set_voltage_time_sel if successfully obtained old_selector */
- if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0
+ if (!rdev->constraints->ramp_disable && old_selector >= 0
&& old_selector != selector) {
delay = ops->set_voltage_time_sel(rdev,
@@ -2850,13 +2853,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}
}
- if (ret == 0 && best_val >= 0) {
+ if (best_val >= 0) {
unsigned long data = best_val;
_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
(void *)data);
}
+out:
trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val);
return ret;