diff mbox

[U-Boot,v1,(WIP),13/16,Timer] Replace get_timer() usage in net/

Message ID 1309261269-4363-14-git-send-email-graeme.russ@gmail.com
State RFC
Headers show

Commit Message

Graeme Russ June 28, 2011, 11:41 a.m. UTC
Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
 net/bootp.c |    6 +++---
 net/net.c   |   18 +++++++-----------
 net/sntp.c  |    2 +-
 net/tftp.c  |    4 ++--
 4 files changed, 13 insertions(+), 17 deletions(-)
diff mbox

Patch

diff --git a/net/bootp.c b/net/bootp.c
index 4db63cb..8c9560d 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -637,7 +637,7 @@  BootpRequest (void)
 	bp->bp_htype = HWT_ETHER;
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
-	bp->bp_secs = htons(get_timer(0) / 1000);
+	bp->bp_secs = htons(time_ms_now() / 1000);
 	NetWriteIP(&bp->bp_ciaddr, 0);
 	NetWriteIP(&bp->bp_yiaddr, 0);
 	NetWriteIP(&bp->bp_siaddr, 0);
@@ -660,7 +660,7 @@  BootpRequest (void)
 		| ((ulong)NetOurEther[3] << 16)
 		| ((ulong)NetOurEther[4] << 8)
 		| (ulong)NetOurEther[5];
-	BootpID += get_timer(0);
+	BootpID += time_now_ms();
 	BootpID	 = htonl(BootpID);
 	NetCopyLong(&bp->bp_id, &BootpID);
 
@@ -819,7 +819,7 @@  static void DhcpSendRequestPkt(Bootp_t *bp_offer)
 	bp->bp_htype = HWT_ETHER;
 	bp->bp_hlen = HWL_ETHER;
 	bp->bp_hops = 0;
-	bp->bp_secs = htons(get_timer(0) / 1000);
+	bp->bp_secs = htons(time_ms_now() / 1000);
 	/* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by
 	 * the server yet */
 
diff --git a/net/net.c b/net/net.c
index 7a60583..b574481 100644
--- a/net/net.c
+++ b/net/net.c
@@ -290,15 +290,11 @@  void ArpRequest(void)
 
 void ArpTimeoutCheck(void)
 {
-	ulong t;
-
 	if (!NetArpWaitPacketIP)
 		return;
 
-	t = get_timer(0);
-
 	/* check for arp timeout */
-	if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) {
+	if (time_since_ms(NetArpWaitTimerStart) > ARP_TIMEOUT) {
 		NetArpWaitTry++;
 
 		if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
@@ -306,7 +302,7 @@  void ArpTimeoutCheck(void)
 			NetArpWaitTry = 0;
 			NetStartAgain();
 		} else {
-			NetArpWaitTimerStart = t;
+			NetArpWaitTimerStart = time_now_ms();
 			ArpRequest();
 		}
 	}
@@ -535,7 +531,7 @@  restart:
 		 *	Check for a timeout, and run the timeout handler
 		 *	if we have one.
 		 */
-		if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) {
+		if (timeHandler && (time_since_ms(timeStart) > timeDelta)) {
 			thand_f *x;
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
@@ -672,7 +668,7 @@  NetSetTimeout(ulong iv, thand_f *f)
 		timeHandler = (thand_f *)0;
 	} else {
 		timeHandler = f;
-		timeStart = get_timer(0);
+		timeStart = time_now_ms();
 		timeDelta = iv;
 	}
 }
@@ -721,7 +717,7 @@  NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
 
 		/* and do the ARP request */
 		NetArpWaitTry = 1;
-		NetArpWaitTimerStart = get_timer(0);
+		NetArpWaitTimerStart = time_now_ms();
 		ArpRequest();
 		return 1;	/* waiting */
 	}
@@ -792,7 +788,7 @@  int PingSend(void)
 
 	/* and do the ARP request */
 	NetArpWaitTry = 1;
-	NetArpWaitTimerStart = get_timer(0);
+	NetArpWaitTimerStart = time_now_ms();
 	ArpRequest();
 	return 1;	/* waiting */
 }
@@ -1960,7 +1956,7 @@  void copy_filename(char *dst, const char *src, int size)
  */
 unsigned int random_port(void)
 {
-	return 1024 + (get_timer(0) % 0x4000);
+	return 1024 + (time_now_ms() % 0x4000);
 }
 #endif
 
diff --git a/net/sntp.c b/net/sntp.c
index 82f2fe6..5bd2425 100644
--- a/net/sntp.c
+++ b/net/sntp.c
@@ -33,7 +33,7 @@  SntpSend (void)
 
 	memcpy ((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, (char *)&pkt, pktlen);
 
-	SntpOurPort = 10000 + (get_timer(0) % 4096);
+	SntpOurPort = 10000 + (time_now_ms() % 4096);
 	sport = NTP_SERVICE_PORT;
 
 	NetSendUDPPacket (NetServerEther, NetNtpServerIP, sport, SntpOurPort, pktlen);
diff --git a/net/tftp.c b/net/tftp.c
index a893e02..52a5ddc 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -338,7 +338,7 @@  TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
 		debug("Got WRQ\n");
 		TftpRemoteIP = sip;
 		TftpRemotePort = src;
-		TftpOurPort = 1024 + (get_timer(0) % 3072);
+		TftpOurPort = 1024 + (time_ms_now() % 3072);
 		TftpLastBlock = 0;
 		TftpBlockWrap = 0;
 		TftpBlockWrapOffset = 0;
@@ -654,7 +654,7 @@  TftpStart(void)
 	TftpTimeoutCount = 0;
 	TftpState = STATE_SEND_RRQ;
 	/* Use a pseudo-random port unless a specific port is set */
-	TftpOurPort = 1024 + (get_timer(0) % 3072);
+	TftpOurPort = 1024 + (time_now_ms() % 3072);
 
 #ifdef CONFIG_TFTP_PORT
 	ep = getenv("tftpdstp");