From patchwork Wed Oct 7 09:31:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enrico Scholz X-Patchwork-Id: 35255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CA11DB7B79 for ; Wed, 7 Oct 2009 20:34:34 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MvSsc-0001V3-Jh; Wed, 07 Oct 2009 09:32:18 +0000 Received: from mail.cvg.de ([62.153.82.30]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MvSsV-0001UD-I1; Wed, 07 Oct 2009 09:32:16 +0000 Received: from ensc-virt.intern.sigma-chemnitz.de (ensc-virt.intern.sigma-chemnitz.de [192.168.3.24]) by mail.cvg.de (8.14.3/8.14.3) with ESMTP id n979Vh3E007761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Oct 2009 11:31:43 +0200 Received: from ensc by ensc-virt.intern.sigma-chemnitz.de with local (Exim 4.69) (envelope-from ) id 1MvSs3-00034k-K5; Wed, 07 Oct 2009 11:31:43 +0200 From: Enrico Scholz To: linux-mtd@lists.infradead.org Subject: [PATCH] pxa3xx_nand: fix time calculation Date: Wed, 7 Oct 2009 11:31:43 +0200 Message-Id: <1254907903-11797-1-git-send-email-enrico.scholz@sigma-chemnitz.de> X-Mailer: git-send-email 1.6.2.5 X-Spam-Score: -1.9 X-Spam-Level: - X-Spam-Tests: AWL,BAYES_00,SPF_NEUTRAL X-Scanned-By: MIMEDefang 2.67 on 62.153.82.30 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091007_053211_910179_E28A6540 X-CRM114-Status: GOOD ( 10.00 ) X-Spam-Score: -4.0 (----) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (-4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [62.153.82.30 listed in list.dnswl.org] Cc: eric.y.miao@gmail.com, mreimer@vpop.net, dwmw2@infradead.org, Enrico Scholz X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- 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))