Commit 32d3fe68 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

y2038: make do_gettimeofday() and get_seconds() inline

[ Upstream commit 33e26418 ]

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5a830803
...@@ -6,8 +6,19 @@ ...@@ -6,8 +6,19 @@
* over time so we can remove the file here. * over time so we can remove the file here.
*/ */
extern void do_gettimeofday(struct timeval *tv); static inline void do_gettimeofday(struct timeval *tv)
unsigned long get_seconds(void); {
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 struct timespec current_kernel_time(void) static inline struct timespec current_kernel_time(void)
{ {
......
...@@ -144,9 +144,11 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv, ...@@ -144,9 +144,11 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
struct timezone __user *, tz) struct timezone __user *, tz)
{ {
if (likely(tv != NULL)) { if (likely(tv != NULL)) {
struct timeval ktv; struct timespec64 ts;
do_gettimeofday(&ktv);
if (copy_to_user(tv, &ktv, sizeof(ktv))) 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; return -EFAULT;
} }
if (unlikely(tz != NULL)) { if (unlikely(tz != NULL)) {
...@@ -227,10 +229,11 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv, ...@@ -227,10 +229,11 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
struct timezone __user *, tz) struct timezone __user *, tz)
{ {
if (tv) { if (tv) {
struct timeval ktv; struct timespec64 ts;
do_gettimeofday(&ktv); ktime_get_real_ts64(&ts);
if (compat_put_timeval(&ktv, tv)) if (put_user(ts.tv_sec, &tv->tv_sec) ||
put_user(ts.tv_nsec / 1000, &tv->tv_usec))
return -EFAULT; return -EFAULT;
} }
if (tz) { if (tz) {
......
...@@ -1214,22 +1214,6 @@ int get_device_system_crosststamp(int (*get_time_fn) ...@@ -1214,22 +1214,6 @@ int get_device_system_crosststamp(int (*get_time_fn)
} }
EXPORT_SYMBOL_GPL(get_device_system_crosststamp); 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. * do_settimeofday64 - Sets the time of day.
* @ts: pointer to the timespec64 variable containing the new time * @ts: pointer to the timespec64 variable containing the new time
...@@ -2177,14 +2161,6 @@ void getboottime64(struct timespec64 *ts) ...@@ -2177,14 +2161,6 @@ void getboottime64(struct timespec64 *ts)
} }
EXPORT_SYMBOL_GPL(getboottime64); 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) void ktime_get_coarse_real_ts64(struct timespec64 *ts)
{ {
struct timekeeper *tk = &tk_core.timekeeper; struct timekeeper *tk = &tk_core.timekeeper;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment