Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matthias Kaehlcke and committed by
Mark Brown
31dfe686 57995a48

+6 -2
+6 -2
drivers/regulator/core.c
··· 2800 2800 ret = -EINVAL; 2801 2801 } 2802 2802 2803 + if (ret) 2804 + goto out; 2805 + 2803 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 2808 && old_selector != selector) { 2806 2809 2807 2810 delay = ops->set_voltage_time_sel(rdev, ··· 2824 2821 } 2825 2822 } 2826 2823 2827 - if (ret == 0 && best_val >= 0) { 2824 + if (best_val >= 0) { 2828 2825 unsigned long data = best_val; 2829 2826 2830 2827 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, 2831 2828 (void *)data); 2832 2829 } 2833 2830 2831 + out: 2834 2832 trace_regulator_set_voltage_complete(rdev_get_name(rdev), best_val); 2835 2833 2836 2834 return ret;