From patchwork Wed Mar 11 03:24:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 45618 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 B4746214BF for ; Wed, 11 Mar 2015 03:28:13 +0000 (UTC) Received: by lbdu14 with SMTP id u14sf4493025lbd.3 for ; Tue, 10 Mar 2015 20:28:12 -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=QJncUKFwmYPP7YUbLehFSUX9PtPdyWjS5yMXBXiu0Y0=; b=TnG46Ws4Lj5NeFCqDCQifmm0ME1sT7NSW0NJsFybgc0RjygXIS1TmkYGpGq1/sF3KC PQ2hv3ouSDYK71JsnlYFr+WntW3St2387i+C+JCBDgbFBn5mQJ05LSxzGpGhh5x/ccbt +uajRefj3YPLiTgo9XIbofh6ZAGPTYK+KIXIxbg9Qk2rQSQYT3B/oy9KVpzzq7zms28+ BDJ9CopTtwoi/eWTD7hukU2bVbeEvm5Ux3pkQ8GtxTr//j28gg7r2nLGg1QVEIESRXqD ZY6iNSCZ13/Tvw0Jj/uYNIKucrIQar8S8O9jFM5AKhLXgtEkoFi4P6wr/R4lZOQqJPoh M2Vg== X-Gm-Message-State: ALoCoQkcXzJJOxNszKsBk8q0UKL6JePc+iU1tjsKZbZhE0o394zO3i+OXQNYGHH7pJslA/U8i3Ss X-Received: by 10.180.87.166 with SMTP id az6mr101200wib.1.1426044492700; Tue, 10 Mar 2015 20:28:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.208 with SMTP id l16ls96117laa.66.gmail; Tue, 10 Mar 2015 20:28:12 -0700 (PDT) X-Received: by 10.112.156.170 with SMTP id wf10mr33889244lbb.102.1426044492506; Tue, 10 Mar 2015 20:28:12 -0700 (PDT) Received: from mail-lb0-x22e.google.com (mail-lb0-x22e.google.com. [2a00:1450:4010:c04::22e]) by mx.google.com with ESMTPS id f2si1464535lbc.134.2015.03.10.20.28.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 20:28:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) client-ip=2a00:1450:4010:c04::22e; Received: by lbjf15 with SMTP id f15so6090203lbj.2 for ; Tue, 10 Mar 2015 20:28:12 -0700 (PDT) X-Received: by 10.112.162.167 with SMTP id yb7mr32228323lbb.76.1426044492399; Tue, 10 Mar 2015 20:28:12 -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.35.133 with SMTP id h5csp2515657lbj; Tue, 10 Mar 2015 20:28:11 -0700 (PDT) X-Received: by 10.70.26.100 with SMTP id k4mr72749379pdg.125.1426044490617; Tue, 10 Mar 2015 20:28:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk6si4508597pab.89.2015.03.10.20.28.09; Tue, 10 Mar 2015 20:28:10 -0700 (PDT) Received-SPF: none (google.com: linux-omap-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 S1752914AbbCKD2B (ORCPT + 5 others); Tue, 10 Mar 2015 23:28:01 -0400 Received: from m15-112.126.com ([220.181.15.112]:43441 "EHLO m15-112.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbbCKD15 (ORCPT ); Tue, 10 Mar 2015 23:27:57 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp2 (Coremail) with SMTP id DMmowEBpY1t7tf9UtpRwAw--.964S2; Wed, 11 Mar 2015 11:24:49 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , John Stultz , Arnd Bergmann , linux-omap@vger.kernel.org, Tony Lindgren , linux-tegra@vger.kernel.org, Stephen Warren , linux390@de.ibm.com, Martin Schwidefsky , Ralf Baechle , Arnd Bergmann , Xunlei Pang Subject: [PATCH 5/8] ARM: tegra: clock: Provide y2038-safe tegra_read_persistent_clock() replacement Date: Wed, 11 Mar 2015 11:24:34 +0800 Message-Id: <1426044277-22170-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DMmowEBpY1t7tf9UtpRwAw--.964S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7trWxWrW8Xr4ftryrWr4kJFb_yoW8KFW3pF WxA34UGw4Yq3Wqv3Zrt3WDCwn8Ka4rZFW2q34rt34Svr1UtFy7K3W5CayjyF9rXrWkJa47 Zr4Fy3W5Ww4DZ3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jg0eQUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi7wW5v00vbbOhzwAAs+ Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22e as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com 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: , From: Xunlei Pang As part of addressing "y2038 problem" for in-kernel uses, this patch adds the y2038-safe tegra_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, tegra_read_persistent_clock() will be removed then. Signed-off-by: Xunlei Pang --- drivers/clocksource/tegra20_timer.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/tegra20_timer.c b/drivers/clocksource/tegra20_timer.c index d2616ef..7fc7fb9 100644 --- a/drivers/clocksource/tegra20_timer.c +++ b/drivers/clocksource/tegra20_timer.c @@ -51,7 +51,7 @@ static void __iomem *timer_reg_base; static void __iomem *rtc_base; -static struct timespec persistent_ts; +static struct timespec64 persistent_ts; static u64 persistent_ms, last_persistent_ms; static struct delay_timer tegra_delay_timer; @@ -120,26 +120,33 @@ static u64 tegra_rtc_read_ms(void) } /* - * tegra_read_persistent_clock - Return time from a persistent clock. + * tegra_read_persistent_clock64 - Return time from a persistent clock. * * Reads the time from a source which isn't disabled during PM, the * 32k sync timer. Convert the cycles elapsed since last read into - * nsecs and adds to a monotonically increasing timespec. + * nsecs and adds to a monotonically increasing timespec64. * Care must be taken that this funciton is not called while the * tegra_rtc driver could be executing to avoid race conditions * on the RTC shadow register */ -static void tegra_read_persistent_clock(struct timespec *ts) +static void tegra_read_persistent_clock64(struct timespec64 *ts) { u64 delta; - struct timespec *tsp = &persistent_ts; last_persistent_ms = persistent_ms; persistent_ms = tegra_rtc_read_ms(); delta = persistent_ms - last_persistent_ms; - timespec_add_ns(tsp, delta * NSEC_PER_MSEC); - *ts = *tsp; + timespec64_add_ns(&persistent_ts, delta * NSEC_PER_MSEC); + *ts = persistent_ts; +} + +static void tegra_read_persistent_clock(struct timespec *ts) +{ + struct timespec ts64; + + tegra_read_persistent_clock64(&ts64); + *ts = timespec64_to_timespec(ts64); } static unsigned long tegra_delay_timer_read_counter_long(void)