From: Daniel Mack <daniel@caiaq.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] net/net.c: add get_timer_ms()
Date: Fri, 5 Dec 2008 15:40:31 +0100 [thread overview]
Message-ID: <20081205144031.GB1821@buzzloop.caiaq.de> (raw)
In-Reply-To: <4938CECF.6090901@gmail.com>
Make timeout implementation in net/net.c take into account the
CONFIG_SYS_HZ variable. This is needed for all CPUs where the default
timer is running on anything else than 1000.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
net/net.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/net/net.c b/net/net.c
index 77e83b5..1c48236 100644
--- a/net/net.c
+++ b/net/net.c
@@ -206,6 +206,11 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
ulong NetArpWaitTimerStart;
int NetArpWaitTry;
+static long get_timer_ms(long base)
+{
+ return get_timer(base) / (CONFIG_SYS_HZ / 1000);
+}
+
void ArpRequest (void)
{
int i;
@@ -256,7 +261,7 @@ void ArpTimeoutCheck(void)
if (!NetArpWaitPacketIP)
return;
- t = get_timer(0);
+ t = get_timer_ms(0);
/* check for arp timeout */
if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) {
@@ -517,7 +522,7 @@ restart:
* Check for a timeout, and run the timeout handler
* if we have one.
*/
- if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) {
+ if (timeHandler && ((get_timer_ms(0) - timeStart) > timeDelta)) {
thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
@@ -639,7 +644,7 @@ NetSetTimeout(ulong iv, thand_f * f)
timeHandler = (thand_f *)0;
} else {
timeHandler = f;
- timeStart = get_timer(0);
+ timeStart = get_timer_ms(0);
timeDelta = iv;
}
}
@@ -684,7 +689,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 = get_timer_ms(0);
ArpRequest();
return 1; /* waiting */
}
@@ -755,7 +760,7 @@ int PingSend(void)
/* and do the ARP request */
NetArpWaitTry = 1;
- NetArpWaitTimerStart = get_timer(0);
+ NetArpWaitTimerStart = get_timer_ms(0);
ArpRequest();
return 1; /* waiting */
}
--
1.5.6.5
next prev parent reply other threads:[~2008-12-05 14:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-28 16:25 [U-Boot] [PATCH] net/net.c: correct timeout function Daniel Mack
2008-12-03 0:31 ` Daniel Mack
2008-12-03 0:43 ` Ben Warren
2008-12-03 1:05 ` Daniel Mack
2008-12-03 17:57 ` Ben Warren
2008-12-03 0:58 ` Daniel Mack
2008-12-05 6:48 ` Ben Warren
2008-12-05 14:40 ` Daniel Mack [this message]
2008-12-05 20:26 ` [U-Boot] [PATCH] net/net.c: add get_timer_ms() Wolfgang Denk
2008-12-05 20:43 ` Daniel Mack
2008-12-05 21:01 ` Wolfgang Denk
2008-12-05 21:07 ` Daniel Mack
2008-12-05 21:16 ` Wolfgang Denk
2008-12-06 16:53 ` Daniel Mack
2008-12-05 20:29 ` [U-Boot] [PATCH] net/net.c: correct timeout function Wolfgang Denk
2008-12-05 21:01 ` Ben Warren
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=20081205144031.GB1821@buzzloop.caiaq.de \
--to=daniel@caiaq.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox