Skip to contentSkip to conversation

regulator: wm831x-dcdc: Fix the logic to choose best current limit setting

PATCH Applied Axel Lin 2 participants 5 messages Mar 27, 2012 – Mar 28, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/4 regulator: wm831x-dcdc: Fix the logic to choose best current limit setting

Current code in wm831x_buckv_set_current_limit actually set the current limit setting greater than specified range.

Fix the logic in wm831x_buckv_set_current_limit to choose the smallest current limit setting falls within the specified range.

---
 drivers/regulator/wm831x-dcdc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/regulator/wm831x-dcdc.c +2 -1
index 3044001..ff810e7 100644
@@ -380,7 +380,8 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
-		if (max_uA <= wm831x_dcdc_ilim[i])
+		if ((min_uA <= wm831x_dcdc_ilim[i]) &&
+		    (wm831x_dcdc_ilim[i] <= max_uA))
 			break;
 	}
 	if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/4 regulator: wm831x-isink: Fix the logic to choose best current limit setting

Current code in wm831x_isink_set_current actually set the current limit setting smaller than specified range.

Fix the logic in wm831x_isink_set_current to choose the smallest current limit setting falls within the specified range.

---
 drivers/regulator/wm831x-isink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/wm831x-isink.c +1 -1
index 634aac3..b414e09 100644
@@ -101,7 +101,7 @@ static int wm831x_isink_set_current(struct regulator_dev *rdev,
 
 	for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) {
 		int val = wm831x_isinkv_values[i];
-		if (min_uA >= val && val <= max_uA) {
+		if (min_uA <= val && val <= max_uA) {
 			ret = wm831x_set_bits(wm831x, isink->reg,
 					      WM831X_CS1_ISEL_MASK, i);
 			return ret;
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 3/4 regulator: wm8350: Fix the logic to choose best current limit setting

In reply to Axel Lin

Current implementation in get_isink_val actually choose the biggest current limit setting falls within the specified range.
What we want is to choose the smallest current limit setting falls within the specified range. Fix it.

---
 drivers/regulator/wm8350-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/wm8350-regulator.c +1 -1
index ff34654..f29803c 100644
@@ -99,7 +99,7 @@ static int get_isink_val(int min_uA, int max_uA, u16 *setting)
 {
 	int i;
 
-	for (i = ARRAY_SIZE(isink_cur) - 1; i >= 0; i--) {
+	for (i = 0; i < ARRAY_SIZE(isink_cur); i++) {
 		if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
 			*setting = i;
 			return 0;
Signature · 1 line
1.7.5.4
author
#3 lore raw

PATCH 4/4 regulator: Return microamps in wm8350_isink_get_current

In reply to Axel Lin

The values in isink_cur array are microamps.
The regulator core expects get_current_limit callback to return microamps.

---
 drivers/regulator/wm8350-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/wm8350-regulator.c +1 -1
index f29803c..c5f3b40 100644
@@ -186,7 +186,7 @@ static int wm8350_isink_get_current(struct regulator_dev *rdev)
 		return 0;
 	}
 
-	return DIV_ROUND_CLOSEST(isink_cur[val], 100);
+	return isink_cur[val];
 }
 
 /* turn on ISINK followed by DCDC */
Signature · 1 line
1.7.5.4
Applied
#4 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

Current code in wm831x_buckv_set_current_limit actually set the current limit setting greater than specified range.

Applied all, thanks.