mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: tglx@linutronix.de
Cc: y2038@lists.linaro.org, linux-api@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>,
	linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	deepa.kernel@gmail.com, linux-arch@vger.kernel.org,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 02/14] y2038: Make do_gettimeofday() and get_seconds() inline
Date: Mon, 27 Aug 2018 21:45:19 +0200	[thread overview]
Message-ID: <20180827194531.3796559-3-arnd@arndb.de> (raw)
In-Reply-To: <20180827194531.3796559-1-arnd@arndb.de>

get_seconds() and do_gettimeofday() are only used by a few modules now any
more (waiting for the respective patches to get accepted), and they are
among the last holdouts of code that is not y2038 safe in the core kernel.

Move the implementation into the timekeeping32.h header to clean up
the core kernel and isolate the old interfaces further.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/timekeeping32.h | 15 +++++++++++++--
 kernel/time/time.c            | 15 +++++++++------
 kernel/time/timekeeping.c     | 24 ------------------------
 3 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h
index a4a4991160fb..a502616f7e1c 100644
--- a/include/linux/timekeeping32.h
+++ b/include/linux/timekeeping32.h
@@ -6,8 +6,19 @@
  * over time so we can remove the file here.
  */
 
-extern void do_gettimeofday(struct timeval *tv);
-unsigned long get_seconds(void);
+static inline void do_gettimeofday(struct timeval *tv)
+{
+	struct timespec64 now;
+
+	ktime_get_real_ts64(&now);
+	tv->tv_sec = now.tv_sec;
+	tv->tv_usec = now.tv_nsec/1000;
+}
+
+static inline unsigned long get_seconds(void)
+{
+	return ktime_get_real_seconds();
+}
 
 static inline void getnstimeofday(struct timespec *ts)
 {
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 712543011106..de332250d6fa 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -144,9 +144,11 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
 		struct timezone __user *, tz)
 {
 	if (likely(tv != NULL)) {
-		struct timeval ktv;
-		do_gettimeofday(&ktv);
-		if (copy_to_user(tv, &ktv, sizeof(ktv)))
+		struct timespec64 ts;
+
+		ktime_get_real_ts64(&ts);
+		if (put_user(ts.tv_sec, &tv->tv_sec) ||
+		    put_user(ts.tv_nsec / 1000, &tv->tv_usec))
 			return -EFAULT;
 	}
 	if (unlikely(tz != NULL)) {
@@ -227,10 +229,11 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
 		       struct timezone __user *, tz)
 {
 	if (tv) {
-		struct timeval ktv;
+		struct timespec64 ts;
 
-		do_gettimeofday(&ktv);
-		if (compat_put_timeval(&ktv, tv))
+		ktime_get_real_ts64(&ts);
+		if (put_user(ts.tv_sec, &tv->tv_sec) ||
+		    put_user(ts.tv_nsec / 1000, &tv->tv_usec))
 			return -EFAULT;
 	}
 	if (tz) {
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index f3b22f456fac..2d110c948805 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1211,22 +1211,6 @@ int get_device_system_crosststamp(int (*get_time_fn)
 }
 EXPORT_SYMBOL_GPL(get_device_system_crosststamp);
 
-/**
- * do_gettimeofday - Returns the time of day in a timeval
- * @tv:		pointer to the timeval to be set
- *
- * NOTE: Users should be converted to using getnstimeofday()
- */
-void do_gettimeofday(struct timeval *tv)
-{
-	struct timespec64 now;
-
-	getnstimeofday64(&now);
-	tv->tv_sec = now.tv_sec;
-	tv->tv_usec = now.tv_nsec/1000;
-}
-EXPORT_SYMBOL(do_gettimeofday);
-
 /**
  * do_settimeofday64 - Sets the time of day.
  * @ts:     pointer to the timespec64 variable containing the new time
@@ -2174,14 +2158,6 @@ void getboottime64(struct timespec64 *ts)
 }
 EXPORT_SYMBOL_GPL(getboottime64);
 
-unsigned long get_seconds(void)
-{
-	struct timekeeper *tk = &tk_core.timekeeper;
-
-	return tk->xtime_sec;
-}
-EXPORT_SYMBOL(get_seconds);
-
 void ktime_get_coarse_real_ts64(struct timespec64 *ts)
 {
 	struct timekeeper *tk = &tk_core.timekeeper;
-- 
2.18.0


  parent reply	other threads:[~2018-08-27 19:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-27 19:45 [PATCH 00/14] y2038 syscall changes for 4.20 Arnd Bergmann
2018-08-27 19:45 ` [PATCH 01/14] y2038: Remove unused time interfaces Arnd Bergmann
2018-08-27 19:45 ` Arnd Bergmann [this message]
2018-08-27 19:45 ` [PATCH 03/14] y2038: Globally rename compat_time to old_time32 Arnd Bergmann
2018-08-29 12:50   ` kbuild test robot
2018-08-29 12:50   ` [RFC PATCH] y2038: __get_old_timespec32() can be static kbuild test robot
2018-08-29 13:17     ` [Y2038] " Arnd Bergmann
2018-08-27 19:45 ` [PATCH 04/14] y2038: Remove newstat family from default syscall set Arnd Bergmann
2018-08-27 19:45 ` [PATCH 05/14] y2038: Remove stat64 " Arnd Bergmann
2018-08-27 19:45 ` [PATCH 06/14] asm-generic: Move common compat types to asm-generic/compat.h Arnd Bergmann
2018-08-27 19:45 ` [PATCH 07/14] asm-generic: Remove unneeded __ARCH_WANT_SYS_LLSEEK macro Arnd Bergmann
2018-08-27 19:45 ` [PATCH 08/14] asm-generic: Remove empty asm/unistd.h Arnd Bergmann
2018-08-27 19:45 ` [PATCH 09/14] y2038: Change sys_utimensat() to use __kernel_timespec Arnd Bergmann
2018-08-27 19:45 ` [PATCH 10/14] y2038: Compile utimes()/futimesat() conditionally Arnd Bergmann
2018-08-27 19:45 ` [PATCH 11/14] y2038: utimes: Rework #ifdef guards for compat syscalls Arnd Bergmann
2018-08-27 19:45 ` [PATCH 12/14] y2038: sched: Change sched_rr_get_interval to use __kernel_timespec Arnd Bergmann
2018-08-27 19:45 ` [PATCH 13/14] y2038: socket: Change recvmmsg " Arnd Bergmann
2018-08-27 19:45 ` [PATCH 14/14] y2038: signal: Change rt_sigtimedwait " Arnd Bergmann
2018-08-29 13:59 ` [PATCH 00/14] y2038 syscall changes for 4.20 Arnd Bergmann

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=20180827194531.3796559-3-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=deepa.kernel@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --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

all inboxes | Powered by JetHome®