diff options
author | Patrick McHardy <kaber@trash.net> | 2006-01-08 22:12:03 -0800 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-09 14:16:05 -0800 |
commit | 538e43a4bd36ae49873ef7097a16a207f5d9912b (patch) | |
tree | 11a7a9ea4594993c559a247d6ff373dc00b77e1c | |
parent | 2941a4863154982918d39a639632c76eeacfa884 (diff) | |
download | op-kernel-dev-538e43a4bd36ae49873ef7097a16a207f5d9912b.zip op-kernel-dev-538e43a4bd36ae49873ef7097a16a207f5d9912b.tar.gz |
[PKT_SCHED]: Use USEC_PER_SEC
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/pkt_sched.h | 23 | ||||
-rw-r--r-- | net/sched/sch_hfsc.c | 8 |
2 files changed, 16 insertions, 15 deletions
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 6492e73..b94d1ad 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -1,6 +1,7 @@ #ifndef __NET_PKT_SCHED_H #define __NET_PKT_SCHED_H +#include <linux/jiffies.h> #include <net/sch_generic.h> struct qdisc_walker @@ -59,8 +60,8 @@ typedef struct timeval psched_time_t; typedef long psched_tdiff_t; #define PSCHED_GET_TIME(stamp) do_gettimeofday(&(stamp)) -#define PSCHED_US2JIFFIE(usecs) (((usecs)+(1000000/HZ-1))/(1000000/HZ)) -#define PSCHED_JIFFIE2US(delay) ((delay)*(1000000/HZ)) +#define PSCHED_US2JIFFIE(usecs) usecs_to_jiffies(usecs) +#define PSCHED_JIFFIE2US(delay) jiffies_to_usecs(delay) #else /* !CONFIG_NET_SCH_CLK_GETTIMEOFDAY */ @@ -123,9 +124,9 @@ do { \ default: \ __delta = 0; \ case 2: \ - __delta += 1000000; \ + __delta += USEC_PER_SEC; \ case 1: \ - __delta += 1000000; \ + __delta += USEC_PER_SEC; \ } \ } \ __delta; \ @@ -136,9 +137,9 @@ psched_tod_diff(int delta_sec, int bound) { int delta; - if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1) + if (bound <= USEC_PER_SEC || delta_sec > (0x7FFFFFFF/USEC_PER_SEC)-1) return bound; - delta = delta_sec * 1000000; + delta = delta_sec * USEC_PER_SEC; if (delta > bound || delta < 0) delta = bound; return delta; @@ -152,9 +153,9 @@ psched_tod_diff(int delta_sec, int bound) default: \ __delta = psched_tod_diff(__delta_sec, bound); break; \ case 2: \ - __delta += 1000000; \ + __delta += USEC_PER_SEC; \ case 1: \ - __delta += 1000000; \ + __delta += USEC_PER_SEC; \ case 0: \ if (__delta > bound || __delta < 0) \ __delta = bound; \ @@ -170,15 +171,15 @@ psched_tod_diff(int delta_sec, int bound) ({ \ int __delta = (tv).tv_usec + (delta); \ (tv_res).tv_sec = (tv).tv_sec; \ - if (__delta > 1000000) { (tv_res).tv_sec++; __delta -= 1000000; } \ + if (__delta > USEC_PER_SEC) { (tv_res).tv_sec++; __delta -= USEC_PER_SEC; } \ (tv_res).tv_usec = __delta; \ }) #define PSCHED_TADD(tv, delta) \ ({ \ (tv).tv_usec += (delta); \ - if ((tv).tv_usec > 1000000) { (tv).tv_sec++; \ - (tv).tv_usec -= 1000000; } \ + if ((tv).tv_usec > USEC_PER_SEC) { (tv).tv_sec++; \ + (tv).tv_usec -= USEC_PER_SEC; } \ }) /* Set/check that time is in the "past perfect"; diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index c26764b..cad1758 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -208,7 +208,7 @@ struct hfsc_sched do { \ struct timeval tv; \ do_gettimeofday(&tv); \ - (stamp) = 1000000ULL * tv.tv_sec + tv.tv_usec; \ + (stamp) = 1ULL * USEC_PER_SEC * tv.tv_sec + tv.tv_usec; \ } while (0) #endif @@ -502,8 +502,8 @@ d2dx(u32 d) u64 dx; dx = ((u64)d * PSCHED_JIFFIE2US(HZ)); - dx += 1000000 - 1; - do_div(dx, 1000000); + dx += USEC_PER_SEC - 1; + do_div(dx, USEC_PER_SEC); return dx; } @@ -523,7 +523,7 @@ dx2d(u64 dx) { u64 d; - d = dx * 1000000; + d = dx * USEC_PER_SEC; do_div(d, PSCHED_JIFFIE2US(HZ)); return (u32)d; } |