Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1234420

[PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version
Date Mon, 28 Sep 2015 22:30:01 +0200
Message-ID <qdNdD-1FC-3@gated-at.bofh.it> (permalink)
References <qdNdD-1FC-5@gated-at.bofh.it>
X-Original-To y2038@lists.linaro.org
X-Mailer git-send-email 2.1.0.rc2
X-Provags-ID V03:K0:/cH6p4nHvOY7KlL+G9zrXEGJEicWeNKu/FU/MeVrLwrXM+6hIeX f5hxwmN92zKJj9AXtUb/MkEM3OUtW+zPkXYXA/xnGK2kHx9od8hgA3RVj0wxoQXmwfGP9VD 5kp+aiZehZ/TIutFqZBtdtG52xPYbeoiEuRLl9s50dlGxBWRJL0xKwASGEWpEC1sCPmdyn/ KSU2JpV6HKEnKC/iylm8Q==
X-Ui-Out-Filterresults notjunk:1;V01:K0:JYEXWV96Lto=:x7tpYle086O1b6o2GIhQiO TGaYnAp7R5GJGTaVdnbfospxRO9xN+zl5qKI9RLkbcsrHl1fUq5cNRMiSQnmxDjBfVeOsvgHB rLtbIalvnRDTuq+Hl/FB36H2FZhQPYVUNPK183BijNut0JgpaZS7rVvatMwCdOlPCXmRdKBMv /auTnY74oqxSG5cxw8fyXWU0ke6fxpn94Z709vYARd63VnNkiEJIuMoNRZKUoFFb9zohSPAZO Sr4zuRFsVTYAPvPDGCEW4RdcSWDSaT3uTVUtmq0OwLRXONmpXjOW3Y0MqGBwKvxTjibe5zhCs 6GaB+Nx9j+LR96Z+XxWZhpdFVpLwOAtE3gspWgUP+XUCEKOTSWmgqhA3yn8vEf8J/U/y9B+c3 JT1BdiOS0iqPeAhAqRD2I75ZjSaCFcdEJQ/rTBQZAr4l0j1bfKgOj62SOEmxQczQRyJqsU13B GbFukVr6jDYBIVF/wo9xsgsgaeUox1e5U9DiNCAI68Emlf8H7MUxbUn0xWB6hRKRtEU33L66T p06BOKLNltcQC703pVICDvCcQSQExyuce97B4j/How+jXiHJvjR49w9VfXnL6Ep250KPtuMHB OVwnyYm61XQb1nBA86QAoznTcTLeFMMw+bFJlNGe9fjgyK3X3/LKUzrT0SfH1Xzj3vCWgiAyC CS+rGKPip8ZTrZ1TTPAzpgrX6GleRNrXArqFG7T99T3WyOv38K7Ot+O8Vue2WuG9YLNg=
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 107
Organization linux.* mail to news gateway
X-Original-Cc Thomas Gleixner <tglx@linutronix.de>, John Stultz <john.stultz@linaro.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rodolfo Giometti <giometti@enneenne.com>, linux-net-drivers@solarflare.com, Shradha Shah <sshah@solarflare.com>, Richard Cochran <richardcochran@gmail.com>, Arnd Bergmann <arnd@arndb.de>
X-Original-Date Mon, 28 Sep 2015 22:21:29 +0200
X-Original-Message-ID <1443471692-2946597-3-git-send-email-arnd@arndb.de>
X-Original-References <1443471692-2946597-1-git-send-email-arnd@arndb.de>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1234420

Show key headers only | View raw


There is exactly one caller of getnstime_raw_and_real in the kernel,
which is the pps_get_ts function. This changes the caller and
the implementation to work on timespec64 types rather than timespec,
to avoid the time_t overflow on 32-bit architectures.

For consistency with the other new functions (ktime_get_seconds,
ktime_get_real_*, ...), I'm renaming the function to
ktime_get_raw_and_real_ts64.

We still need to convert from the internal 64-bit type to 32 bit
types in the caller, but this conversion is now pushed out from
getnstime_raw_and_real to pps_get_ts. A follow-up patch changes
the remaining pps code to completely avoid the conversion.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/pps_kernel.h  |  7 ++++++-
 include/linux/timekeeping.h |  4 ++--
 kernel/time/timekeeping.c   | 12 ++++++------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index 1d2cd21242e8..b2fbd62ab18d 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -115,7 +115,12 @@ static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
 
 static inline void pps_get_ts(struct pps_event_time *ts)
 {
-	getnstime_raw_and_real(&ts->ts_raw, &ts->ts_real);
+	struct timespec64 raw, real;
+
+	ktime_get_raw_and_real_ts64(&raw, &real);
+
+	ts->ts_raw = timespec64_to_timespec(raw);
+	ts->ts_real = timespec64_to_timespec(real);
 }
 
 #else /* CONFIG_NTP_PPS */
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 474331cd1ef8..ca2eaa9077eb 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -269,8 +269,8 @@ extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
 /*
  * PPS accessor
  */
-extern void getnstime_raw_and_real(struct timespec *ts_raw,
-				   struct timespec *ts_real);
+extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw,
+				        struct timespec64 *ts_real);
 
 /*
  * Persistent clock related interfaces
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 3112977dfca0..ed5049ff94c5 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -849,7 +849,7 @@ EXPORT_SYMBOL_GPL(ktime_get_real_seconds);
 #ifdef CONFIG_NTP_PPS
 
 /**
- * getnstime_raw_and_real - get day and raw monotonic time in timespec format
+ * ktime_get_raw_and_real_ts64 - get day and raw monotonic time in timespec format
  * @ts_raw:	pointer to the timespec to be set to raw monotonic time
  * @ts_real:	pointer to the timespec to be set to the time of day
  *
@@ -857,7 +857,7 @@ EXPORT_SYMBOL_GPL(ktime_get_real_seconds);
  * same time atomically and stores the resulting timestamps in timespec
  * format.
  */
-void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
+void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, struct timespec64 *ts_real)
 {
 	struct timekeeper *tk = &tk_core.timekeeper;
 	unsigned long seq;
@@ -868,7 +868,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
 	do {
 		seq = read_seqcount_begin(&tk_core.seq);
 
-		*ts_raw = timespec64_to_timespec(tk->raw_time);
+		*ts_raw = tk->raw_time;
 		ts_real->tv_sec = tk->xtime_sec;
 		ts_real->tv_nsec = 0;
 
@@ -877,10 +877,10 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
 
 	} while (read_seqcount_retry(&tk_core.seq, seq));
 
-	timespec_add_ns(ts_raw, nsecs_raw);
-	timespec_add_ns(ts_real, nsecs_real);
+	timespec64_add_ns(ts_raw, nsecs_raw);
+	timespec64_add_ns(ts_real, nsecs_real);
 }
-EXPORT_SYMBOL(getnstime_raw_and_real);
+EXPORT_SYMBOL(ktime_get_raw_and_real_ts64);
 
 #endif /* CONFIG_NTP_PPS */
 
-- 
2.1.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version Arnd Bergmann <arnd@arndb.de> - 2015-09-28 22:30 +0200

csiph-web