From patchwork Mon Jun 1 11:58:09 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: 49313 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3FB8218FC for ; Mon, 1 Jun 2015 11:58:47 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf33931349lbc.2 for ; Mon, 01 Jun 2015 04:58:46 -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=mx+T3yH9tdG7e8VAGQYLaHc8iFMf10uFVNizU8naqo4=; b=KjHVR840dD03SD8XSCYYtDE5jWJyqLoFxgZBQAVKsXffzkwwDmjX5q3ubNiv6NXnh0 1hlYPDlKPDM11aPjAKMcpVcjX+2Gnp47UuNYHuxEw0m/ZVti7ywWmV6kHUrrP4e8oDjd ERnR4oSfoAoJ2sORhs+9zt8zayyf3tNR1jrj+0Ui73r9xoGuIoy1DeoftS1TrYW+iy5l w6JSR/mT01OuzwVEQFo4lTfzSQ3XPSlKuQ16kegC7DH+OhMvLgYYaZ3eNL70C9u9BeBB gk7GnNZT7lfa7S4UNI7aveEyl+WgxxVjBIP9mCEcx/iSIBffdQ8uCSRPl+imyZzDJr5E ZbdQ== X-Gm-Message-State: ALoCoQl+7fFTM0427oVVggBE0Gl7TKaN9loeNcJuEFPIek5BWVdAC9vaVbFJ5N0ySNjmR7L8oyVn X-Received: by 10.112.26.5 with SMTP id h5mr20847182lbg.4.1433159926667; Mon, 01 Jun 2015 04:58:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.228 with SMTP id z4ls531706lal.90.gmail; Mon, 01 Jun 2015 04:58:46 -0700 (PDT) X-Received: by 10.112.124.166 with SMTP id mj6mr12547870lbb.104.1433159926426; Mon, 01 Jun 2015 04:58:46 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id o5si12149459lae.1.2015.06.01.04.58.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcmx3 with SMTP id mx3so82686597lbc.1 for ; Mon, 01 Jun 2015 04:58:46 -0700 (PDT) X-Received: by 10.152.2.133 with SMTP id 5mr19281111lau.36.1433159926134; Mon, 01 Jun 2015 04:58:46 -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 hn6csp2259300lbb; Mon, 1 Jun 2015 04:58:45 -0700 (PDT) X-Received: by 10.66.142.199 with SMTP id ry7mr40015351pab.14.1433159925118; Mon, 01 Jun 2015 04:58:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rc3si20923151pbc.149.2015.06.01.04.58.43; Mon, 01 Jun 2015 04:58:45 -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 S1753217AbbFAL6h (ORCPT + 28 others); Mon, 1 Jun 2015 07:58:37 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36736 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553AbbFAL6X (ORCPT ); Mon, 1 Jun 2015 07:58:23 -0400 Received: by pdjm12 with SMTP id m12so23235649pdj.3 for ; Mon, 01 Jun 2015 04:58:23 -0700 (PDT) X-Received: by 10.70.94.73 with SMTP id da9mr39991749pdb.28.1433159903172; Mon, 01 Jun 2015 04:58:23 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id we8sm14397983pac.44.2015.06.01.04.58.20 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:58:22 -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 16/25] posix-timers:Convert to the 64bit methods for the clock_getres syscall function Date: Mon, 1 Jun 2015 19:58:09 +0800 Message-Id: <1433159889-5142-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.178 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_getres64 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_getres syscall function, and change the clock_getres syscall implementation. Also add a default 64bit method for the clock_getres64 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 | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index be2123d..35786c5 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -98,6 +98,7 @@ struct k_itimer { struct k_clock { int (*clock_getres) (const clockid_t which_clock, struct timespec *tp); + int (*clock_getres64) (const clockid_t which_clock, struct timespec64 *tp); int (*clock_set) (const clockid_t which_clock, const struct timespec *tp); int (*clock_set64) (const clockid_t which_clock, diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 3bb5bee..d2975d9 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -596,6 +596,20 @@ static int default_clock_get64(const clockid_t which_clock, return ret; } +static int default_clock_getres64(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_getres(which_clock, &tp); + if (!ret) + *tp64 = timespec_to_timespec64(tp); + + return 0; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -610,8 +624,8 @@ void posix_timers_register_clock(const clockid_t clock_id, clock_id); return; } - if (!new_clock->clock_getres) { - printk(KERN_WARNING "POSIX clock id %d lacks clock_getres()\n", + if (!new_clock->clock_getres && !new_clock->clock_getres64) { + printk(KERN_WARNING "POSIX clock id %d lacks clock_getres() and clock_getres64()\n", clock_id); return; } @@ -624,6 +638,8 @@ void posix_timers_register_clock(const clockid_t clock_id, new_clock->clock_set64 = default_clock_set64; if (new_clock->clock_get && !new_clock->clock_get64) new_clock->clock_get64 = default_clock_get64; + if (new_clock->clock_getres && !new_clock->clock_getres64) + new_clock->clock_getres64 = default_clock_getres64; posix_clocks[clock_id] = *new_clock; } @@ -671,7 +687,8 @@ static struct k_clock *clockid_to_kclock(const clockid_t id) return (id & CLOCKFD_MASK) == CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu; - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres) + if (id >= MAX_CLOCKS || (!posix_clocks[id].clock_getres + && !posix_clocks[id].clock_getres64)) return NULL; return &posix_clocks[id]; } @@ -1180,25 +1197,25 @@ SYSCALL_DEFINE2(clock_adjtime, const clockid_t, which_clock, return err; } -static int __clock_getres(clockid_t which_clock, struct timespec *ts) +static int __clock_getres(clockid_t which_clock, struct timespec64 *ts) { struct k_clock *kc = clockid_to_kclock(which_clock); if (!kc) return -EINVAL; - return kc->clock_getres(which_clock, ts); + return kc->clock_getres64(which_clock, ts); } SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct timespec __user *, tp) { - struct timespec rtn_tp; + struct timespec64 rtn_tp; int error; error = __clock_getres(which_clock, &rtn_tp); - if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp))) + if (!error && tp && put_timespec(&rtn_tp, tp)) error = -EFAULT; return error;