From: Axel Lin Date: Wed, 8 Aug 2012 12:21:30 +0000 (+0800) Subject: regulator: tps6524x: set_current_limit should select the maximum current in specific... X-Git-Tag: v3.7-rc1~204^2^5~31 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=73f4f3d37604ff7084e6157745610c8fb07d27b6;p=~emulex%2Finfiniband.git regulator: tps6524x: set_current_limit should select the maximum current in specific range Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 947ece933d9..058d2f2675e 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c @@ -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)