Skip to contentSkip to conversation

regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage

PATCH Applied Axel Lin 3 participants 3 messages Jul 3, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH v2 1/1 regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_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.

---
 drivers/regulator/tps65217-regulator.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/tps65217-regulator.c +3 -3
index 0a3df5b..f7d0495 100644
@@ -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);
Signature · 1 line
1.7.9.5
Acked-by on v2 1/1
#1 lore raw

Hi Axel,

Thanks for the patch

Quoted 37 lines · Axel Lin

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.

---
 drivers/regulator/tps65217-regulator.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/tps65217-regulator.c +3 -3
index 0a3df5b..f7d0495 100644
@@ -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);
Signature · 1 line
1.7.9.5

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

Applied
#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

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

Applied, thanks.