Joe's suggestion, put jiffies_to_usecs in time.h and make it smarter
about HZ values math.
Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxx>
diff -Nru a/include/linux/time.h b/include/linux/time.h
--- a/include/linux/time.h 2004-09-27 13:22:41 -07:00
+++ b/include/linux/time.h 2004-09-27 13:22:41 -07:00
@@ -194,6 +194,18 @@
return (j * 1000) / HZ;
#endif
}
+
+static inline unsigned int jiffies_to_usecs(const unsigned long j)
+{
+#if HZ <= 1000 && !(1000 % HZ)
+ return (1000000 / HZ) * j;
+#elif HZ > 1000 && !(HZ % 1000)
+ return (j*1000 + (HZ - 1000))/(HZ / 1000);
+#else
+ return (j * 1000000) / HZ;
+#endif
+}
+
static inline unsigned long msecs_to_jiffies(const unsigned int m)
{
#if HZ <= 1000 && !(1000 % HZ)
diff -Nru a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
--- a/net/ipv4/tcp_diag.c 2004-09-27 13:22:41 -07:00
+++ b/net/ipv4/tcp_diag.c 2004-09-27 13:22:41 -07:00
@@ -41,12 +41,6 @@
rta->rta_len = rtalen; \
RTA_DATA(rta); })
-static inline unsigned int jiffies_to_usecs(const unsigned long j)
-{
- return 1000*jiffies_to_msecs(j);
-}
-
-
/* Return information about state of tcp endpoint in API format. */
void tcp_get_info(struct sock *sk, struct tcp_info *info)
{
|