* [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector
@ 2012-03-06 1:54 Axel Lin
2012-03-06 1:56 ` [PATCH 2/2] regulator: wm8400: " Axel Lin
2012-03-06 12:17 ` [PATCH 1/2] regulator: tps65217: " Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-06 1:54 UTC (permalink / raw)
To: linux-kernel; +Cc: AnilKumar Ch, Mark Brown, Liam Girdwood
Use DIV_ROUND_UP macro for better readability.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/tps65217-regulator.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 28a10ea..15f2fa0 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -82,11 +82,11 @@ static int tps65217_uv_to_vsel1(int uV, unsigned int *vsel)
return -EINVAL;
if (uV <= 1500000)
- *vsel = (uV - 875001) / 25000;
+ *vsel = DIV_ROUND_UP(uV - 900000, 25000);
else if (uV <= 2900000)
- *vsel = 24 + (uV - 1450001) / 50000;
+ *vsel = 24 + DIV_ROUND_UP(uV - 1500000, 50000);
else if (uV < 3300000)
- *vsel = 52 + (uV - 2800001) / 100000;
+ *vsel = 52 + DIV_ROUND_UP(uV - 2900000, 100000);
else
*vsel = 56;
@@ -116,11 +116,11 @@ static int tps65217_uv_to_vsel2(int uV, unsigned int *vsel)
return -EINVAL;
if (uV <= 1900000)
- *vsel = (uV - 1450001) / 50000;
+ *vsel = DIV_ROUND_UP(uV - 1500000, 50000);
else if (uV <= 2400000)
- *vsel = 8 + (uV - 1800001) / 100000;
+ *vsel = 8 + DIV_ROUND_UP(uV - 1900000, 100000);
else
- *vsel = 13 + (uV - 2350001) / 50000;
+ *vsel = 13 + DIV_ROUND_UP(uV - 2400000, 50000);
return 0;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] regulator: wm8400: Use DIV_ROUND_UP macro to calculate selector
2012-03-06 1:54 [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector Axel Lin
@ 2012-03-06 1:56 ` Axel Lin
2012-03-06 12:17 ` [PATCH 1/2] regulator: tps65217: " Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-06 1:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood
Use DIV_ROUND_UP macro for better readability.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/wm8400-regulator.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 706f395..8477153 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -78,14 +78,14 @@ static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
if (min_uV < 1700000) {
/* Steps of 50mV from 900mV; */
- val = (min_uV - 850001) / 50000;
+ val = DIV_ROUND_UP(min_uV - 900000, 50000);
if ((val * 50000) + 900000 > max_uV)
return -EINVAL;
BUG_ON((val * 50000) + 900000 < min_uV);
} else {
/* Steps of 100mV from 1700mV */
- val = ((min_uV - 1600001) / 100000);
+ val = DIV_ROUND_UP(min_uV - 1700000, 100000);
if ((val * 100000) + 1700000 > max_uV)
return -EINVAL;
@@ -168,7 +168,7 @@ static int wm8400_dcdc_set_voltage(struct regulator_dev *dev,
if (min_uV < 850000)
return -EINVAL;
- val = (min_uV - 825001) / 25000;
+ val = DIV_ROUND_UP(min_uV - 850000, 25000);
if (850000 + (25000 * val) > max_uV)
return -EINVAL;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector
2012-03-06 1:54 [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector Axel Lin
2012-03-06 1:56 ` [PATCH 2/2] regulator: wm8400: " Axel Lin
@ 2012-03-06 12:17 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-03-06 12:17 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, AnilKumar Ch, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 130 bytes --]
On Tue, Mar 06, 2012 at 09:54:22AM +0800, Axel Lin wrote:
> Use DIV_ROUND_UP macro for better readability.
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-06 12:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 1:54 [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector Axel Lin
2012-03-06 1:56 ` [PATCH 2/2] regulator: wm8400: " Axel Lin
2012-03-06 12:17 ` [PATCH 1/2] regulator: tps65217: " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox