Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753081AbbFAL5h (ORCPT ); Mon, 1 Jun 2015 07:57:37 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33428 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752999AbbFAL5U (ORCPT ); Mon, 1 Jun 2015 07:57:20 -0400 From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v4 12/25] posix-timers:Convert to the 64bit methods for the clock_settime syscall function Date: Mon, 1 Jun 2015 19:57:06 +0800 Message-Id: <1433159826-4998-1-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3349 Lines: 97 This patch introduces the clock_set64 method with timespec64 type for k_clock structure, that makes it ready for the 2038 year. Convert to the 64bit method with timespec64 type for the clock_settime syscall function, and change the clock_settime syscall implementation. Also add a default 64bit method for the clock_set64 pointer of k_clock structure, and it will be removed after all the drivers are converted to 64bit methods. Signed-off-by: Baolin Wang --- include/linux/posix-timers.h | 2 ++ kernel/time/posix-timers.c | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 16c3364..2b19ec8 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -100,6 +100,8 @@ struct k_clock { int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); int (*clock_set) (const clockid_t which_clock, const struct timespec *tp); + int (*clock_set64) (const clockid_t which_clock, + const struct timespec64 *tp); int (*clock_get) (const clockid_t which_clock, struct timespec * tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 9912745..06e2549 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -570,6 +570,18 @@ static int default_timer_set64(struct k_itimer *timr, int flags, return ret; } +static int default_clock_set64(const clockid_t which_clock, + const struct timespec64 *tp64) +{ + struct k_clock *kc = clockid_to_kclock(which_clock); + struct timespec tp; + int ret; + + tp = timespec64_to_timespec(*tp64); + ret = kc->clock_set(which_clock, &tp); + return ret; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -594,6 +606,8 @@ void posix_timers_register_clock(const clockid_t clock_id, new_clock->timer_get64 = default_timer_get64; if (new_clock->timer_set && !new_clock->timer_set64) new_clock->timer_set64 = default_timer_set64; + if (new_clock->clock_set && !new_clock->clock_set64) + new_clock->clock_set64 = default_clock_set64; posix_clocks[clock_id] = *new_clock; } @@ -1082,22 +1096,22 @@ void exit_itimers(struct signal_struct *sig) } } -static int __clock_settime(clockid_t which_clock, struct timespec *ts) +static int __clock_settime(clockid_t which_clock, struct timespec64 *ts) { struct k_clock *kc = clockid_to_kclock(which_clock); - if (!kc || !kc->clock_set) + if (!kc || !kc->clock_set64) return -EINVAL; - return kc->clock_set(which_clock, ts); + return kc->clock_set64(which_clock, ts); } SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, const struct timespec __user *, tp) { - struct timespec new_tp; + struct timespec64 new_tp; - if (copy_from_user(&new_tp, tp, sizeof (*tp))) + if (get_timespec(&new_tp, tp)) return -EFAULT; return __clock_settime(which_clock, &new_tp); -- 1.7.9.5 -- 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/