regulator: core: Don't allow to get regulator until all couples resolved
authorDmitry Osipenko <digetx@gmail.com>
Fri, 5 Oct 2018 15:36:31 +0000 (18:36 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 8 Nov 2018 12:41:10 +0000 (12:41 +0000)
Don't allow to get regulator until all of its couples resolved because
consumer will get EPERM and coupling shall be transparent for the drivers.

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

index 925df9e6f1e37383de8e98040da73baffa87aa23..089e8ad8ef57ec4b13e811148f438fe373bac48b 100644 (file)
@@ -1747,6 +1747,16 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
                return regulator;
        }
 
+       mutex_lock(&regulator_list_mutex);
+       ret = (rdev->coupling_desc.n_resolved != rdev->coupling_desc.n_coupled);
+       mutex_unlock(&regulator_list_mutex);
+
+       if (ret != 0) {
+               regulator = ERR_PTR(-EPROBE_DEFER);
+               put_device(&rdev->dev);
+               return regulator;
+       }
+
        ret = regulator_resolve_supply(rdev);
        if (ret < 0) {
                regulator = ERR_PTR(ret);