diff options
| author | Matthias Kaehlcke <mka@chromium.org> | 2016-09-14 12:52:06 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2016-09-16 12:33:40 -0400 |
| commit | 31dfe686ed0ba5a796bcfc5a6745e77ddb5daa4e (patch) | |
| tree | a2306feb6e845d6cedce484ea52394389f27b249 /drivers/regulator | |
| parent | 57995a4860542ea2089558c84f739e12d5ca1059 (diff) | |
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.
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
| -rw-r--r-- | drivers/regulator/core.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b059e8334567..b0076ccf896b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -2800,8 +2800,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
| 2800 | ret = -EINVAL; | 2800 | ret = -EINVAL; |
| 2801 | } | 2801 | } |
| 2802 | 2802 | ||
| 2803 | if (ret) | ||
| 2804 | goto out; | ||
| 2805 | |||
| 2803 | /* Call set_voltage_time_sel if successfully obtained old_selector */ | 2806 | /* Call set_voltage_time_sel if successfully obtained old_selector */ |
| 2804 | if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0 | 2807 | if (!rdev->constraints->ramp_disable && old_selector >= 0 |
| 2805 | && old_selector != selector) { | 2808 | && old_selector != selector) { |
| 2806 | 2809 | ||
| 2807 | delay = ops->set_voltage_time_sel(rdev, | 2810 | delay = ops->set_voltage_time_sel(rdev, |
| @@ -2821,13 +2824,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
| 2821 | } | 2824 | } |
| 2822 | } | 2825 | } |
| 2823 | 2826 | ||
| 2824 | if (ret == 0 && best_val >= 0) { | 2827 | if (best_val >= 0) { |
| 2825 | unsigned long data = best_val; | 2828 | unsigned long data = best_val; |
| 2826 | 2829 | ||
| 2827 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, | 2830 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, |
| 2828 | (void *)data); | 2831 | (void *)data); |
| 2829 | } | 2832 | } |
| 2830 | 2833 | ||
| 2834 | out: | ||
| 2831 | trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val); | 2835 | trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val); |
| 2832 | 2836 | ||
| 2833 | return ret; | 2837 | return ret; |
