Skip to content

Commit df869b6

Browse files
Roman ZippelLinus Torvalds
authored andcommitted
[PATCH] hrtimers: remove nsec_t typedef
nsec_t predates ktime_t and has mostly been superseded by it. In the few places that are left it's better to make it explicit that we're dealing with 64 bit values here. Signed-off-by: Roman Zippel <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 272705c commit df869b6

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

include/linux/time.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec);
7373
#define timespec_valid(ts) \
7474
(((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC))
7575

76-
/*
77-
* 64-bit nanosec type. Large enough to span 292+ years in nanosecond
78-
* resolution. Ought to be enough for a while.
79-
*/
80-
typedef s64 nsec_t;
81-
8276
extern struct timespec xtime;
8377
extern struct timespec wall_to_monotonic;
8478
extern seqlock_t xtime_lock;
@@ -114,9 +108,9 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
114108
* Returns the scalar nanosecond representation of the timespec
115109
* parameter.
116110
*/
117-
static inline nsec_t timespec_to_ns(const struct timespec *ts)
111+
static inline s64 timespec_to_ns(const struct timespec *ts)
118112
{
119-
return ((nsec_t) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
113+
return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
120114
}
121115

122116
/**
@@ -126,9 +120,9 @@ static inline nsec_t timespec_to_ns(const struct timespec *ts)
126120
* Returns the scalar nanosecond representation of the timeval
127121
* parameter.
128122
*/
129-
static inline nsec_t timeval_to_ns(const struct timeval *tv)
123+
static inline s64 timeval_to_ns(const struct timeval *tv)
130124
{
131-
return ((nsec_t) tv->tv_sec * NSEC_PER_SEC) +
125+
return ((s64) tv->tv_sec * NSEC_PER_SEC) +
132126
tv->tv_usec * NSEC_PER_USEC;
133127
}
134128

@@ -138,15 +132,15 @@ static inline nsec_t timeval_to_ns(const struct timeval *tv)
138132
*
139133
* Returns the timespec representation of the nsec parameter.
140134
*/
141-
extern struct timespec ns_to_timespec(const nsec_t nsec);
135+
extern struct timespec ns_to_timespec(const s64 nsec);
142136

143137
/**
144138
* ns_to_timeval - Convert nanoseconds to timeval
145139
* @nsec: the nanoseconds value to be converted
146140
*
147141
* Returns the timeval representation of the nsec parameter.
148142
*/
149-
extern struct timeval ns_to_timeval(const nsec_t nsec);
143+
extern struct timeval ns_to_timeval(const s64 nsec);
150144

151145
#endif /* __KERNEL__ */
152146

kernel/hrtimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
266266
/*
267267
* Divide a ktime value by a nanosecond value
268268
*/
269-
static unsigned long ktime_divns(const ktime_t kt, nsec_t div)
269+
static unsigned long ktime_divns(const ktime_t kt, s64 div)
270270
{
271271
u64 dclc, inc, dns;
272272
int sft = 0;
@@ -322,7 +322,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
322322
interval.tv64 = timer->base->resolution.tv64;
323323

324324
if (unlikely(delta.tv64 >= interval.tv64)) {
325-
nsec_t incr = ktime_to_ns(interval);
325+
s64 incr = ktime_to_ns(interval);
326326

327327
orun = ktime_divns(delta, incr);
328328
timer->expires = ktime_add_ns(timer->expires, incr * orun);

kernel/time.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
610610
*
611611
* Returns the timespec representation of the nsec parameter.
612612
*/
613-
struct timespec ns_to_timespec(const nsec_t nsec)
613+
struct timespec ns_to_timespec(const s64 nsec)
614614
{
615615
struct timespec ts;
616616

@@ -630,7 +630,7 @@ struct timespec ns_to_timespec(const nsec_t nsec)
630630
*
631631
* Returns the timeval representation of the nsec parameter.
632632
*/
633-
struct timeval ns_to_timeval(const nsec_t nsec)
633+
struct timeval ns_to_timeval(const s64 nsec)
634634
{
635635
struct timespec ts = ns_to_timespec(nsec);
636636
struct timeval tv;

0 commit comments

Comments
 (0)