regulator: wm831x-dcdc: Fix the logic to choose best current limit setting
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
@@ -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
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
@@ -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
PATCH 3/4 regulator: wm8350: Fix the logic to choose best current limit setting
In reply to Axel LinCurrent 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
@@ -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
PATCH 4/4 regulator: Return microamps in wm8350_isink_get_current
In reply to Axel LinThe 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
@@ -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
Mark Brown
AppliedQuoted 2 lines · Axel Lin
Current code in
wm831x_buckv_set_current_limitactually set the current limit setting greater than specified range.
Applied all, thanks.