regulator: core: Respect off_on_delay at startup
authorVincent Whitchurch <vincent.whitchurch@axis.com>
Thu, 22 Apr 2021 08:30:44 +0000 (10:30 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 22 Apr 2021 15:27:34 +0000 (16:27 +0100)
commita5ccccb3ec0b052804d03df90c0d08689be54170
treea449d82c09b9b44fbf9065a4a85420b9c7af474e
parent013592be146a10d3567c0062cd1416faab060704
regulator: core: Respect off_on_delay at startup

We currently do not respect off_on_delay the first time we turn on a
regulator.  This is problematic since the regulator could have been
turned off by the bootloader, or it could it have been turned off during
the probe of the regulator driver (such as when regulator-fixed requests
the enable GPIO), either of which could potentially have happened less
than off_on_delay microseconds ago before the first time a client
requests for the regulator to be turned on.

We can't know exactly when the regulator was turned off, but initialise
off_on_delay to the current time when registering the regulator, so that
we guarantee that we respect the off_on_delay in all cases.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Link: https://lore.kernel.org/r/20210422083044.11479-1-vincent.whitchurch@axis.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c