All of lore.kernel.org
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 (WIP) 10/16] [Timer]Replace get_timer() usage in driver/mtd and driver/block
Date: Tue, 28 Jun 2011 21:41:03 +1000	[thread overview]
Message-ID: <1309261269-4363-11-git-send-email-graeme.russ@gmail.com> (raw)
In-Reply-To: <1309261269-4363-1-git-send-email-graeme.russ@gmail.com>

This prepares for final removal of reset_timer() from Nios2

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
 drivers/mtd/cfi_flash.c         |   12 ++++++------
 drivers/mtd/nand/nand_base.c    |   17 +++++++++--------
 drivers/mtd/spi/eeprom_m95xxx.c |    6 +++---
 drivers/mtd/spi/spi_flash.c     |    6 +++---
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 3ac6c80..dad80c5 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -563,7 +563,7 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
 static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 			       ulong tout, char *prompt)
 {
-	ulong start;
+	u32 start;
 
 #if CONFIG_SYS_HZ != 1000
 	if ((ulong)CONFIG_SYS_HZ > 100000)
@@ -576,9 +576,9 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 #ifdef CONFIG_NIOS2
 	reset_timer();
 #endif
-	start = get_timer (0);
+	start = time_now_ms();
 	while (flash_is_busy (info, sector)) {
-		if (get_timer (start) > tout) {
+		if (time_since_ms(start) > tout) {
 			printf ("Flash %s timeout at address %lx data %lx\n",
 				prompt, info->start[sector],
 				flash_read_long (info, sector, 0));
@@ -653,7 +653,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 			     ulong tout, char *prompt)
 {
 #ifdef CONFIG_SYS_CFI_FLASH_STATUS_POLL
-	ulong start;
+	u32 start;
 	int ready;
 
 #if CONFIG_SYS_HZ != 1000
@@ -667,7 +667,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 #ifdef CONFIG_NIOS2
 	reset_timer();
 #endif
-	start = get_timer(0);
+	start = time_now_ms();
 	while (1) {
 		switch (info->portwidth) {
 		case FLASH_CFI_8BIT:
@@ -688,7 +688,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 		}
 		if (ready)
 			break;
-		if (get_timer(start) > tout) {
+		if (time_since_ms(start) > tout) {
 			printf("Flash %s timeout at address %lx data %lx\n",
 			       prompt, (ulong)dst, (ulong)flash_read8(dst));
 			return ERR_TIMOUT;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 52f8575..c838695 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -33,6 +33,7 @@
  */
 
 #include <common.h>
+#include <time.h>
 
 #define ENOTSUPP	524	/* Operation is not supported */
 
@@ -439,12 +440,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;
+	u32 start;
 
-	time_start = get_timer(0);
+	start = time_now_ms();
 
 	/* wait until command is processed or timeout occures */
-	while (get_timer(time_start) < timeo) {
+	while (time_since_ms(start) < timeo) {
 		if (chip->dev_ready)
 			if (chip->dev_ready(mtd))
 				break;
@@ -705,7 +706,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
 {
 	unsigned long	timeo;
 	int state = this->state;
-	u32 time_start;
+	u32 start;
 
 	if (state == FL_ERASING)
 		timeo = (CONFIG_SYS_HZ * 400) / 1000;
@@ -717,10 +718,10 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
 	else
 		this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
 
-	time_start = get_timer(0);
+	start = time_now_ms();
 
 	while (1) {
-		if (get_timer(time_start) > timeo) {
+		if (time_since_ms(start) > timeo) {
 			printf("Timeout!");
 			return 0x01;
 		}
@@ -734,8 +735,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this)
 		}
 	}
 #ifdef PPCHAMELON_NAND_TIMER_HACK
-	time_start = get_timer(0);
-	while (get_timer(time_start) < 10)
+	start = time_now_ms();
+	while (time_since_ms(start) < 10)
 		;
 #endif /*  PPCHAMELON_NAND_TIMER_HACK */
 
diff --git a/drivers/mtd/spi/eeprom_m95xxx.c b/drivers/mtd/spi/eeprom_m95xxx.c
index ef8ed6f..16b194c 100644
--- a/drivers/mtd/spi/eeprom_m95xxx.c
+++ b/drivers/mtd/spi/eeprom_m95xxx.c
@@ -75,7 +75,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len)
 {
 	struct spi_slave *slave;
 	char buf[3];
-	ulong start;
+	u32 start;
 
 	slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, 1, 1000000,
 			CONFIG_DEFAULT_SPI_MODE);
@@ -103,7 +103,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len)
 	if(spi_xfer(slave, len * 8, buffer, NULL, SPI_XFER_END))
 		return -1;
 
-	start = get_timer(0);
+	start = time_now_ms();
 	do {
 		buf[0] = SPI_EEPROM_RDSR;
 		buf[1] = 0;
@@ -112,7 +112,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len)
 		if (!(buf[1] & 1))
 			break;
 
-	} while (get_timer(start) < CONFIG_SYS_SPI_WRITE_TOUT);
+	} while (time_since_ms(start) <	CONFIG_SYS_SPI_WRITE_TOUT);
 
 	if (buf[1] & 1)
 		printf ("*** spi_write: Time out while writing!\n");
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 016b586..6e1054d 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -94,7 +94,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
 			   u8 cmd, u8 poll_bit)
 {
 	struct spi_slave *spi = flash->spi;
-	unsigned long timebase;
+	u32 start;
 	int ret;
 	u8 status;
 
@@ -104,7 +104,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
 		return ret;
 	}
 
-	timebase = get_timer(0);
+	start = time_now_ms();
 	do {
 		WATCHDOG_RESET();
 
@@ -115,7 +115,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
 		if ((status & poll_bit) == 0)
 			break;
 
-	} while (get_timer(timebase) < timeout);
+	} while (time_since_ms(start) < timeout);
 
 	spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
 
-- 
1.7.5.2.317.g391b14

  parent reply	other threads:[~2011-06-28 11:41 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28 11:40 [U-Boot] [PATCH v1 (WIP) 00/16] [Timer]API Rewrite Graeme Russ
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 01/16] [Timer]Fix misuse of ARM *timer_masked() functions outside arch/arm Graeme Russ
2011-06-28 12:35   ` Andreas Bießmann
2011-07-11 21:57   ` Wolfgang Denk
2011-07-14 17:01     ` Albert ARIBAUD
2011-07-14 19:50       ` Wolfgang Denk
2011-07-14 23:24         ` Graeme Russ
2011-07-15  6:31           ` Wolfgang Denk
2011-07-15  7:00             ` Graeme Russ
2011-07-15 12:16   ` [U-Boot] [PATCH v2 1/7]Timer: Fix " Graeme Russ
2011-07-16  8:40     ` Albert ARIBAUD
2011-07-16  8:59       ` Graeme Russ
2011-07-16  9:12         ` Albert ARIBAUD
2011-07-16  9:31     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-16  9:58       ` Albert ARIBAUD
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 02/16] [Timer]Remove calls to set_timer outside arch/ Graeme Russ
2011-07-11 21:58   ` Wolfgang Denk
2011-07-15 12:17   ` [U-Boot] [PATCH v2 2/7]Timer: Remove " Graeme Russ
2011-07-16  9:33     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:52       ` Wolfgang Denk
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 03/16] [Timer]Remove calls to set_timer in arch/ Graeme Russ
2011-07-11 21:59   ` Wolfgang Denk
2011-07-15 12:18   ` [U-Boot] [PATCH v2 3/7]Timer: Remove set_timer completely Graeme Russ
2011-07-16  9:34     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:52       ` Wolfgang Denk
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 04/16] [Timer]Allow reset_timer() only for Nios2 Graeme Russ
2011-07-11 22:01   ` Wolfgang Denk
2011-07-15 12:18   ` [U-Boot] [PATCH v2 4/7]Timer: Allow reset_timer() only for systems with low resolution timers Graeme Russ
2011-07-16  9:35     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:53       ` Wolfgang Denk
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 05/16] [Timer]Remove reset_timer() for non-Nios2 arches Graeme Russ
2011-07-11 22:02   ` Wolfgang Denk
2011-07-15  0:01     ` Graeme Russ
2011-07-15 12:19   ` [U-Boot] [PATCH v2 5/7]Timer: Remove " Graeme Russ
2011-07-16  9:36     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:53       ` Wolfgang Denk
2011-08-19 21:24         ` Mike Frysinger
2011-08-19 22:55           ` Graeme Russ
2011-08-19 23:12             ` Mike Frysinger
2011-09-28 19:24           ` Wolfgang Denk
2011-06-28 11:40 ` [U-Boot] [PATCH v1 (WIP) 06/16] [Timer]Fix at91rm9200/spi.c timer usage Graeme Russ
2011-06-28 12:30   ` Andreas Bießmann
2011-07-15 12:20   ` [U-Boot] [PATCH v2 6/7]Timer: Fix " Graeme Russ
2011-07-16  9:37     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:54       ` Wolfgang Denk
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 07/16] [Timer]Remove reset_timer_masked() Graeme Russ
2011-07-11 22:04   ` Wolfgang Denk
2011-07-15 12:21   ` [U-Boot] [PATCH v2 7/7]Timer: Remove reset_timer_masked() Graeme Russ
2011-07-16  9:38     ` [U-Boot] [PATCH v3 " Graeme Russ
2011-07-26 12:54       ` Wolfgang Denk
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 08/16] [Timer]Create new userland timer API Graeme Russ
2011-06-29  4:31   ` Simon Glass
2011-06-29  4:36     ` Graeme Russ
2011-06-29  4:48       ` Simon Glass
2011-07-11 22:05   ` Wolfgang Denk
2011-07-11 22:32     ` Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 09/16] [Timer]Replace get_timer() usage in drivers/block/ Graeme Russ
2011-06-29  4:40   ` Simon Glass
2011-06-29  5:06     ` Reinhard Meyer
2011-06-29  5:19       ` Graeme Russ
2011-06-29  5:30         ` Simon Glass
2011-06-29  5:38           ` Graeme Russ
2011-06-28 11:41 ` Graeme Russ [this message]
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 11/16] [Timer]Remove reset_timer() completely Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 12/16] [Timer]Replace get_timer() usage in drivers/ Graeme Russ
2011-06-28 12:36   ` Vitaly Kuzmichev
2011-06-28 23:03     ` Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 13/16] [Timer]Replace get_timer() usage in net/ Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 14/16] [Timer]Replace get_timer() usage in common/ Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 15/16] [Timer]Replace get_timer() usage in board/ Graeme Russ
2011-06-28 11:41 ` [U-Boot] [PATCH v1 (WIP) 16/16] [Timer]Replace get_timer() usage in arch/ Graeme Russ
2011-06-29  4:45   ` Simon Glass
2011-06-29  4:51     ` Graeme Russ
2011-06-29  5:15       ` Mike Frysinger
2011-06-29  5:26         ` Mike Frysinger
2011-06-29  5:29           ` Graeme Russ
2011-06-29  4:54 ` [U-Boot] [PATCH v1 (WIP) 00/16] [Timer]API Rewrite Graeme Russ
2011-06-29  5:08 ` Mike Frysinger
2011-06-29  5:20   ` Graeme Russ
2011-07-08  0:25 ` Graeme Russ
2011-07-09  6:01   ` Albert ARIBAUD
2011-07-11 21:56 ` Wolfgang Denk
2011-07-11 22:49   ` Graeme Russ
2011-07-11 23:36   ` Graeme Russ
2011-07-12  2:17     ` Graeme Russ
2011-07-12  8:49       ` Wolfgang Denk
2011-07-12 10:36         ` Graeme Russ
2011-07-12 13:10           ` Wolfgang Denk
2011-07-12 15:23             ` Scott McNutt
2011-07-12 17:27               ` J. William Campbell
2011-07-13  0:29             ` Graeme Russ
2011-07-14 19:30               ` Wolfgang Denk
2011-07-17  1:51           ` Graeme Russ
2011-07-12 14:30       ` J. William Campbell
2011-07-12 16:08         ` Reinhard Meyer
2011-07-13  0:33           ` Graeme Russ
2011-07-13  1:20             ` J. William Campbell
2011-07-14 19:41               ` Wolfgang Denk
2011-07-14 23:52                 ` J. William Campbell
2011-07-15  7:17                   ` Wolfgang Denk
2011-07-15 18:08                     ` J. William Campbell
2011-07-15 18:34                       ` Wolfgang Denk
2011-07-15 21:03                         ` J. William Campbell
2011-07-16 14:11                           ` Graeme Russ
2011-07-15 12:15 ` [U-Boot] [PATCH v2 0/7]Timer: Simplify API Graeme Russ
2011-07-15 13:08   ` Graeme Russ
2011-07-16  8:36     ` Albert ARIBAUD
2011-07-16  9:01       ` Graeme Russ
2011-07-16  9:13         ` Albert ARIBAUD
2011-07-16  9:32         ` Wolfgang Denk

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=1309261269-4363-11-git-send-email-graeme.russ@gmail.com \
    --to=graeme.russ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.