mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Wolfram Sang <w.sang@pengutronix.de>
Subject: [PATCH V2 1/8] arm: mxs: make get_hclk result useable for upcoming set_hclk
Date: Thu, 14 Jun 2012 15:20:58 +0200	[thread overview]
Message-ID: <1339680065-12169-2-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1339680065-12169-1-git-send-email-w.sang@pengutronix.de>

To avoid getting a different divider due to rounding errors when using
set_hclk later, use DIV_ROUND_UP for the returned value.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 arch/arm/mach-mxs/speed-imx23.c |    5 +++--
 arch/arm/mach-mxs/speed-imx28.c |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-mxs/speed-imx23.c b/arch/arm/mach-mxs/speed-imx23.c
index b10c786..c9ca7ac 100644
--- a/arch/arm/mach-mxs/speed-imx23.c
+++ b/arch/arm/mach-mxs/speed-imx23.c
@@ -184,9 +184,10 @@ unsigned imx_get_hclk(void)
 
 	if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) {
 		rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f;
-		rate >>= 5U; /* / 32 */
+		rate = DIV_ROUND_UP(rate, 32);
 	} else
-		rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f;
+		rate = DIV_ROUND_UP(rate,
+			readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f);
 	return rate * 1000;
 }
 
diff --git a/arch/arm/mach-mxs/speed-imx28.c b/arch/arm/mach-mxs/speed-imx28.c
index 67cdbdf..4f4db1b 100644
--- a/arch/arm/mach-mxs/speed-imx28.c
+++ b/arch/arm/mach-mxs/speed-imx28.c
@@ -251,9 +251,10 @@ unsigned imx_get_hclk(void)
 
 	if (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x20) {
 		rate *= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f;
-		rate /= 32;
+		rate = DIV_ROUND_UP(rate, 32);
 	} else
-		rate /= readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f;
+		rate = DIV_ROUND_UP(rate,
+			readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & 0x1f);
 	return rate * 1000;
 }
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-06-14 13:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 13:20 [PATCH V2 0/8] arm: mxs: add ocotp write support Wolfram Sang
2012-06-14 13:20 ` Wolfram Sang [this message]
2012-06-14 13:20 ` [PATCH V2 2/8] arm: mxs: add imx_set_hclk Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 3/8] arm: mxs: refactor access to power domain Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 4/8] arm: mxs: add POWER_BASE for MX28, too Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 5/8] arm: mxs: add functions to get/set vddio Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 6/8] arm: mxs: refactor timeout routine for ocotp Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 7/8] arm: mxs: use consistent naming for #defines " Wolfram Sang
2012-06-14 13:21 ` [PATCH V2 8/8] arm: mxs: add write support " Wolfram Sang

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=1339680065-12169-2-git-send-email-w.sang@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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