From patchwork Mon Jun 1 11:57:38 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: 49311 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B5EF218FC for ; Mon, 1 Jun 2015 11:58:26 +0000 (UTC) Received: by wibbk2 with SMTP id bk2sf22150119wib.2 for ; Mon, 01 Jun 2015 04:58:25 -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=c9NBIkLhE51VxNr2KV2q6Vxfa0k2OPhLK0KXdWrpBoA=; b=Ulcu4zkY1xUZOXasGo1ae26PXs1BnB5FCTz71fC8yEiL2yVO4QaBwugF9C/Ybucqux yQrWjJ/M5BGSTETL4X90YVLzYD2pjSTMK5QS0wngWFEsIB7mPAXVBm1cWW/inlZ9Ii66 7BrTvkUErmSz7/AvIiIePvo3qYkZMexmmD71bz22kio8PZwrmy6KJ7Mz00A0Wykgl0Ba KqP/w12USKt2pjxV9UDqMOydns9BE7wPuhGnrpgI+H+QORXd5m/OIX1LbpmAN8l/Irwb YvldOMkGMSmRBJwb5wMK3EXHKOoNT5fWjWBlfg79s/tk3lfTs5hZ0KhcyBtwSQ068fdd rxtQ== X-Gm-Message-State: ALoCoQlIc2L7lsHS/tg/TSzP3pUdproOjhAfo35tCHRzyHOkrik8POkwRqjze8ckHeBIsoKbPmxM X-Received: by 10.152.87.140 with SMTP id ay12mr11079431lab.1.1433159905550; Mon, 01 Jun 2015 04:58:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.99 with SMTP id c3ls580384laf.96.gmail; Mon, 01 Jun 2015 04:58:25 -0700 (PDT) X-Received: by 10.112.126.162 with SMTP id mz2mr20202295lbb.97.1433159905373; Mon, 01 Jun 2015 04:58:25 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id yl6si12120985lbb.116.2015.06.01.04.58.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbuc2 with SMTP id uc2so82744791lbb.2 for ; Mon, 01 Jun 2015 04:58:25 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr20683640lbb.36.1433159905132; Mon, 01 Jun 2015 04:58:25 -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 hn6csp2259124lbb; Mon, 1 Jun 2015 04:58:24 -0700 (PDT) X-Received: by 10.66.66.1 with SMTP id b1mr31597788pat.62.1433159903219; Mon, 01 Jun 2015 04:58:23 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ai7si17352029pbd.187.2015.06.01.04.58.21; Mon, 01 Jun 2015 04:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753186AbbFAL6P (ORCPT + 28 others); Mon, 1 Jun 2015 07:58:15 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:36377 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753099AbbFAL5w (ORCPT ); Mon, 1 Jun 2015 07:57:52 -0400 Received: by pdjm12 with SMTP id m12so23227322pdj.3 for ; Mon, 01 Jun 2015 04:57:52 -0700 (PDT) X-Received: by 10.69.31.106 with SMTP id kl10mr2394611pbd.155.1433159872338; Mon, 01 Jun 2015 04:57:52 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id np9sm14335535pdb.9.2015.06.01.04.57.50 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:57:51 -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 v4 14/25] posix-timers:Convert to the 64bit methods for the clock_gettime syscall function Date: Mon, 1 Jun 2015 19:57:38 +0800 Message-Id: <1433159858-5070-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.169 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 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_gettime syscall function, and change the clock_gettime syscall implementation. Also add a default 64bit method for the clock_get64 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 | 1 + kernel/time/posix-timers.c | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 2b19ec8..be2123d 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 12affd5..9b5352a 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -582,6 +582,20 @@ static int default_clock_set64(const clockid_t which_clock, return ret; } +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; + int ret; + + ret = kc->clock_get(which_clock, &tp); + if (!ret) + *tp64 = timespec_to_timespec64(tp); + + return ret; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -591,8 +605,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; } @@ -608,6 +622,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; } @@ -1117,25 +1133,25 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock, return __clock_settime(which_clock, &new_tp); } -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; + struct timespec64 kernel_tp; int error; error = __clock_gettime(which_clock, &kernel_tp); - if (!error && copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) + if (!error && put_timespec(&kernel_tp, tp)) error = -EFAULT; return error;