From patchwork Thu Nov 18 13:14:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Meyer X-Patchwork-Id: 72087 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BAABDB71B1 for ; Fri, 19 Nov 2010 00:03:36 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 109982834D; Thu, 18 Nov 2010 14:03:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k5-LPuNxMuLU; Thu, 18 Nov 2010 14:03:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59A1E28352; Thu, 18 Nov 2010 14:03:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 177E328352 for ; Thu, 18 Nov 2010 14:03:32 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AfkN-GhyKcZe for ; Thu, 18 Nov 2010 14:03:30 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by theia.denx.de (Postfix) with ESMTP id 090862834D for ; Thu, 18 Nov 2010 14:03:28 +0100 (CET) Received: from localhost.localdomain (p5B20026F.dip0.t-ipconnect.de [91.32.2.111]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0LuHCt-1OIogt2nwd-011J15; Thu, 18 Nov 2010 14:03:25 +0100 From: Reinhard Meyer To: u-boot@lists.denx.de Date: Thu, 18 Nov 2010 14:14:26 +0100 Message-Id: <1290086066-21472-1-git-send-email-u-boot@emk-elektronik.de> X-Mailer: git-send-email 1.5.6.5 X-Provags-ID: V02:K0:euZxivhbhHMS9+RC2npLcXymQzXdsDaSVM7HXpCTY+P RdjBj6EzIapdx9Y6rPwQFeBewwIP6t0Bdf6z6badCZVjrgdUAB mqKZA/iuBZoTc14f7ofXBGpBDqJPo6LpcB13xz+MG8wwxoCm64 r41KHh5O7dUBl+nr7yt1T03qPyueA62lP+P7mJuV0qa/cwER+z coBlkInlSWrI6e7cFwfIMvkBLrnR1FUcIy8bKVhJOs= Subject: [U-Boot] [PATCH] MTD/NAND: fix nand_base.c to use get_timer() correctly X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This is part of the timer cleanup effort. In the future we only use get_timer() in its intended way to program timeout loops. reset_timer() shall not be used anymore. Signed-off-by: Reinhard Meyer --- drivers/mtd/nand/nand_base.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 21cc5a3..3dcef97 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -439,11 +439,12 @@ void nand_wait_ready(struct mtd_info *mtd) { struct nand_chip *chip = mtd->priv; u32 timeo = (CONFIG_SYS_HZ * 20) / 1000; + u32 time_start; - reset_timer(); + time_start = get_timer(0); /* wait until command is processed or timeout occures */ - while (get_timer(0) < timeo) { + while (get_timer(time_start) < timeo) { if (chip->dev_ready) if (chip->dev_ready(mtd)) break; @@ -704,6 +705,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) { unsigned long timeo; int state = this->state; + u32 time_start; if (state == FL_ERASING) timeo = (CONFIG_SYS_HZ * 400) / 1000; @@ -715,10 +717,10 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) else this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); - reset_timer(); + time_start = get_timer(0); while (1) { - if (get_timer(0) > timeo) { + if (get_timer(time_start) > timeo) { printf("Timeout!"); return 0x01; } @@ -732,8 +734,9 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) } } #ifdef PPCHAMELON_NAND_TIMER_HACK - reset_timer(); - while (get_timer(0) < 10); + time_start = get_timer(0); + while (get_timer(time_start) < 10) + ; #endif /* PPCHAMELON_NAND_TIMER_HACK */ return this->read_byte(mtd);