Skip to content

Commit 31dfe68

Browse files
Matthias Kaehlckebroonie
authored andcommitted
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>
1 parent 57995a4 commit 31dfe68

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/regulator/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,8 +2800,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
28002800
ret = -EINVAL;
28012801
}
28022802

2803+
if (ret)
2804+
goto out;
2805+
28032806
/* 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
28052808
&& old_selector != selector) {
28062809

28072810
delay = ops->set_voltage_time_sel(rdev,
@@ -2821,13 +2824,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
28212824
}
28222825
}
28232826

2824-
if (ret == 0 && best_val >= 0) {
2827+
if (best_val >= 0) {
28252828
unsigned long data = best_val;
28262829

28272830
_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
28282831
(void *)data);
28292832
}
28302833

2834+
out:
28312835
trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val);
28322836

28332837
return ret;

0 commit comments

Comments
 (0)