aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2013-03-22 14:31:29 -0400
committerJohn Stultz <john.stultz@linaro.org>2013-04-04 16:18:14 -0400
commitaa6f9c595d857328e5d815e5b94c0e7cd31a6b59 (patch)
treebee031555304488a68e9f4dc76944b8924f11e7b /kernel/time
parentad460967a2953496ad76b1c22091ea99f21b4e86 (diff)
ntp: Move do_adjtimex() and hardpps() functions to timekeeping.c
In preparation for changing the ntp locking rules, move do_adjtimex and hardpps accessor functions to timekeeping.c, but keep the code logic in ntp.c. This patch also introduces a ntp_internal.h file so timekeeping specific interfaces of ntp.c can be more limitedly shared with timekeeping.c. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/ntp.c9
-rw-r--r--kernel/time/ntp_internal.h11
-rw-r--r--kernel/time/timekeeping.c21
3 files changed, 36 insertions, 5 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 457d2ba245fe..8b107068d7e3 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -18,6 +18,7 @@
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19 19
20#include "tick-internal.h" 20#include "tick-internal.h"
21#include "ntp_internal.h"
21 22
22/* 23/*
23 * NTP timekeeping variables: 24 * NTP timekeeping variables:
@@ -661,7 +662,7 @@ int ntp_validate_timex(struct timex *txc)
661 * adjtimex mainly allows reading (and writing, if superuser) of 662 * adjtimex mainly allows reading (and writing, if superuser) of
662 * kernel time-keeping variables. used by xntpd. 663 * kernel time-keeping variables. used by xntpd.
663 */ 664 */
664int do_adjtimex(struct timex *txc) 665int __do_adjtimex(struct timex *txc)
665{ 666{
666 struct timespec ts; 667 struct timespec ts;
667 u32 time_tai, orig_tai; 668 u32 time_tai, orig_tai;
@@ -911,7 +912,7 @@ static void hardpps_update_phase(long error)
911} 912}
912 913
913/* 914/*
914 * hardpps() - discipline CPU clock oscillator to external PPS signal 915 * __hardpps() - discipline CPU clock oscillator to external PPS signal
915 * 916 *
916 * This routine is called at each PPS signal arrival in order to 917 * This routine is called at each PPS signal arrival in order to
917 * discipline the CPU clock oscillator to the PPS signal. It takes two 918 * discipline the CPU clock oscillator to the PPS signal. It takes two
@@ -922,7 +923,7 @@ static void hardpps_update_phase(long error)
922 * This code is based on David Mills's reference nanokernel 923 * This code is based on David Mills's reference nanokernel
923 * implementation. It was mostly rewritten but keeps the same idea. 924 * implementation. It was mostly rewritten but keeps the same idea.
924 */ 925 */
925void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) 926void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
926{ 927{
927 struct pps_normtime pts_norm, freq_norm; 928 struct pps_normtime pts_norm, freq_norm;
928 unsigned long flags; 929 unsigned long flags;
@@ -976,8 +977,6 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
976 977
977 raw_spin_unlock_irqrestore(&ntp_lock, flags); 978 raw_spin_unlock_irqrestore(&ntp_lock, flags);
978} 979}
979EXPORT_SYMBOL(hardpps);
980
981#endif /* CONFIG_NTP_PPS */ 980#endif /* CONFIG_NTP_PPS */
982 981
983static int __init ntp_tick_adj_setup(char *str) 982static int __init ntp_tick_adj_setup(char *str)
diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h
new file mode 100644
index 000000000000..fdee80cb34f3
--- /dev/null
+++ b/kernel/time/ntp_internal.h
@@ -0,0 +1,11 @@
1#ifndef _LINUX_NTP_INTERNAL_H
2#define _LINUX_NTP_INTERNAL_H
3
4extern void ntp_init(void);
5extern void ntp_clear(void);
6/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
7extern u64 ntp_tick_length(void);
8extern int second_overflow(unsigned long secs);
9extern int __do_adjtimex(struct timex *);
10extern void __hardpps(const struct timespec *, const struct timespec *);
11#endif /* _LINUX_NTP_INTERNAL_H */
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index c5feb7aa3acb..a138ec2cde3e 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -24,6 +24,7 @@
24#include <linux/pvclock_gtod.h> 24#include <linux/pvclock_gtod.h>
25 25
26#include "tick-internal.h" 26#include "tick-internal.h"
27#include "ntp_internal.h"
27 28
28static struct timekeeper timekeeper; 29static struct timekeeper timekeeper;
29static DEFINE_RAW_SPINLOCK(timekeeper_lock); 30static DEFINE_RAW_SPINLOCK(timekeeper_lock);
@@ -1613,6 +1614,26 @@ ktime_t ktime_get_monotonic_offset(void)
1613EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); 1614EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset);
1614 1615
1615/** 1616/**
1617 * do_adjtimex() - Accessor function to NTP __do_adjtimex function
1618 */
1619int do_adjtimex(struct timex *txc)
1620{
1621 return __do_adjtimex(txc);
1622}
1623
1624
1625#ifdef CONFIG_NTP_PPS
1626/**
1627 * hardpps() - Accessor function to NTP __hardpps function
1628 */
1629void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
1630{
1631 __hardpps(phase_ts, raw_ts);
1632}
1633EXPORT_SYMBOL(hardpps);
1634#endif
1635
1636/**
1616 * xtime_update() - advances the timekeeping infrastructure 1637 * xtime_update() - advances the timekeeping infrastructure
1617 * @ticks: number of ticks, that have elapsed since the last call. 1638 * @ticks: number of ticks, that have elapsed since the last call.
1618 * 1639 *