linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting
@ 2012-03-27  7:17 Axel Lin
  2012-03-27  7:18 ` [PATCH 2/4] regulator: wm831x-isink: " Axel Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-27  7:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/wm831x-dcdc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 3044001..ff810e7 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -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))
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] regulator: wm831x-isink: Fix the logic to choose best current limit setting
  2012-03-27  7:17 [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Axel Lin
@ 2012-03-27  7:18 ` Axel Lin
  2012-03-27  7:20 ` [PATCH 3/4] regulator: wm8350: " Axel Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-27  7:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/wm831x-isink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 634aac3..b414e09 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -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;
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] regulator: wm8350: Fix the logic to choose best current limit setting
  2012-03-27  7:17 [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Axel Lin
  2012-03-27  7:18 ` [PATCH 2/4] regulator: wm831x-isink: " Axel Lin
@ 2012-03-27  7:20 ` Axel Lin
  2012-03-27  7:21 ` [PATCH 4/4] regulator: Return microamps in wm8350_isink_get_current Axel Lin
  2012-03-28 11:44 ` [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-27  7:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/wm8350-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index ff34654..f29803c 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -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;
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] regulator: Return microamps in wm8350_isink_get_current
  2012-03-27  7:17 [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Axel Lin
  2012-03-27  7:18 ` [PATCH 2/4] regulator: wm831x-isink: " Axel Lin
  2012-03-27  7:20 ` [PATCH 3/4] regulator: wm8350: " Axel Lin
@ 2012-03-27  7:21 ` Axel Lin
  2012-03-28 11:44 ` [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-27  7:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

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

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/wm8350-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index f29803c..c5f3b40 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -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 */
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting
  2012-03-27  7:17 [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Axel Lin
                   ` (2 preceding siblings ...)
  2012-03-27  7:21 ` [PATCH 4/4] regulator: Return microamps in wm8350_isink_get_current Axel Lin
@ 2012-03-28 11:44 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-03-28 11:44 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

On Tue, Mar 27, 2012 at 03:17:26PM +0800, Axel Lin wrote:
> Current code in wm831x_buckv_set_current_limit actually set the current limit
> setting greater than specified range.

Applied all, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-28 11:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27  7:17 [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Axel Lin
2012-03-27  7:18 ` [PATCH 2/4] regulator: wm831x-isink: " Axel Lin
2012-03-27  7:20 ` [PATCH 3/4] regulator: wm8350: " Axel Lin
2012-03-27  7:21 ` [PATCH 4/4] regulator: Return microamps in wm8350_isink_get_current Axel Lin
2012-03-28 11:44 ` [PATCH 1/4] regulator: wm831x-dcdc: Fix the logic to choose best current limit setting Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).