From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
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>
Subject: [PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version
Date: Mon, 28 Sep 2015 22:21:29 +0200 [thread overview]
Message-ID: <1443471692-2946597-3-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1443471692-2946597-1-git-send-email-arnd@arndb.de>
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
next prev parent reply other threads:[~2015-09-28 20:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 20:21 [PATCH 0/5] y2038 conversion for ntp/pps and sfc driver Arnd Bergmann
2015-09-28 20:21 ` [PATCH 1/5] ntp/pps: use timespec64 for hardpps() Arnd Bergmann
2015-09-30 7:20 ` Thomas Gleixner
2015-09-28 20:21 ` Arnd Bergmann [this message]
2015-09-30 7:20 ` [PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version Thomas Gleixner
2015-09-28 20:21 ` [PATCH 3/5] ntp: use timespec64 in sync_cmos_clock Arnd Bergmann
2015-09-30 7:22 ` Thomas Gleixner
2015-09-28 20:21 ` [PATCH 4/5] ntp/pps: use y2038 safe types in pps_event_time Arnd Bergmann
2015-09-30 7:25 ` Thomas Gleixner
2015-09-28 20:21 ` [PATCH 5/5] net: sfc: avoid using timespec Arnd Bergmann
2015-09-30 7:26 ` Thomas Gleixner
2015-09-29 19:17 ` [PATCH 0/5] y2038 conversion for ntp/pps and sfc driver Richard Cochran
2015-09-30 4:06 ` David Miller
2015-09-30 7:27 ` Thomas Gleixner
2015-10-01 17:00 ` John Stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443471692-2946597-3-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=giometti@enneenne.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net-drivers@solarflare.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=sshah@solarflare.com \
--cc=tglx@linutronix.de \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox