From patchwork Mon Jun 1 12:04:03 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: 49319 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 01A32218FC for ; Mon, 1 Jun 2015 12:04:40 +0000 (UTC) Received: by wifx6 with SMTP id x6sf22282750wif.1 for ; Mon, 01 Jun 2015 05:04:39 -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=4QNcw/I+4nWEM8DpOqV0L44Mgy4EbPQTcQOZidZccW0=; b=LcdKPLaKjjB0hbuaxdXPkSM86yaxrfB39hv+vJ+v1jY6tyPzJ9wXmXFa5bD3agdGXy WPHda9co0ZE6k+KurCpLlEW1NMdFbIShEUevX+m2htbSYZVV/CsINkyz+d2fe3nWiu2V Wa0CZp3H+pBHPyh/3zU7S0hYRb+RXGlkE1JHQTZAwAOL/cvXEVu5iwQyunaFWPDvxO6g oFpBKAwH0WelvLt2NPinOKEquhZGfaV/dXXM/f4t8iFKijurHCQy7kAFt3v/7qrsiW8M rZ9o+PT/nxjdD6VXISdeOpYGukbHg1ZEwdLxxE/FrLgf7VareCVudfxzlAjmgbggxmL2 M07w== X-Gm-Message-State: ALoCoQlP7p8uBIZ/+4S5egD0PUhwnLFYwQnD2KQpLT1M5z6jdfTkTnKq6R/2Nd+lxNZVPRd9b9ze X-Received: by 10.180.106.10 with SMTP id gq10mr11375481wib.0.1433160279165; Mon, 01 Jun 2015 05:04:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.9 with SMTP id ky9ls526369lab.98.gmail; Mon, 01 Jun 2015 05:04:38 -0700 (PDT) X-Received: by 10.152.197.2 with SMTP id iq2mr20850844lac.103.1433160278974; Mon, 01 Jun 2015 05:04:38 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id ay17si12162521lab.9.2015.06.01.05.04.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 05:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labko7 with SMTP id ko7so95926307lab.2 for ; Mon, 01 Jun 2015 05:04:38 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr20728488lbc.19.1433160278720; Mon, 01 Jun 2015 05:04:38 -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 hn6csp2263140lbb; Mon, 1 Jun 2015 05:04:37 -0700 (PDT) X-Received: by 10.66.165.8 with SMTP id yu8mr39883122pab.82.1433160274637; Mon, 01 Jun 2015 05:04:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha8si19351743pac.226.2015.06.01.05.04.33; Mon, 01 Jun 2015 05:04:34 -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 S1753468AbbFAME2 (ORCPT + 28 others); Mon, 1 Jun 2015 08:04:28 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:36674 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752950AbbFAMES (ORCPT ); Mon, 1 Jun 2015 08:04:18 -0400 Received: by pdjm12 with SMTP id m12so23347337pdj.3 for ; Mon, 01 Jun 2015 05:04:18 -0700 (PDT) X-Received: by 10.68.107.97 with SMTP id hb1mr2470977pbb.143.1433160258292; Mon, 01 Jun 2015 05:04:18 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id q4sm14342426pdo.42.2015.06.01.05.04.15 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 05:04:17 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, john.stultz@linaro.org, ahh@google.com, pjt@google.com, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v4 22/25] time/time:Introduce the timespec64_to_jiffies()/jiffies_to_timespec64() function Date: Mon, 1 Jun 2015 20:04:03 +0800 Message-Id: <1433160243-5367-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.41 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: , To make it is ready for 2038 issue when implementing the conversion between cputime and timespec64, this patch introduces the timespec64_to_jiffies() and jiffies_to_timespec64() functions. And move the old functions timespec64_to_jiffies() and jiffies_to_timespec64() to jiffies.h file, for it is convenient to delete them later. Signed-off-by: Baolin Wang --- include/linux/jiffies.h | 21 ++++++++++++++++++--- kernel/time/time.c | 12 ++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index c367cbd..36c0461 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -290,9 +290,24 @@ static inline u64 jiffies_to_nsecs(const unsigned long j) extern unsigned long msecs_to_jiffies(const unsigned int m); extern unsigned long usecs_to_jiffies(const unsigned int u); -extern unsigned long timespec_to_jiffies(const struct timespec *value); -extern void jiffies_to_timespec(const unsigned long jiffies, - struct timespec *value); +extern unsigned long __timespec_to_jiffies(unsigned long sec, long nsec); +extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); +extern void jiffies_to_timespec64(const unsigned long jiffies, + struct timespec64 *value); +static inline unsigned long timespec_to_jiffies(const struct timespec *value) +{ + return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); +} + +static inline void jiffies_to_timespec(const unsigned long jiffies, + struct timespec *value) +{ + struct timespec64 ts; + + jiffies_to_timespec64(jiffies, &ts); + *value = timespec64_to_timespec(ts); +} + extern unsigned long timeval_to_jiffies(const struct timeval *value); extern void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value); diff --git a/kernel/time/time.c b/kernel/time/time.c index 33c539b..2ffb5e7 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -569,7 +569,7 @@ EXPORT_SYMBOL(usecs_to_jiffies); * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec * value to a scaled second value. */ -static unsigned long +unsigned long __timespec_to_jiffies(unsigned long sec, long nsec) { nsec = nsec + TICK_NSEC - 1; @@ -583,17 +583,17 @@ __timespec_to_jiffies(unsigned long sec, long nsec) (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; } +EXPORT_SYMBOL(__timespec_to_jiffies); unsigned long -timespec_to_jiffies(const struct timespec *value) +timespec64_to_jiffies(const struct timespec64 *value) { return __timespec_to_jiffies(value->tv_sec, value->tv_nsec); } - -EXPORT_SYMBOL(timespec_to_jiffies); +EXPORT_SYMBOL(timespec64_to_jiffies); void -jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) +jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value) { /* * Convert jiffies to nanoseconds and separate with @@ -604,7 +604,7 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) NSEC_PER_SEC, &rem); value->tv_nsec = rem; } -EXPORT_SYMBOL(jiffies_to_timespec); +EXPORT_SYMBOL(jiffies_to_timespec64); /* * We could use a similar algorithm to timespec_to_jiffies (with a