2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-14 16:23:51 +08:00

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>
This commit is contained in:
John Stultz 2013-03-22 11:31:29 -07:00
parent ad460967a2
commit aa6f9c595d
4 changed files with 36 additions and 12 deletions

View File

@ -125,9 +125,6 @@
extern unsigned long tick_usec; /* USER_HZ period (usec) */ extern unsigned long tick_usec; /* USER_HZ period (usec) */
extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */ extern unsigned long tick_nsec; /* SHIFTED_HZ period (nsec) */
extern void ntp_init(void);
extern void ntp_clear(void);
/* Required to safely shift negative values */ /* Required to safely shift negative values */
#define shift_right(x, s) ({ \ #define shift_right(x, s) ({ \
__typeof__(x) __x = (x); \ __typeof__(x) __x = (x); \
@ -140,10 +137,6 @@ extern void ntp_clear(void);
#define NTP_INTERVAL_FREQ (HZ) #define NTP_INTERVAL_FREQ (HZ)
#define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ) #define NTP_INTERVAL_LENGTH (NSEC_PER_SEC/NTP_INTERVAL_FREQ)
/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
extern u64 ntp_tick_length(void);
extern int second_overflow(unsigned long secs);
extern int do_adjtimex(struct timex *); extern int do_adjtimex(struct timex *);
extern void hardpps(const struct timespec *, const struct timespec *); extern void hardpps(const struct timespec *, const struct timespec *);

View File

@ -18,6 +18,7 @@
#include <linux/rtc.h> #include <linux/rtc.h>
#include "tick-internal.h" #include "tick-internal.h"
#include "ntp_internal.h"
/* /*
* NTP timekeeping variables: * NTP timekeeping variables:
@ -661,7 +662,7 @@ int ntp_validate_timex(struct timex *txc)
* adjtimex mainly allows reading (and writing, if superuser) of * adjtimex mainly allows reading (and writing, if superuser) of
* kernel time-keeping variables. used by xntpd. * kernel time-keeping variables. used by xntpd.
*/ */
int do_adjtimex(struct timex *txc) int __do_adjtimex(struct timex *txc)
{ {
struct timespec ts; struct timespec ts;
u32 time_tai, orig_tai; u32 time_tai, orig_tai;
@ -911,7 +912,7 @@ static void hardpps_update_phase(long error)
} }
/* /*
* hardpps() - discipline CPU clock oscillator to external PPS signal * __hardpps() - discipline CPU clock oscillator to external PPS signal
* *
* This routine is called at each PPS signal arrival in order to * This routine is called at each PPS signal arrival in order to
* discipline the CPU clock oscillator to the PPS signal. It takes two * discipline the CPU clock oscillator to the PPS signal. It takes two
@ -922,7 +923,7 @@ static void hardpps_update_phase(long error)
* This code is based on David Mills's reference nanokernel * This code is based on David Mills's reference nanokernel
* implementation. It was mostly rewritten but keeps the same idea. * implementation. It was mostly rewritten but keeps the same idea.
*/ */
void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts) void __hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
{ {
struct pps_normtime pts_norm, freq_norm; struct pps_normtime pts_norm, freq_norm;
unsigned long flags; unsigned long flags;
@ -976,8 +977,6 @@ void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
raw_spin_unlock_irqrestore(&ntp_lock, flags); raw_spin_unlock_irqrestore(&ntp_lock, flags);
} }
EXPORT_SYMBOL(hardpps);
#endif /* CONFIG_NTP_PPS */ #endif /* CONFIG_NTP_PPS */
static int __init ntp_tick_adj_setup(char *str) static int __init ntp_tick_adj_setup(char *str)

View File

@ -0,0 +1,11 @@
#ifndef _LINUX_NTP_INTERNAL_H
#define _LINUX_NTP_INTERNAL_H
extern void ntp_init(void);
extern void ntp_clear(void);
/* Returns how long ticks are at present, in ns / 2^NTP_SCALE_SHIFT. */
extern u64 ntp_tick_length(void);
extern int second_overflow(unsigned long secs);
extern int __do_adjtimex(struct timex *);
extern void __hardpps(const struct timespec *, const struct timespec *);
#endif /* _LINUX_NTP_INTERNAL_H */

View File

@ -24,6 +24,7 @@
#include <linux/pvclock_gtod.h> #include <linux/pvclock_gtod.h>
#include "tick-internal.h" #include "tick-internal.h"
#include "ntp_internal.h"
static struct timekeeper timekeeper; static struct timekeeper timekeeper;
static DEFINE_RAW_SPINLOCK(timekeeper_lock); static DEFINE_RAW_SPINLOCK(timekeeper_lock);
@ -1612,6 +1613,26 @@ ktime_t ktime_get_monotonic_offset(void)
} }
EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset);
/**
* do_adjtimex() - Accessor function to NTP __do_adjtimex function
*/
int do_adjtimex(struct timex *txc)
{
return __do_adjtimex(txc);
}
#ifdef CONFIG_NTP_PPS
/**
* hardpps() - Accessor function to NTP __hardpps function
*/
void hardpps(const struct timespec *phase_ts, const struct timespec *raw_ts)
{
__hardpps(phase_ts, raw_ts);
}
EXPORT_SYMBOL(hardpps);
#endif
/** /**
* xtime_update() - advances the timekeeping infrastructure * xtime_update() - advances the timekeeping infrastructure
* @ticks: number of ticks, that have elapsed since the last call. * @ticks: number of ticks, that have elapsed since the last call.