From patchwork Sun Dec 13 04:24:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deng Chao X-Patchwork-Id: 58317 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp768367lbv; Sat, 12 Dec 2015 20:25:20 -0800 (PST) X-Received: by 10.66.246.161 with SMTP id xx1mr12997136pac.106.1449980720113; Sat, 12 Dec 2015 20:25:20 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fd9si8794963pac.80.2015.12.12.20.25.19; Sat, 12 Dec 2015 20:25:20 -0800 (PST) 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 S1751879AbbLMEZP (ORCPT + 28 others); Sat, 12 Dec 2015 23:25:15 -0500 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33353 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbbLMEZK (ORCPT ); Sat, 12 Dec 2015 23:25:10 -0500 Received: by pfnn128 with SMTP id n128so87312553pfn.0 for ; Sat, 12 Dec 2015 20:25:09 -0800 (PST) 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=05eco3OmicPZSC+E8jKrmA3mQv42MOF7BfFX14l64kU=; b=LMvSYJ3oNe3+OIBc2krXScKtyRCdVGtClNeySDfitV+C5lDpEm4YVKpGGT7qDiXdQ+ OXlkhv8RvHWwWomNQPTDYPBItr5BHx651om0tbmwoWKEdIE+QfYkglSuduEmrM6NlyjA irTK1nF9HSTyU0lyRMev+xQ9pyhp0hYtV2oano9UlNH0MgOUV2Jq9JSeGxKcyW4sY2Rk ihb1YHjt5MVNl1iQdF/zSpl+U7XFzNbEjQE9OeC/7SmiKcIkzvlLOVYWBA7teCzkfPtD w2nmWG/Yuo8jOU3yG9Fxc8tSBaHwQYsWRem3d117qxQnGTzzaFT/s2Z4xpzuXwdKHl10 uYJA== 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=05eco3OmicPZSC+E8jKrmA3mQv42MOF7BfFX14l64kU=; b=iveCQARl5Cg9U7sfoEtTSw6/Hrh3KVic7Dqg9czYoMACowef/i6LQ4Vw7q1NdPpWJ5 TOiGXUshxIhYIUGDnLL8qjHbWIhGydW1bT2Qdu8EHVZJe5T3MnjOylwvGH9A/qFPXKdW V5huJn2CIEupLvhLhf4d9suk5F+2dvRgQDwTvMfEcJAqvwz3MBqHgeC3Qn8qrWENhDP4 +5/RYoLgPcBkKYL4raSdgegEkejCEBJIFaygjttcmrErOHYLOCkgguf2C4MXy+XbMuUm ZV+dnc4fc58/zOtr690YRDgf8ots4E0csOYT3ZkCwGEF6S2PL2HVg56RIP8nru6ar0CZ Diwg== X-Gm-Message-State: ALoCoQl+XhjzLeW2pbMeHv3FvpMEYV5M+ZDxLX06b43/5ely3Ha9mQuM3ag7rrCV0VLoOIlNXivuSVic0RhvhpTv6MiUA2OJEQ== X-Received: by 10.98.72.152 with SMTP id q24mr26770981pfi.156.1449980709594; Sat, 12 Dec 2015 20:25:09 -0800 (PST) Received: from localhost.localdomain ([167.160.116.42]) by smtp.gmail.com with ESMTPSA id by2sm34454489pab.20.2015.12.12.20.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 12 Dec 2015 20:25:09 -0800 (PST) From: DengChao To: linux-kernel@vger.kernel.org, tglx@linutronix.de, john.stultz@linaro.org Cc: chao.deng@linaro.org Subject: [PATCH 2/2] ntp:Change the type of time_reftime to time64_t and replace get_seconds with __ktime_get_real_seconds Date: Sun, 13 Dec 2015 12:24:19 +0800 Message-Id: <1449980659-2948-3-git-send-email-chao.deng@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449980659-2948-1-git-send-email-chao.deng@linaro.org> References: <1449980659-2948-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". Reviewed-by: John Stultz 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 149cc80..f9b9d8e 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); @@ -590,7 +592,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;