UPSTREAM: regulator: reorder initialization steps in regulator_register()
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 12 Apr 2016 10:31:00 +0000 (12:31 +0200)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 6 Mar 2017 10:28:40 +0000 (18:28 +0800)
commit286d645c529781e8cb5b44f97d1d5adfa42f6d4d
tree67ea5be4c16fce3970e97ae716fe5ab2da165743
parente8177c76214dbc92f1342f28231928dfcb8866ba
UPSTREAM: regulator: reorder initialization steps in regulator_register()

device_register() is calling ->get_voltage() as part of it's sysfs attribute
initialization process, and this functions might need to know the regulator
constraints to return a valid value.
This is at least true for the pwm regulator driver (when operating in
continuous mode) which needs to know the minimum and maximum voltage values
to calculate the current voltage:

min_uV + (((max_uV - min_uV) * dutycycle) / 100);

Move device_register() after set_machine_constraints() to make sure those
constraints are correctly initialized when ->get_voltage() is called.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 469b640e4f4a28bdd50f0ac1d2b310907afb464c)

Change-Id: I83c95e5baef0501876d19f1e2e7a7e3af8631b1f
Signed-off-by: David Wu <david.wu@rock-chips.com>
drivers/regulator/core.c