regulator: core: Make set_voltage_tol() try for mid-range first
authorMark Brown <broonie@linaro.org>
Thu, 4 Jul 2013 16:27:14 +0000 (17:27 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 15 Jul 2013 10:20:08 +0000 (11:20 +0100)
commitdc9ceed6a12aff627c81e01ada191e8a23fcbe3e
tree2eb735c7e63efe9bddd03953337e100ece9d5d33
parentad81f0545ef01ea651886dddac4bef6cec930092
regulator: core: Make set_voltage_tol() try for mid-range first

The expected semantic for something expressed as a tolerance is that it
should deliver the specified value with some deviation allowed but this
is not what set_voltage_tol() currently does. Instead it just passes
the maximum possible range to set_voltage() which will typically result
in a voltage aimed at lower than the target voltage.

Instead first try to set a voltage between the target voltage and the
upper limit, then fall back on the full range. This will be much more
robust against physical variation in systems and makes the API behave
more like users would expect.

Signed-off-by: Mark Brown <broonie@linaro.org>
include/linux/regulator/consumer.h