Commit 538e43a4 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[PKT_SCHED]: Use USEC_PER_SEC

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2941a486
#ifndef __NET_PKT_SCHED_H #ifndef __NET_PKT_SCHED_H
#define __NET_PKT_SCHED_H #define __NET_PKT_SCHED_H
#include <linux/jiffies.h>
#include <net/sch_generic.h> #include <net/sch_generic.h>
struct qdisc_walker struct qdisc_walker
...@@ -59,8 +60,8 @@ typedef struct timeval psched_time_t; ...@@ -59,8 +60,8 @@ typedef struct timeval psched_time_t;
typedef long psched_tdiff_t; typedef long psched_tdiff_t;
#define PSCHED_GET_TIME(stamp) do_gettimeofday(&(stamp)) #define PSCHED_GET_TIME(stamp) do_gettimeofday(&(stamp))
#define PSCHED_US2JIFFIE(usecs) (((usecs)+(1000000/HZ-1))/(1000000/HZ)) #define PSCHED_US2JIFFIE(usecs) usecs_to_jiffies(usecs)
#define PSCHED_JIFFIE2US(delay) ((delay)*(1000000/HZ)) #define PSCHED_JIFFIE2US(delay) jiffies_to_usecs(delay)
#else /* !CONFIG_NET_SCH_CLK_GETTIMEOFDAY */ #else /* !CONFIG_NET_SCH_CLK_GETTIMEOFDAY */
...@@ -123,9 +124,9 @@ do { \ ...@@ -123,9 +124,9 @@ do { \
default: \ default: \
__delta = 0; \ __delta = 0; \
case 2: \ case 2: \
__delta += 1000000; \ __delta += USEC_PER_SEC; \
case 1: \ case 1: \
__delta += 1000000; \ __delta += USEC_PER_SEC; \
} \ } \
} \ } \
__delta; \ __delta; \
...@@ -136,9 +137,9 @@ psched_tod_diff(int delta_sec, int bound) ...@@ -136,9 +137,9 @@ psched_tod_diff(int delta_sec, int bound)
{ {
int delta; int delta;
if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1) if (bound <= USEC_PER_SEC || delta_sec > (0x7FFFFFFF/USEC_PER_SEC)-1)
return bound; return bound;
delta = delta_sec * 1000000; delta = delta_sec * USEC_PER_SEC;
if (delta > bound || delta < 0) if (delta > bound || delta < 0)
delta = bound; delta = bound;
return delta; return delta;
...@@ -152,9 +153,9 @@ psched_tod_diff(int delta_sec, int bound) ...@@ -152,9 +153,9 @@ psched_tod_diff(int delta_sec, int bound)
default: \ default: \
__delta = psched_tod_diff(__delta_sec, bound); break; \ __delta = psched_tod_diff(__delta_sec, bound); break; \
case 2: \ case 2: \
__delta += 1000000; \ __delta += USEC_PER_SEC; \
case 1: \ case 1: \
__delta += 1000000; \ __delta += USEC_PER_SEC; \
case 0: \ case 0: \
if (__delta > bound || __delta < 0) \ if (__delta > bound || __delta < 0) \
__delta = bound; \ __delta = bound; \
...@@ -170,15 +171,15 @@ psched_tod_diff(int delta_sec, int bound) ...@@ -170,15 +171,15 @@ psched_tod_diff(int delta_sec, int bound)
({ \ ({ \
int __delta = (tv).tv_usec + (delta); \ int __delta = (tv).tv_usec + (delta); \
(tv_res).tv_sec = (tv).tv_sec; \ (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; \ (tv_res).tv_usec = __delta; \
}) })
#define PSCHED_TADD(tv, delta) \ #define PSCHED_TADD(tv, delta) \
({ \ ({ \
(tv).tv_usec += (delta); \ (tv).tv_usec += (delta); \
if ((tv).tv_usec > 1000000) { (tv).tv_sec++; \ if ((tv).tv_usec > USEC_PER_SEC) { (tv).tv_sec++; \
(tv).tv_usec -= 1000000; } \ (tv).tv_usec -= USEC_PER_SEC; } \
}) })
/* Set/check that time is in the "past perfect"; /* Set/check that time is in the "past perfect";
......
...@@ -208,7 +208,7 @@ struct hfsc_sched ...@@ -208,7 +208,7 @@ struct hfsc_sched
do { \ do { \
struct timeval tv; \ struct timeval tv; \
do_gettimeofday(&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) } while (0)
#endif #endif
...@@ -502,8 +502,8 @@ d2dx(u32 d) ...@@ -502,8 +502,8 @@ d2dx(u32 d)
u64 dx; u64 dx;
dx = ((u64)d * PSCHED_JIFFIE2US(HZ)); dx = ((u64)d * PSCHED_JIFFIE2US(HZ));
dx += 1000000 - 1; dx += USEC_PER_SEC - 1;
do_div(dx, 1000000); do_div(dx, USEC_PER_SEC);
return dx; return dx;
} }
...@@ -523,7 +523,7 @@ dx2d(u64 dx) ...@@ -523,7 +523,7 @@ dx2d(u64 dx)
{ {
u64 d; u64 d;
d = dx * 1000000; d = dx * USEC_PER_SEC;
do_div(d, PSCHED_JIFFIE2US(HZ)); do_div(d, PSCHED_JIFFIE2US(HZ));
return (u32)d; return (u32)d;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment