LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
@ 2012-03-02  8:20 Axel Lin
  2012-03-02  8:22 ` [PATCH 2/3] regulator: max1586: " Axel Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-02  8:20 UTC (permalink / raw
  To: linux-kernel; +Cc: Sonic Zhang, Liam Girdwood, Mark Brown

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

diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index 483c809..26d23ad 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
 	if (max_uA > chip->max_uA || max_uA < chip->min_uA)
 		return -EINVAL;
 
-	selector = ((min_uA - chip->min_uA) * chip->current_level +
-			range_uA - 1) / range_uA;
+	selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level,
+				range_uA);
 	if (ad5398_calc_current(chip, selector) > max_uA)
 		return -EINVAL;
 
-- 
1.7.5.4




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

* [PATCH 2/3] regulator: max1586: Use DIV_ROUND_UP macro to calculate selector
  2012-03-02  8:20 [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector Axel Lin
@ 2012-03-02  8:22 ` Axel Lin
  2012-03-03 11:13   ` Robert Jarzmik
  2012-03-02  8:23 ` [PATCH 3/3] regulator: max8660: " Axel Lin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2012-03-02  8:22 UTC (permalink / raw
  To: linux-kernel; +Cc: Robert Jarzmik, Liam Girdwood, Mark Brown

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

diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 40e7a4d..282d2ee 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -76,8 +76,8 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,
 	if (min_uV < max1586->min_uV)
 		min_uV = max1586->min_uV;
 
-	*selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL +
-			range_uV - 1) / range_uV;
+	*selector = DIV_ROUND_UP((min_uV - max1586->min_uV) *
+				 MAX1586_V3_MAX_VSEL, range_uV);
 	if (max1586_v3_calc_voltage(max1586, *selector) > max_uV)
 		return -EINVAL;
 
-- 
1.7.5.4




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

* [PATCH 3/3] regulator: max8660: Use DIV_ROUND_UP macro to calculate selector
  2012-03-02  8:20 [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector Axel Lin
  2012-03-02  8:22 ` [PATCH 2/3] regulator: max1586: " Axel Lin
@ 2012-03-02  8:23 ` Axel Lin
  2012-03-02  8:57 ` [PATCH 1/3] regulator: ad5398: " Zhang, Sonic
  2012-03-02 11:24 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-02  8:23 UTC (permalink / raw
  To: linux-kernel; +Cc: Wolfram Sang, Liam Girdwood, Mark Brown

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

diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index a838e66..4c5b053 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -153,14 +153,15 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV,
 	if (max_uV < MAX8660_DCDC_MIN_UV || max_uV > MAX8660_DCDC_MAX_UV)
 		return -EINVAL;
 
-	selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1))
-			/ MAX8660_DCDC_STEP;
-	*s = selector;
+	selector = DIV_ROUND_UP(min_uV - MAX8660_DCDC_MIN_UV,
+				MAX8660_DCDC_STEP);
 
 	ret = max8660_dcdc_list(rdev, selector);
 	if (ret < 0 || ret > max_uV)
 		return -EINVAL;
 
+	*s = selector;
+
 	reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
 	ret = max8660_write(max8660, reg, 0, selector);
 	if (ret)
@@ -210,8 +211,9 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV,
 	if (max_uV < MAX8660_LDO5_MIN_UV || max_uV > MAX8660_LDO5_MAX_UV)
 		return -EINVAL;
 
-	selector = (min_uV - (MAX8660_LDO5_MIN_UV - MAX8660_LDO5_STEP + 1))
-			/ MAX8660_LDO5_STEP;
+	selector = DIV_ROUND_UP(min_uV - MAX8660_LDO5_MIN_UV,
+				MAX8660_LDO5_STEP);
+
 	ret = max8660_ldo5_list(rdev, selector);
 	if (ret < 0 || ret > max_uV)
 		return -EINVAL;
@@ -287,8 +289,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV,
 	if (max_uV < MAX8660_LDO67_MIN_UV || max_uV > MAX8660_LDO67_MAX_UV)
 		return -EINVAL;
 
-	selector = (min_uV - (MAX8660_LDO67_MIN_UV - MAX8660_LDO67_STEP + 1))
-			/ MAX8660_LDO67_STEP;
+	selector = DIV_ROUND_UP(min_uV - MAX8660_LDO67_MIN_UV,
+				MAX8660_LDO67_STEP);
 
 	ret = max8660_ldo67_list(rdev, selector);
 	if (ret < 0 || ret > max_uV)
-- 
1.7.5.4




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

* RE: [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
  2012-03-02  8:20 [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector Axel Lin
  2012-03-02  8:22 ` [PATCH 2/3] regulator: max1586: " Axel Lin
  2012-03-02  8:23 ` [PATCH 3/3] regulator: max8660: " Axel Lin
@ 2012-03-02  8:57 ` Zhang, Sonic
  2012-03-02 11:24 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Zhang, Sonic @ 2012-03-02  8:57 UTC (permalink / raw
  To: Axel Lin, linux-kernel@vger.kernel.org; +Cc: Liam Girdwood, Mark Brown

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1320 bytes --]

Acked-by: Sonic Zhang <sonic.zhang@analog.com>

-----Original Message-----
From: Axel Lin [mailto:axel.lin@gmail.com]
Sent: Friday, March 02, 2012 4:21 PM
To: linux-kernel@vger.kernel.org
Cc: Zhang, Sonic; Liam Girdwood; Mark Brown
Subject: [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector

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

diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
index 483c809..26d23ad 100644
--- a/drivers/regulator/ad5398.c
+++ b/drivers/regulator/ad5398.c
@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
        if (max_uA > chip->max_uA || max_uA < chip->min_uA)
                return -EINVAL;

-       selector = ((min_uA - chip->min_uA) * chip->current_level +
-                       range_uA - 1) / range_uA;
+       selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level,
+                               range_uA);
        if (ad5398_calc_current(chip, selector) > max_uA)
                return -EINVAL;

--
1.7.5.4




ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector
  2012-03-02  8:20 [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector Axel Lin
                   ` (2 preceding siblings ...)
  2012-03-02  8:57 ` [PATCH 1/3] regulator: ad5398: " Zhang, Sonic
@ 2012-03-02 11:24 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-03-02 11:24 UTC (permalink / raw
  To: Axel Lin; +Cc: linux-kernel, Sonic Zhang, Liam Girdwood

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

On Fri, Mar 02, 2012 at 04:20:54PM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied all, thanks.

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

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

* Re: [PATCH 2/3] regulator: max1586: Use DIV_ROUND_UP macro to calculate selector
  2012-03-02  8:22 ` [PATCH 2/3] regulator: max1586: " Axel Lin
@ 2012-03-03 11:13   ` Robert Jarzmik
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Jarzmik @ 2012-03-03 11:13 UTC (permalink / raw
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown

Axel Lin <axel.lin@gmail.com> writes:

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

Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

-- 
Robert

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-02  8:20 [PATCH 1/3] regulator: ad5398: Use DIV_ROUND_UP macro to calculate selector Axel Lin
2012-03-02  8:22 ` [PATCH 2/3] regulator: max1586: " Axel Lin
2012-03-03 11:13   ` Robert Jarzmik
2012-03-02  8:23 ` [PATCH 3/3] regulator: max8660: " Axel Lin
2012-03-02  8:57 ` [PATCH 1/3] regulator: ad5398: " Zhang, Sonic
2012-03-02 11:24 ` 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 read-only IMAP folder(s) and NNTP newsgroup(s).