public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] pxa3xx_nand: fix time calculation
@ 2009-10-07  9:31 Enrico Scholz
  2009-10-11 12:51 ` Artem Bityutskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Enrico Scholz @ 2009-10-07  9:31 UTC (permalink / raw)
  To: linux-mtd; +Cc: eric.y.miao, mreimer, dwmw2, Enrico Scholz

Use DIV_ROUND_UP to calculate number of clocks.  Else, calculated clocks
are nearly always to low and for times < 10ns, they will be negative on
PXA320  (which has a nand clock of 104 MHz).

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 drivers/mtd/nand/pxa3xx_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 6ea520a..32cb4d1 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -316,7 +316,7 @@ static struct pxa3xx_nand_flash *builtin_flash_types[] = {
 #define tAR_NDTR1(r)	(((r) >> 0) & 0xf)
 
 /* convert nano-seconds to nand flash controller clock cycles */
-#define ns2cycle(ns, clk)	(int)(((ns) * (clk / 1000000) / 1000) - 1)
+#define ns2cycle(ns, clk)	(int)(DIV_ROUND_UP((ns) * (clk / 1000000), 1000) - 1)
 
 /* convert nand flash controller clock cycles to nano-seconds */
 #define cycle2ns(c, clk)	((((c) + 1) * 1000000 + clk / 500) / (clk / 1000))
-- 
1.6.2.5

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

end of thread, other threads:[~2009-10-12 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07  9:31 [PATCH] pxa3xx_nand: fix time calculation Enrico Scholz
2009-10-11 12:51 ` Artem Bityutskiy
2009-10-12  3:22   ` Eric Miao
2009-10-12 10:03     ` Enrico Scholz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox