From patchwork Mon May 11 11:17:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 48247 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6289921550 for ; Mon, 11 May 2015 11:17:27 +0000 (UTC) Received: by wiz9 with SMTP id 9sf9171351wiz.3 for ; Mon, 11 May 2015 04:17:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ZYUsQwwXPD8DXJEPGi4q5H0ds8IUm9jQOZqy7A2PayE=; b=C2idV7+VQ9ONk4N/92Bu73aQ6A2Av2XG5jJTyURowCTzZ2Ic6K6+lu+jxpGgGoTt1S NuGmWPH2Tt3qPWwqto2/pQartBD/ioejXhIeXuWKbnjyUtU3uWLp76R76Nq7k4GxjFU2 6Qlyl1NROxq5t8BAkIkMRR9rxE89E60MFajrbpbIjoC74OT4lHbjKxCp+wnIR7+jz8Jo MylvzYVQKFMa/CtTm3vqW5PiY+2gAH02px+ANKQ/1sNXIuwKG+XBynMgmfo0LLzdjBta JU6APbMsDG8iDuokYJ0SWV6QvXYUpTUuwuTBxy+C24cdQH7npNc2Hcxda5V/YCQRmWy1 QyMg== X-Gm-Message-State: ALoCoQnD0evDGMMDpMWGn+QAox/vUuMd4XqM4ZvgNgXRRTAMBCECVZtImA34gVOjPMOxSGQqlI1Y X-Received: by 10.194.189.110 with SMTP id gh14mr733929wjc.3.1431343046673; Mon, 11 May 2015 04:17:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls694746lac.91.gmail; Mon, 11 May 2015 04:17:26 -0700 (PDT) X-Received: by 10.152.179.233 with SMTP id dj9mr7769380lac.101.1431343046487; Mon, 11 May 2015 04:17:26 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id wh2si8193696lbb.24.2015.05.11.04.17.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 04:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbzk7 with SMTP id zk7so91354082lbb.0 for ; Mon, 11 May 2015 04:17:26 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr7563642lac.41.1431343046359; Mon, 11 May 2015 04:17:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1443546lbb; Mon, 11 May 2015 04:17:25 -0700 (PDT) X-Received: by 10.66.141.77 with SMTP id rm13mr18556912pab.14.1431343044432; Mon, 11 May 2015 04:17:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si17530424pdi.227.2015.05.11.04.17.23; Mon, 11 May 2015 04:17:24 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753914AbbEKLRT (ORCPT + 28 others); Mon, 11 May 2015 07:17:19 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35703 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753495AbbEKLRP (ORCPT ); Mon, 11 May 2015 07:17:15 -0400 Received: by pabtp1 with SMTP id tp1so107691045pab.2 for ; Mon, 11 May 2015 04:17:15 -0700 (PDT) X-Received: by 10.70.48.68 with SMTP id j4mr18229715pdn.5.1431343035016; Mon, 11 May 2015 04:17:15 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id mi1sm12727187pab.0.2015.05.11.04.17.12 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 04:17:14 -0700 (PDT) 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 v3 11/22] posix-timers:Convert to the 64bit methods for the clock_gettime syscall function Date: Mon, 11 May 2015 19:17:08 +0800 Message-Id: <1431343028-29801-1-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch introduces the clock_get64 methods with timespec64 type for k_clock structure. Convert to the 64bit methods with timespec64 type for the clock_gettime syscall function, and change the clock_gettime syscall implementation according the the CONFIG_64BIT macro. Signed-off-by: Baolin Wang --- include/linux/posix-timers.h | 1 + kernel/time/posix-timers.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 9b6469c..c08a536 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -103,6 +103,7 @@ struct k_clock { 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_get64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_adj) (const clockid_t which_clock, struct timex *tx); int (*timer_create) (struct k_itimer *timer); int (*nsleep) (const clockid_t which_clock, int flags, diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 8aac06d..ccc84d3 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -545,6 +545,16 @@ static int default_clock_set64(const clockid_t which_clock, return 0; } +static int default_clock_get64(const clockid_t which_clock, + struct timespec64 *tp64) +{ + struct k_clock *kc = clockid_to_kclock(which_clock); + struct timespec tp; + + kc->clock_get(which_clock, &tp); + return 0; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -554,8 +564,8 @@ void posix_timers_register_clock(const clockid_t clock_id, return; } - if (!new_clock->clock_get) { - printk(KERN_WARNING "POSIX clock id %d lacks clock_get()\n", + if (!new_clock->clock_get && !new_clock->clock_get64) { + printk(KERN_WARNING "POSIX clock id %d lacks clock_get() and clock_get64()\n", clock_id); return; } @@ -571,6 +581,8 @@ void posix_timers_register_clock(const clockid_t clock_id, new_clock->timer_set64 = default_timer_set64; if (new_clock->clock_set && !new_clock->clock_set64) new_clock->clock_set64 = default_clock_set64; + if (new_clock->clock_get && !new_clock->clock_get64) + new_clock->clock_get64 = default_clock_get64; posix_clocks[clock_id] = *new_clock; } @@ -1115,23 +1127,31 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, #endif } -static int __clock_gettime(clockid_t which_clock, struct timespec *ts) +static int __clock_gettime(clockid_t which_clock, struct timespec64 *ts) { struct k_clock *kc = clockid_to_kclock(which_clock); if (!kc) return -EINVAL; - return kc->clock_get(which_clock, ts); + return kc->clock_get64(which_clock, ts); } SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, struct timespec __user *,tp) { - struct timespec kernel_tp; int error; - +#ifdef CONFIG_64BIT + struct timespec64 kernel_tp; error = __clock_gettime(which_clock, &kernel_tp); +#else + struct timespec64 kernel_tp64; + struct timespec kernel_tp; + + error = __clock_gettime(which_clock, &kernel_tp64); + if (!error) + kernel_tp = timespec64_to_timespec(kernel_tp64); +#endif if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) error = -EFAULT;