[PATCH 1/2] regulator: ad5398: Fix min/max current limit boundary checking

July 02nd, 2012 - 11:10 pm ET by Axel Lin | Report spam
It is ok to request current limit with min_uA < chip->min_uA and
max_uA > chip->max_uA.

Signed-off-by: Axel Lin <axel.lin@gmail.com>

drivers/regulator/ad5398.c | 4 +
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index 46d05f3..6a357dc 100644
a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -89,9 +89,7 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
unsigned short data;
int ret;

- if (min_uA > chip->max_uA || min_uA < chip->min_uA)
- return -EINVAL;
- if (max_uA > chip->max_uA || max_uA < chip->min_uA)
+ if (min_uA > chip->max_uA || max_uA < chip->min_uA)
return -EINVAL;

selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level,
1.7.9.5



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
email Follow the discussionReplies 6 repliesReplies Make a reply

Replies

#1 Axel Lin
July 02nd, 2012 - 11:10 pm ET | Report spam
It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
max_uV > tps->info[rid]->max_uV

Signed-off-by: Axel Lin

drivers/regulator/tps65217-regulator.c | 5 +-
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 0a3df5b..0947a09 100644
a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -206,10 +206,7 @@ static int tps65217_pmic_map_voltage(struct regulator_dev *dev,
if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
return -EINVAL;

- if (min_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
- return -EINVAL;
-
- if (max_uV < tps->info[rid]->min_uV || max_uV > tps->info[rid]->max_uV)
+ if (max_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
return -EINVAL;

ret = tps->info[rid]->uv_to_vsel(min_uV, &sel);
1.7.9.5



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Similar topics