public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: AnilKumar Ch <anilkumar@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>
Subject: [PATCH 1/2] regulator: tps65217: Use DIV_ROUND_UP macro to calculate selector
Date: Tue, 06 Mar 2012 09:54:22 +0800	[thread overview]
Message-ID: <1330998862.3708.1.camel@phoenix> (raw)

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




             reply	other threads:[~2012-03-06  1:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06  1:54 Axel Lin [this message]
2012-03-06  1:56 ` [PATCH 2/2] regulator: wm8400: Use DIV_ROUND_UP macro to calculate selector Axel Lin
2012-03-06 12:17 ` [PATCH 1/2] regulator: tps65217: " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330998862.3708.1.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=anilkumar@ti.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox