From patchwork Mon Mar 25 20:08:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15627 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B180023E66 for ; Mon, 25 Mar 2013 20:08:29 +0000 (UTC) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by fiordland.canonical.com (Postfix) with ESMTP id 437EAA19564 for ; Mon, 25 Mar 2013 20:08:29 +0000 (UTC) Received: by mail-ve0-f181.google.com with SMTP id pa12so3697416veb.40 for ; Mon, 25 Mar 2013 13:08:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=1Ixdj4axmWJ8fmPIgitAdaaM1tyFVecaxoXeMlVzhXU=; b=jNKOnDykYwH7+tnI5FqwQUkvh6qD0UBtuRJYhylcytXcTaqkzEKlNHajdKMAamoJzh 889o4d3Q5GKNoR8vVpAgB8RPZEqkmTH7140Jq8NcxiEySLqjiO5VmJcJdLcffPYZ5dBR oiKXkvLEiBWC1gpKjgQe+Fhiyiedeqr29XFnDURUCXXz5kTTWbISkwt+nKb8DIVrribM sMzPctq0SVNlkHt+pasNFxBVX9rOQeZhFVxKE9QcqsdaB845d1VEaLQnFf58u1XBnqFb t9uL8KsR8lzxuIoGvALdLJfZF9TCaryVCdg50bJthrP4uDp8yON3kfy1RA14G1HsZgVy 0AUg== X-Received: by 10.220.153.143 with SMTP id k15mr17336787vcw.33.1364242108760; Mon, 25 Mar 2013 13:08:28 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp41752ved; Mon, 25 Mar 2013 13:08:28 -0700 (PDT) X-Received: by 10.66.175.142 with SMTP id ca14mr20223450pac.52.1364242107916; Mon, 25 Mar 2013 13:08:27 -0700 (PDT) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id x7si15056961pab.202.2013.03.25.13.08.27 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-pd0-f176.google.com with SMTP id r11so135380pdi.7 for ; Mon, 25 Mar 2013 13:08:27 -0700 (PDT) X-Received: by 10.68.220.68 with SMTP id pu4mr19290588pbc.26.1364242107518; Mon, 25 Mar 2013 13:08:27 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id gn2sm14529074pbb.22.2013.03.25.13.08.26 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Mar 2013 13:08:26 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Thomas Gleixner , Richard Cochran , Prarit Bhargava Subject: [PATCH 2/8] ntp: Move do_adjtimex() and hardpps() functions to timekeeping.c Date: Mon, 25 Mar 2013 13:08:12 -0700 Message-Id: <1364242098-5977-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> References: <1364242098-5977-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQnifGwr4BzddhzjL02cc+opt8KY3jYjULtXuiqXAdb5/dxwyxjhAKGR5AjqQg0VOMkPX3/T 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 Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: John Stultz --- include/linux/timex.h | 7 ------- kernel/time/ntp.c | 9 ++++----- kernel/time/ntp_internal.h | 11 +++++++++++ kernel/time/timekeeping.c | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 kernel/time/ntp_internal.h diff --git a/include/linux/timex.h b/include/linux/timex.h index 5ec87c6..b3726e6 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h @@ -125,9 +125,6 @@ extern unsigned long tick_usec; /* USER_HZ period (usec) */ 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 */ #define shift_right(x, s) ({ \ __typeof__(x) __x = (x); \ @@ -140,10 +137,6 @@ extern void ntp_clear(void); #define NTP_INTERVAL_FREQ (HZ) #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 void hardpps(const struct timespec *, const struct timespec *); diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 457d2ba..8b10706 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -18,6 +18,7 @@ #include #include "tick-internal.h" +#include "ntp_internal.h" /* * NTP timekeeping variables: @@ -661,7 +662,7 @@ int ntp_validate_timex(struct timex *txc) * adjtimex mainly allows reading (and writing, if superuser) of * kernel time-keeping variables. used by xntpd. */ -int do_adjtimex(struct timex *txc) +int __do_adjtimex(struct timex *txc) { struct timespec ts; 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 * 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 * 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; 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); } -EXPORT_SYMBOL(hardpps); - #endif /* CONFIG_NTP_PPS */ static 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 0000000..fdee80c --- /dev/null +++ b/kernel/time/ntp_internal.h @@ -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 */ diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index c5feb7a..a138ec2 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -24,6 +24,7 @@ #include #include "tick-internal.h" +#include "ntp_internal.h" static struct timekeeper timekeeper; static DEFINE_RAW_SPINLOCK(timekeeper_lock); @@ -1613,6 +1614,26 @@ ktime_t ktime_get_monotonic_offset(void) 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 * @ticks: number of ticks, that have elapsed since the last call. *