提交 d2e3e0ca 编写于 作者: D Deepa Dinamani 提交者: Thomas Gleixner

time: Change k_clock clock_getres() to use timespec64

struct timespec is not y2038 safe on 32 bit machines.  Replace uses of
struct timespec with struct timespec64 in the kernel. The syscall
interfaces themselves will be changed in a separate series.

The clock_getres() interface has also been changed to use timespec64 even
though this particular interface is not affected by the y2038 problem. This
helps verification for internal kernel code for y2038 readiness by getting
rid of time_t/ timeval/ timespec completely.
Signed-off-by: NDeepa Dinamani <deepa.kernel@gmail.com>
Cc: y2038@lists.linaro.org
Cc: john.stultz@linaro.org
Cc: arnd@arndb.de
Link: http://lkml.kernel.org/r/1490555058-4603-5-git-send-email-deepa.kernel@gmail.comSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 3c9c12f4
...@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, ...@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err; return err;
} }
static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp) static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{ {
tp->tv_sec = 0; tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period; tp->tv_nsec = sgi_clock_period;
......
...@@ -87,7 +87,7 @@ struct k_itimer { ...@@ -87,7 +87,7 @@ struct k_itimer {
}; };
struct k_clock { struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); int (*clock_getres) (const clockid_t which_clock, struct timespec64 *tp);
int (*clock_set) (const clockid_t which_clock, int (*clock_set) (const clockid_t which_clock,
const struct timespec *tp); const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_get) (const clockid_t which_clock, struct timespec64 *tp);
......
...@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, ...@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
* *
* Returns the granularity of underlying alarm base clock * Returns the granularity of underlying alarm base clock
*/ */
static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp) static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{ {
if (!alarmtimer_get_rtcdev()) if (!alarmtimer_get_rtcdev())
return -EINVAL; return -EINVAL;
......
...@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct timespec64 *ts) ...@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
return err; return err;
} }
static int pc_clock_getres(clockid_t id, struct timespec *ts) static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
{ {
struct posix_clock_desc cd; struct posix_clock_desc cd;
struct timespec64 ts64;
int err; int err;
err = get_clock_desc(id, &cd); err = get_clock_desc(id, &cd);
if (err) if (err)
return err; return err;
if (cd.clk->ops.clock_getres) { if (cd.clk->ops.clock_getres)
err = cd.clk->ops.clock_getres(cd.clk, &ts64); err = cd.clk->ops.clock_getres(cd.clk, ts);
*ts = timespec64_to_timespec(ts64);
}
else else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
......
...@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p) ...@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
} }
static int static int
posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp) posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
{ {
int error = check_clock(which_clock); int error = check_clock(which_clock);
if (!error) { if (!error) {
...@@ -1369,7 +1369,7 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block) ...@@ -1369,7 +1369,7 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block)
#define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED) #define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
static int process_cpu_clock_getres(const clockid_t which_clock, static int process_cpu_clock_getres(const clockid_t which_clock,
struct timespec *tp) struct timespec64 *tp)
{ {
return posix_cpu_clock_getres(PROCESS_CLOCK, tp); return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
} }
...@@ -1394,7 +1394,7 @@ static long process_cpu_nsleep_restart(struct restart_block *restart_block) ...@@ -1394,7 +1394,7 @@ static long process_cpu_nsleep_restart(struct restart_block *restart_block)
return -EINVAL; return -EINVAL;
} }
static int thread_cpu_clock_getres(const clockid_t which_clock, static int thread_cpu_clock_getres(const clockid_t which_clock,
struct timespec *tp) struct timespec64 *tp)
{ {
return posix_cpu_clock_getres(THREAD_CLOCK, tp); return posix_cpu_clock_getres(THREAD_CLOCK, tp);
} }
......
...@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock, ...@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0; return 0;
} }
static int posix_get_coarse_res(const clockid_t which_clock, struct timespec *tp) static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 *tp)
{ {
*tp = ktime_to_timespec(KTIME_LOW_RES); *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0; return 0;
} }
...@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec64 *tp) ...@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec64 *tp)
return 0; return 0;
} }
static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec *tp) static int posix_get_hrtimer_res(clockid_t which_clock, struct timespec64 *tp)
{ {
tp->tv_sec = 0; tp->tv_sec = 0;
tp->tv_nsec = hrtimer_resolution; tp->tv_nsec = hrtimer_resolution;
...@@ -1075,13 +1075,15 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, ...@@ -1075,13 +1075,15 @@ SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock,
struct timespec __user *, tp) struct timespec __user *, tp)
{ {
struct k_clock *kc = clockid_to_kclock(which_clock); struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec64 rtn_tp64;
struct timespec rtn_tp; struct timespec rtn_tp;
int error; int error;
if (!kc) if (!kc)
return -EINVAL; return -EINVAL;
error = kc->clock_getres(which_clock, &rtn_tp); error = kc->clock_getres(which_clock, &rtn_tp64);
rtn_tp = timespec64_to_timespec(rtn_tp64);
if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp))) if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp)))
error = -EFAULT; error = -EFAULT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册