Revert "UPSTREAM: regulator: core: avoid unused variable warning"
authorHuang, Tao <huangtao@rock-chips.com>
Tue, 8 Mar 2016 08:13:26 +0000 (16:13 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Tue, 8 Mar 2016 08:27:08 +0000 (16:27 +0800)
This reverts commit 40e4c3535811ea74490bfa4fbe09cf85bb305efb.

Please refer to commit 70a7fb80e85a
("regulator: core: Fix nested locking of supplies")

Change-Id: If0bee255621a7480cfc6fa232f65081c4d904897

drivers/regulator/core.c

index c70017d5f74bb2d1305eb5d3f35a2885fbf9b51f..73b7683355cd015791114249defc26fdf2b644cf 100644 (file)
@@ -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;
+       }
 }
 
 /**