summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-08-30 16:07:38 +0400
committerMark Brown <broonie@linaro.org>2013-08-30 18:24:42 +0400
commit556dcf903d8a22aa1b3eb743aeffd4849eef2e24 (patch)
tree483bd2c4647e821337d655bd314b73f066419392 /drivers/regulator
parent69ca3e58d17854f8fa72d85aea6bf4614ad25a56 (diff)
downloadlinux-556dcf903d8a22aa1b3eb743aeffd4849eef2e24.tar.xz
regulator: da9063: Optimize da9063_set_current_limit implementation
All the current limit tables have the values in ascend order. So we can slightly optimize the for loop iteration because the first match is the minimal value. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/da9063-regulator.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index fc2871cb4742..f29e7290cc94 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -166,22 +166,15 @@ static int da9063_set_current_limit(struct regulator_dev *rdev,
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
const struct da9063_regulator_info *rinfo = regl->info;
- int val = INT_MAX;
- unsigned sel = 0;
- int n;
- int tval;
+ int n, tval;
for (n = 0; n < rinfo->n_current_limits; n++) {
tval = rinfo->current_limits[n];
- if (tval >= min_uA && tval <= max_uA && val > tval) {
- val = tval;
- sel = n;
- }
+ if (tval >= min_uA && tval <= max_uA)
+ return regmap_field_write(regl->ilimit, n);
}
- if (val == INT_MAX)
- return -EINVAL;
- return regmap_field_write(regl->ilimit, sel);
+ return -EINVAL;
}
static int da9063_get_current_limit(struct regulator_dev *rdev)