Upgrade to 4.4.50-rt62
[kvmfornfv.git] / kernel / drivers / regulator / core.c
index 73b7683..732ac71 100644 (file)
@@ -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);
 }
 
 /**