From: Huang, Tao Date: Tue, 8 Mar 2016 08:13:26 +0000 (+0800) Subject: Revert "UPSTREAM: regulator: core: avoid unused variable warning" X-Git-Tag: firefly_0821_release~3256 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e089966464e40c4bdbae5fbdbfbcac02d0195546;p=firefly-linux-kernel-4.4.55.git Revert "UPSTREAM: regulator: core: avoid unused variable warning" This reverts commit 40e4c3535811ea74490bfa4fbe09cf85bb305efb. Please refer to commit 70a7fb80e85a ("regulator: core: Fix nested locking of supplies") Change-Id: If0bee255621a7480cfc6fa232f65081c4d904897 --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c70017d5f74b..73b7683355cd 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -138,10 +138,18 @@ static bool have_full_constraints(void) */ static void regulator_lock_supply(struct regulator_dev *rdev) { - int i; + struct regulator *supply; + int i = 0; + + while (1) { + mutex_lock_nested(&rdev->mutex, i++); + supply = rdev->supply; - for (i = 0; rdev->supply; rdev = rdev->supply->rdev, i++) - mutex_lock_nested(&rdev->mutex, i); + if (!rdev->supply) + return; + + rdev = supply->rdev; + } } /**