From patchwork Tue May 12 14:12:15 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: 48386 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F4582121F for ; Tue, 12 May 2015 14:13:15 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf2410547lab.1 for ; Tue, 12 May 2015 07:13:13 -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=1fFo9FQ3xTEqkLpzPPRcOx4QH5v00V+OFAnX6Jbc/wY=; b=Umqp2CQPZlzqvxSnM7+W7N2I/38lfCtDU3fzskDo8wIcy4ohaFPmzFabdA+o2iv4gl 7Wc++PQ32uUc/3czFkGq/f+8xueIKqtHQuqfQT+/zx4O0jLFIt98eMEvF3JI9JxTZF9W ELpApwrZlME5voWwXSaB789nVn/+uuUlNlDkL+bPksy8Uy31hB0jUfAt/0aGOqkRtB4z swy9TDiYgBnUXyonJpf/vyPLXl3e6VzM3QCG6CiC49dZkgs3DMD48HkWVIPc9LBDUzHT J5you+WVbwBglNP/jAAyTu+er8K0K2o3Pq1VKovRZoAMowBwPfAs+qYWJdl/4pHlArfM Avbg== X-Gm-Message-State: ALoCoQlW3mL2iTXbszmILT3ylEV8Dc4KZNkr947+dAh4kzbv9sEdM4HOtboZQIWO55XIDg9avb3Z X-Received: by 10.112.26.5 with SMTP id h5mr10804293lbg.4.1431439993919; Tue, 12 May 2015 07:13:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.10 with SMTP id p10ls42385lag.29.gmail; Tue, 12 May 2015 07:13:13 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr3988064lak.117.1431439993747; Tue, 12 May 2015 07:13:13 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id u8si10453907laz.27.2015.05.12.07.13.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 07:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laat2 with SMTP id t2so6930185laa.1 for ; Tue, 12 May 2015 07:13:13 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr12267527lbc.86.1431439993464; Tue, 12 May 2015 07:13:13 -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 hn6csp2117458lbb; Tue, 12 May 2015 07:13:12 -0700 (PDT) X-Received: by 10.70.89.199 with SMTP id bq7mr28118152pdb.168.1431439991660; Tue, 12 May 2015 07:13:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fe6si22750859pdb.84.2015.05.12.07.12.51; Tue, 12 May 2015 07:13:11 -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 S933146AbbELOMX (ORCPT + 28 others); Tue, 12 May 2015 10:12:23 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:35776 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933041AbbELOMW (ORCPT ); Tue, 12 May 2015 10:12:22 -0400 Received: by pdbqd1 with SMTP id qd1so13909119pdb.2 for ; Tue, 12 May 2015 07:12:21 -0700 (PDT) X-Received: by 10.66.139.70 with SMTP id qw6mr28490567pab.112.1431439941657; Tue, 12 May 2015 07:12:21 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id eu5sm16388619pbb.44.2015.05.12.07.12.19 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 07:12:21 -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 14/23] posix-timers:Convert to the 64bit methods for the clock_getres syscall function Date: Tue, 12 May 2015 22:12:15 +0800 Message-Id: <1431439935-6090-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.215.52 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 according to the CONFIG_64BIT macro. 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 | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 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 a9e14cf..e0a6a09 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -567,6 +567,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) { @@ -581,8 +595,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; } @@ -595,6 +609,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; } @@ -642,7 +658,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]; } @@ -1195,23 +1212,32 @@ 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;