regulator: tps6524x: set_current_limit should select the maximum current in specific...
authorAxel Lin <axel.lin@gmail.com>
Wed, 8 Aug 2012 12:21:30 +0000 (20:21 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 28 Aug 2012 18:00:26 +0000 (11:00 -0700)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/tps6524x-regulator.c

index 947ece933d901fa75ef54e286979d12f02dea7ce..058d2f2675e902c8d2856b83b3ee5a6b4c7c5503 100644 (file)
@@ -502,15 +502,13 @@ static int set_current_limit(struct regulator_dev *rdev, int min_uA,
        if (info->n_ilimsels == 1)
                return -EINVAL;
 
-       for (i = 0; i < info->n_ilimsels; i++)
+       for (i = info->n_ilimsels - 1; i >= 0; i--) {
                if (min_uA <= info->ilimsels[i] &&
                    max_uA >= info->ilimsels[i])
-                       break;
-
-       if (i >= info->n_ilimsels)
-               return -EINVAL;
+                       return write_field(hw, &info->ilimsel, i);
+       }
 
-       return write_field(hw, &info->ilimsel, i);
+       return -EINVAL;
 }
 
 static int get_current_limit(struct regulator_dev *rdev)