X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Fdrivers%2Fregulator%2Fcore.c;fp=kernel%2Fdrivers%2Fregulator%2Fcore.c;h=732ac71b82cdd5981454dec04da6ad2cad6c4cba;hb=52f993b8e89487ec9ee15a7fb4979e0f09a45b27;hp=73b7683355cd015791114249defc26fdf2b644cf;hpb=c189ccac5702322ed843fe17057035b7222a59b6;p=kvmfornfv.git diff --git a/kernel/drivers/regulator/core.c b/kernel/drivers/regulator/core.c index 73b768335..732ac71b8 100644 --- a/kernel/drivers/regulator/core.c +++ b/kernel/drivers/regulator/core.c @@ -132,24 +132,24 @@ static bool have_full_constraints(void) return has_full_constraints || of_have_populated_dt(); } +static inline struct regulator_dev *rdev_get_supply(struct regulator_dev *rdev) +{ + if (rdev && rdev->supply) + return rdev->supply->rdev; + + return NULL; +} + /** * regulator_lock_supply - lock a regulator and its supplies * @rdev: regulator source */ static void regulator_lock_supply(struct regulator_dev *rdev) { - struct regulator *supply; - int i = 0; - - while (1) { - mutex_lock_nested(&rdev->mutex, i++); - supply = rdev->supply; - - if (!rdev->supply) - return; + int i; - rdev = supply->rdev; - } + for (i = 0; rdev; rdev = rdev_get_supply(rdev), i++) + mutex_lock_nested(&rdev->mutex, i); } /**