From patchwork Mon Oct 26 15:22:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deng Chao X-Patchwork-Id: 55571 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1263457lbq; Mon, 26 Oct 2015 08:23:22 -0700 (PDT) X-Received: by 10.50.4.33 with SMTP id h1mr19354147igh.24.1445873001060; Mon, 26 Oct 2015 08:23:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e87si8236136iod.189.2015.10.26.08.23.20; Mon, 26 Oct 2015 08:23:21 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbbJZPXP (ORCPT + 28 others); Mon, 26 Oct 2015 11:23:15 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:33950 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbbJZPXL (ORCPT ); Mon, 26 Oct 2015 11:23:11 -0400 Received: by padhk11 with SMTP id hk11so191579227pad.1 for ; Mon, 26 Oct 2015 08:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+VyucygZHLAi8RJWNVBQ6LU4PKKu6nNVjmwLRQ8VKEA=; b=I5XKvgPG4zyZwNtRKM7IGUsqtyCUP3AmgXPY3BdwOFSOz2mp1cETfo7ByYkQHEMbPV aB461Y3MJ3X/+ITD4ACzmPstqvKxfqZ3s0E4FslDO1leqCB6s7Xxj/8AV22ImzuEATwE zOoo8QqAlgZF7nx/z4hPQMyKVLXvAT1s203Wj+CNURDhBsyNNCtLSJK0WIM+UtSYP2CH Dm81m8humyhSawunH9FHZxdcnz7UBATQKLP4ka55Q7a8kPxXVDNYMQq4DrrvNorfmGD4 80qd4OnDEhdn1pKoER7E94BmCsp6hUqDl16f2Rs7lDI4U0uiZ0miICtqP7YNzyBzMMoN o1Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+VyucygZHLAi8RJWNVBQ6LU4PKKu6nNVjmwLRQ8VKEA=; b=XHM/IM8TJtsVGQu3SgY9QMx/gJO07djZz+elU+Lhm4RLOCDJzUcscB6vGI2PbziW45 E+wHU32Yh4Kxy7gEeAA3DkYqEHxSegw2MJzkMaPelPdOqEqozmMziH6yi3vmwMhwBktG XplDd3wOWesx6xeGXebWX+OLnZfj0QP1nxEAFVo+V4L1+qQx7Tw/auvGrHWhDK97hgGM YFs1yAqQzw7bvVMVWq6/CUolGXWNfK72ox7yHZx6fBoRuvaDXPmPG2vN1PGJd+1HRslE mlK/sDKGBj8YMNImjN4XYxkfhcfJ0NezfT5otbuP0wPcxMQTj7l2ALPky0YEE8LdULca 62FA== X-Gm-Message-State: ALoCoQkTdj4qrWSvk47u3Cm9pEKmyQ0yOkiRY8gZfVuGJ9AkBu8siVVbWTuNYC+SqVA3OXDNCgOj X-Received: by 10.66.55.66 with SMTP id q2mr22410039pap.109.1445872990722; Mon, 26 Oct 2015 08:23:10 -0700 (PDT) Received: from localhost.localdomain ([167.160.116.82]) by smtp.gmail.com with ESMTPSA id ez1sm12232122pab.6.2015.10.26.08.23.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Oct 2015 08:23:10 -0700 (PDT) From: DengChao To: linux-kernel@vger.kernel.org Cc: chao.deng@linaro.org Subject: [PATCH 2/2] ntp:Change the type of time_reftime to time64_t and Date: Mon, 26 Oct 2015 23:22:43 +0800 Message-Id: <1445872963-29988-3-git-send-email-chao.deng@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445872963-29988-1-git-send-email-chao.deng@linaro.org> References: <1445872963-29988-1-git-send-email-chao.deng@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The type of static variant "time_reftime" and the call of get_seconds in ntp are both not y2038 safe. So change the type of time_reftime to time64_t and replace get_seconds with __ktime_get_real_seconds. The local variant "secs" in ntp_update_offset represents seconds between now and last ntp adjustment, it seems impossible that this time will last more than 68 years, so keep its type as "long". Signed-off-by: DengChao --- kernel/time/ntp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index fb4d98c..71628d0 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -18,6 +18,8 @@ #include #include "ntp_internal.h" +#include "timekeeping_internal.h" + /* * NTP timekeeping variables: @@ -70,7 +72,7 @@ static long time_esterror = NTP_PHASE_LIMIT; static s64 time_freq; /* time at last adjustment (secs): */ -static long time_reftime; +static time64_t time_reftime; static long time_adjust; @@ -311,11 +313,11 @@ static void ntp_update_offset(long offset) * Select how the frequency is to be controlled * and in which mode (PLL or FLL). */ - secs = get_seconds() - time_reftime; + secs = (long)(__ktime_get_real_seconds() - time_reftime); if (unlikely(time_status & STA_FREQHOLD)) secs = 0; - time_reftime = get_seconds(); + time_reftime = __ktime_get_real_seconds(); offset64 = offset; freq_adj = ntp_update_offset_fll(offset64, secs); @@ -585,7 +587,7 @@ static inline void process_adj_status(struct timex *txc, struct timespec64 *ts) * reference time to current time. */ if (!(time_status & STA_PLL) && (txc->status & STA_PLL)) - time_reftime = get_seconds(); + time_reftime = __ktime_get_real_seconds(); /* only set allowed bits */ time_status &= STA_RONLY;