aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-06 16:18:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-06 16:18:29 -0400
commitb62ad9ab181a67207a4c8c373461b587c4861a68 (patch)
treeace1572964d81f5f9bbc10b7960c1f742832d744 /include/linux
parentaf390084359a5de20046c901529b2b6a50b941cb (diff)
parentb29230769e3482bbd62a07d6d9485371ee66a18f (diff)
Merge branch 'timers-timekeeping-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-timekeeping-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: um: Fix read_persistent_clock fallout kgdb: Do not access xtime directly powerpc: Clean up obsolete code relating to decrementer and timebase powerpc: Rework VDSO gettimeofday to prevent time going backwards clocksource: Add __clocksource_updatefreq_hz/khz methods x86: Convert common clocksources to use clocksource_register_hz/khz timekeeping: Make xtime and wall_to_monotonic static hrtimer: Cleanup direct access to wall_to_monotonic um: Convert to use read_persistent_clock timkeeping: Fix update_vsyscall to provide wall_to_monotonic offset powerpc: Cleanup xtime usage powerpc: Simplify update_vsyscall time: Kill off CONFIG_GENERIC_TIME time: Implement timespec_add x86: Fix vtime/file timestamp inconsistencies Trivial conflicts in Documentation/feature-removal-schedule.txt Much less trivial conflicts in arch/powerpc/kernel/time.c resolved as per Thomas' earlier merge commit 47916be4e28c ("Merge branch 'powerpc.cherry-picks' into timers/clocksource")
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/clocksource.h17
-rw-r--r--include/linux/time.h21
2 files changed, 33 insertions, 5 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 5ea3c60c160c..c37b21ad5a3b 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -292,6 +292,8 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec);
292 */ 292 */
293extern int 293extern int
294__clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq); 294__clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq);
295extern void
296__clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq);
295 297
296static inline int clocksource_register_hz(struct clocksource *cs, u32 hz) 298static inline int clocksource_register_hz(struct clocksource *cs, u32 hz)
297{ 299{
@@ -303,6 +305,15 @@ static inline int clocksource_register_khz(struct clocksource *cs, u32 khz)
303 return __clocksource_register_scale(cs, 1000, khz); 305 return __clocksource_register_scale(cs, 1000, khz);
304} 306}
305 307
308static inline void __clocksource_updatefreq_hz(struct clocksource *cs, u32 hz)
309{
310 __clocksource_updatefreq_scale(cs, 1, hz);
311}
312
313static inline void __clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
314{
315 __clocksource_updatefreq_scale(cs, 1000, khz);
316}
306 317
307static inline void 318static inline void
308clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec) 319clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec)
@@ -313,11 +324,13 @@ clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec)
313 324
314#ifdef CONFIG_GENERIC_TIME_VSYSCALL 325#ifdef CONFIG_GENERIC_TIME_VSYSCALL
315extern void 326extern void
316update_vsyscall(struct timespec *ts, struct clocksource *c, u32 mult); 327update_vsyscall(struct timespec *ts, struct timespec *wtm,
328 struct clocksource *c, u32 mult);
317extern void update_vsyscall_tz(void); 329extern void update_vsyscall_tz(void);
318#else 330#else
319static inline void 331static inline void
320update_vsyscall(struct timespec *ts, struct clocksource *c, u32 mult) 332update_vsyscall(struct timespec *ts, struct timespec *wtm,
333 struct clocksource *c, u32 mult)
321{ 334{
322} 335}
323 336
diff --git a/include/linux/time.h b/include/linux/time.h
index ea3559f0b3f2..cb34e35fabac 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -76,9 +76,25 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon,
76 const unsigned int min, const unsigned int sec); 76 const unsigned int min, const unsigned int sec);
77 77
78extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); 78extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec);
79
80/*
81 * timespec_add_safe assumes both values are positive and checks
82 * for overflow. It will return TIME_T_MAX if the reutrn would be
83 * smaller then either of the arguments.
84 */
79extern struct timespec timespec_add_safe(const struct timespec lhs, 85extern struct timespec timespec_add_safe(const struct timespec lhs,
80 const struct timespec rhs); 86 const struct timespec rhs);
81 87
88
89static inline struct timespec timespec_add(struct timespec lhs,
90 struct timespec rhs)
91{
92 struct timespec ts_delta;
93 set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec,
94 lhs.tv_nsec + rhs.tv_nsec);
95 return ts_delta;
96}
97
82/* 98/*
83 * sub = lhs - rhs, in normalized form 99 * sub = lhs - rhs, in normalized form
84 */ 100 */
@@ -97,8 +113,6 @@ static inline struct timespec timespec_sub(struct timespec lhs,
97#define timespec_valid(ts) \ 113#define timespec_valid(ts) \
98 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) 114 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC))
99 115
100extern struct timespec xtime;
101extern struct timespec wall_to_monotonic;
102extern seqlock_t xtime_lock; 116extern seqlock_t xtime_lock;
103 117
104extern void read_persistent_clock(struct timespec *ts); 118extern void read_persistent_clock(struct timespec *ts);
@@ -110,7 +124,8 @@ extern int timekeeping_suspended;
110 124
111unsigned long get_seconds(void); 125unsigned long get_seconds(void);
112struct timespec current_kernel_time(void); 126struct timespec current_kernel_time(void);
113struct timespec __current_kernel_time(void); /* does not hold xtime_lock */ 127struct timespec __current_kernel_time(void); /* does not take xtime_lock */
128struct timespec __get_wall_to_monotonic(void); /* does not take xtime_lock */
114struct timespec get_monotonic_coarse(void); 129struct timespec get_monotonic_coarse(void);
115 130
116#define CURRENT_TIME (current_kernel_time()) 131#define CURRENT_TIME (current_kernel_time())