]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
regulator: core: simplify _regulator_get()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 7 Feb 2017 03:56:14 +0000 (19:56 -0800)
committerMark Brown <broonie@kernel.org>
Wed, 8 Feb 2017 18:29:05 +0000 (18:29 +0000)
commita4d7641fa797b523c0789d2fa55b0a3d53abc2fb
treef8cd5387ca87ec469686539d0088825c529d064a
parent163478dae0b6ce2437488e54012705b53ef43f3d
regulator: core: simplify _regulator_get()

The code in _regulator_get() got a bit confusing over time, with control
flow jumping to a label from couple of places. Let's untangle it a bit by
doing the following:

1. Make handling of missing supplies and substituting them with dummy
regulators more explicit:

- check if we not have full constraints and refuse considering dummy
  regulators with appropriate message;

- use "switch (get_type)" to handle different types of request explicitly
  as well. "Normal" requests will get dummies, exclusive will not and
  will notify user about that; optional will fail silently.

2. Stop jumping to a label in the middle of the function but instead have
proper conditional flow. I believe jumps should be reserved for error
handling, breaking from inner loop, or restarting a loop, but not for
implementing normal conditional flow.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c