Skip to content

Commit

Permalink
regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_m…
Browse files Browse the repository at this point in the history
…ap_voltage

It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
max_uV > tps->info[rid]->max_uV.

The equation we used in uv_to_vsel() does not allow
min_uV < tps->info[rid]->min_uV, otherwise it returns negative selector.
So we need to set min_uV = tps->info[rid]->min_uV if
min_uV < tps->info[rid]->min_uV.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Jul 3, 2012
1 parent 0072f0a commit 844e690
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/regulator/tps65217-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ 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 (min_uV < tps->info[rid]->min_uV)
min_uV = tps->info[rid]->min_uV;

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);
Expand Down

0 comments on commit 844e690

Please sign in to comment.