From e089966464e40c4bdbae5fbdbfbcac02d0195546 Mon Sep 17 00:00:00 2001 From: "Huang, Tao" Date: Tue, 8 Mar 2016 16:13:26 +0800 Subject: [PATCH] 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 --- drivers/regulator/core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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; + } } /** -- 2.34.1