From patchwork Tue May 24 10:54:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 97143 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 B9892B6FAA for ; Tue, 24 May 2011 20:54:27 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A818B280E6; Tue, 24 May 2011 12:54:23 +0200 (CEST) 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 bkP-mSuHUcR8; Tue, 24 May 2011 12:54:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3621280DE; Tue, 24 May 2011 12:54:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D159280DE for ; Tue, 24 May 2011 12:54:17 +0200 (CEST) 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 VFwN8W0iHntm for ; Tue, 24 May 2011 12:54:13 +0200 (CEST) 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 mail-pv0-f172.google.com (mail-pv0-f172.google.com [74.125.83.172]) by theia.denx.de (Postfix) with ESMTPS id 0874A280DC for ; Tue, 24 May 2011 12:54:11 +0200 (CEST) Received: by pvh18 with SMTP id 18so3209763pvh.3 for ; Tue, 24 May 2011 03:54:07 -0700 (PDT) Received: by 10.68.31.104 with SMTP id z8mr2927207pbh.220.1306234447666; Tue, 24 May 2011 03:54:07 -0700 (PDT) Received: from localhost.localdomain (d122-104-32-171.sbr6.nsw.optusnet.com.au [122.104.32.171]) by mx.google.com with ESMTPS id n3sm2062189pbh.16.2011.05.24.03.54.05 (version=SSLv3 cipher=OTHER); Tue, 24 May 2011 03:54:06 -0700 (PDT) From: Graeme Russ To: u-boot@lists.denx.de Date: Tue, 24 May 2011 20:54:00 +1000 Message-Id: <1306234440-3486-1-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.5.2.317.g391b14 In-Reply-To: <1306151649-25640-1-git-send-email-graeme.russ@gmail.com> References: <1306151649-25640-1-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [PATCH] [Timer]Remove calls to [get, reset]_timer outside arch/ 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 There is no need to use set_timer() and reset_timer() and there are build breakages occuring because of them (specifically cfi_flash). Remove any usage outside arch/ to fix build breakages and to prepare for complete removal The Nios2 timer implentation updates every 10ms (increases in 10ms steps) and required a reset_timer() call before timing operations. For Nios2, call reset_timer() when get_timer() is called with a parameter value of 0 Signed-off-by: Graeme Russ --- checkpatch complains about long lines and brace usage in the board specific flash.c files - They are deprecated and not worth fixing for style Changes since V1: - Fix typo in commit message - Add reset_timer() to Nios2 get_timer(0) --- arch/nios2/cpu/interrupts.c | 4 ++++ board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/cobra5272/flash.c | 10 ++++++---- board/idmr/flash.c | 10 ++++++---- drivers/block/mg_disk.c | 1 - drivers/mtd/cfi_flash.c | 2 -- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index 63acfa9..4e027f1 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -95,6 +95,10 @@ void reset_timer (void) ulong get_timer (ulong base) { WATCHDOG_RESET (); + + if (base == 0) + reset_timer(); + return (timestamp - base); } diff --git a/board/BuS/EB+MCF-EV123/flash.c b/board/BuS/EB+MCF-EV123/flash.c index 3c36367..8b7f957 100644 --- a/board/BuS/EB+MCF-EV123/flash.c +++ b/board/BuS/EB+MCF-EV123/flash.c @@ -157,6 +157,7 @@ int amd_flash_erase_sector(flash_info_t * info, int sector) { int state; ulong result; + ulong start; volatile u16 *addr = (volatile u16 *) (info->start[sector]); @@ -171,13 +172,13 @@ int amd_flash_erase_sector(flash_info_t * info, int sector) /* wait until flash is ready */ state = 0; - set_timer (0); + start = get_timer(0); do { result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; state = ERR_TIMOUT; } @@ -267,6 +268,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) ulong result; int cflag, iflag; int state; + ulong start; /* * Check if Flash is (sufficiently) erased @@ -295,7 +297,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) *addr = data; /* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0); /* wait until flash is ready */ state = 0; @@ -303,7 +305,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { state = ERR_TIMOUT; } if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK))) diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 33c9361..e8f02eb 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -147,6 +147,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start; /* first look for protection bits */ @@ -190,7 +191,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect); /* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0); if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -211,7 +212,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -264,6 +265,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start; /* * Check if Flash is (sufficiently) erased @@ -291,7 +293,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data; /* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0); /* wait until flash is ready */ chip1 = 0; @@ -299,7 +301,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/idmr/flash.c b/board/idmr/flash.c index 57c9948..9f4ff2b 100644 --- a/board/idmr/flash.c +++ b/board/idmr/flash.c @@ -130,6 +130,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start; /* first look for protection bits */ @@ -170,7 +171,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect); /* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0); if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -191,7 +192,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -248,6 +249,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int iflag; int chip1; + ulong start; /* * Check if Flash is (sufficiently) erased @@ -272,7 +274,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data; /* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0); /* wait until flash is ready */ chip1 = 0; @@ -280,7 +282,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr; /* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { chip1 = ERR | TMO; break; } diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index b74307a..7609557 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,7 +91,6 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 from, cur, err; err = MG_ERR_NONE; - reset_timer(); from = get_timer(0); status = readb(mg_base() + MG_REG_STATUS); diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 5788328..ea5e1f2 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -573,7 +573,6 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #endif /* Wait for command completion */ - reset_timer(); start = get_timer (0); while (flash_is_busy (info, sector)) { if (get_timer (start) > tout) { @@ -660,7 +659,6 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #endif /* Wait for command completion */ - reset_timer(); start = get_timer(0); while (1) { switch (info->portwidth) {