From patchwork Mon May 11 11:17:43 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: 48249 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 9715121550 for ; Mon, 11 May 2015 11:17:59 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf37770840lbb.3 for ; Mon, 11 May 2015 04:17:58 -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=aOeKn1AllAV/n1q5xGzGuxrFxof3cF/O+l3T80LrSWQ=; b=dowhKi44C7UcSgSp52VO1b2c9RHLPYk1nfAB75KTY2eF1zy9RYPS/WCp9wijQjoMqz QofEAeYVeciMEvq1pu0Uz+DLasqqeKpe5uLF4yQFnH5zwUdfH2SLNcleQ1YU5j9bS7mB K+1z1E8DUovdezRlBJLp/o8ghhIyptc9LuSn+n/99f8ngxrf8RlZWSq44KwtveMQjaIy 7iQ8qHm05qDFYR0Fhl9BEwL1JMWTQyG0Eriw4rh4HAlHeiTsZwOXjYVJjXXodY64c4tu kbTGFJv8dj4JL89xEhMCAe+c+Bjx3X26LKG0FcpNkZbDKKPjn9B5DSxIC1uIZGSB3s/G IECw== X-Gm-Message-State: ALoCoQmGkFeYesw99kT6g26+AGC6BXBN0BBoS89j/Ja6hiBOWjd8yPgE3UWaVmGzIGH58i5obH9R X-Received: by 10.112.13.200 with SMTP id j8mr7295081lbc.14.1431343078523; Mon, 11 May 2015 04:17:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.229 with SMTP id jf5ls581306lac.56.gmail; Mon, 11 May 2015 04:17:58 -0700 (PDT) X-Received: by 10.112.167.73 with SMTP id zm9mr7681691lbb.89.1431343078352; Mon, 11 May 2015 04:17:58 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id y1si8181384lag.66.2015.05.11.04.17.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 04:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbuc2 with SMTP id uc2so91205347lbb.2 for ; Mon, 11 May 2015 04:17:58 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr7918048lad.56.1431343078255; Mon, 11 May 2015 04:17:58 -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 hn6csp1443795lbb; Mon, 11 May 2015 04:17:57 -0700 (PDT) X-Received: by 10.68.116.132 with SMTP id jw4mr18259825pbb.107.1431343076531; Mon, 11 May 2015 04:17:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pu1si17463689pbb.242.2015.05.11.04.17.55; Mon, 11 May 2015 04:17:56 -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 S1753934AbbEKLRv (ORCPT + 28 others); Mon, 11 May 2015 07:17:51 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34172 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753517AbbEKLRt (ORCPT ); Mon, 11 May 2015 07:17:49 -0400 Received: by pacyx8 with SMTP id yx8so107642382pac.1 for ; Mon, 11 May 2015 04:17:49 -0700 (PDT) X-Received: by 10.70.124.131 with SMTP id mi3mr18422652pdb.28.1431343069454; Mon, 11 May 2015 04:17:49 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id fm3sm12831735pdb.28.2015.05.11.04.17.47 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 May 2015 04:17:48 -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 13/22] posix-timers:Convert to the 64bit methods for the clock_getres syscall function Date: Mon, 11 May 2015 19:17:43 +0800 Message-Id: <1431343063-29877-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.174 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. Convert to the 64bit method with timespec64 type for the clock_getres syscall function, and change the clock_getres syscall implementation according the the CONFIG_64BIT macro. Signed-off-by: Baolin Wang --- include/linux/posix-timers.h | 1 + kernel/time/posix-timers.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index c08a536..9a5a211 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 456c588..b93b637 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -555,6 +555,16 @@ static int default_clock_get64(const clockid_t which_clock, return 0; } +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; + + kc->clock_getres(which_clock, &tp); + return 0; +} + void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock) { @@ -569,8 +579,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; } @@ -583,6 +593,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; } @@ -630,7 +642,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]; } @@ -1182,23 +1195,31 @@ 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; int error; - +#ifdef CONFIG_64BIT + struct timespec64 rtn_tp; error = __clock_getres(which_clock, &rtn_tp); +#else + struct timespec64 rtn_tp64; + struct timespec rtn_tp; + + error = __clock_getres(which_clock, &rtn_tp64); + if (!error) + rtn_tp = timespec64_to_timespec(rtn_tp64); +#endif if (!error && tp && copy_to_user(tp, &rtn_tp, sizeof (rtn_tp))) error = -EFAULT;