OSDN Git Service

regulator: core: Don't use regulators as supplies until the parent is bound
authorJon Hunter <jonathanh@nvidia.com>
Wed, 11 Jan 2017 17:44:25 +0000 (17:44 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 12 Jan 2017 17:25:14 +0000 (17:25 +0000)
commit66d228a2bf03b163ddaeca5f24f1ff89a84ad668
treeb2f6a5f394f747ab02710b61317c9fc93d5a0250
parentd00b74613fb18dfd0a5aa99270ee2e72d5c808d7
regulator: core: Don't use regulators as supplies until the parent is bound

When regulators are successfully registered, we check to see if the
regulator is a supply for any other registered regulator and if so
add the new regulator as the supply for the existing regulator(s).

Some devices, such as Power Management ICs, may register a series of
regulators when probed and there are cases where one of the regulators
may fail to register and defer the probing of the parent device. In this
case any successfully registered regulators would be unregistered so
that they can be re-registered at some time later when the probe is
attempted again. However, if one of the regulators that was registered
was added as a supply to another registered regulator (that did not
belong to the same parent device), then this supply regulator was
unregister again because the parent device is probe deferred, then a
regulator could be holding an invalid reference to a supply regulator
that has been unregistered. This will lead to a system crash if that
regulator is then used.

Although it would be possible to check when unregistering a regulator
if any other regulator in the system is using it as a supply, it still
may not be possible to remove it as a supply if this other regulator is
in use. Therefore, fix this by preventing any regulator from adding
another regulator as a supply if the parent device for the supply
regulator has not been bound and if the parent device for the supply
and the regulator are different. This will allow a parent device that is
registering regulators to be probe deferred and ensure that none of the
regulators it has registered are used as supplies for any other
regulator from another device.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c