From patchwork Thu Jan 22 02:31:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 43487 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 31DD5240D5 for ; Thu, 22 Jan 2015 02:33:54 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf13449355lbv.1 for ; Wed, 21 Jan 2015 18:33:52 -0800 (PST) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=r9UA2a3BOX7SsutDoaY9GfnQxLGZn7X2CO8bLo/Vz3I=; b=lEz1RfTE67YV9N7VgW70/L8Ng9G4Z1ulfxNaM+l6+zhdEFh9BMQWGPYDsRsM8Zg1XW hYtwe5jq8lCdCE2ZCBBCauqUs8Hhaga9q2NXY0+CQQrcoXx+/0LUPxVRUaOVt9vJzniU N4MnfjWSuNEe1M77uptihEAVd+bEgj+T+aXtK/mTcZGHJbgIj503BbIqoEIP5vvQHOqW +GrqprQP+Z4hnCK7t4N/vAJhBZ+OYV8ecQt/gatviN7GZnnWuIYvmAgOjWUHuV3lqb6P iIws9aeOTFqr5hQO3FNx4pFrVZrmpCdiubfsOAHLBXg9S8CzadZU0+XArAsj8w2Vbajt M5Lg== X-Gm-Message-State: ALoCoQmKFQi5vB/1kTqBZlwCP1zFvuVqDXW5u/t2z2Ht6ce5WHf/ykR0AyDtX3RxiYVRjTR2wsQC X-Received: by 10.152.36.168 with SMTP id r8mr1284513laj.2.1421894032827; Wed, 21 Jan 2015 18:33:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.67 with SMTP id de3ls108350lac.60.gmail; Wed, 21 Jan 2015 18:33:52 -0800 (PST) X-Received: by 10.112.97.163 with SMTP id eb3mr40751514lbb.47.1421894032652; Wed, 21 Jan 2015 18:33:52 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id n2si19530554lbs.48.2015.01.21.18.33.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 18:33:52 -0800 (PST) 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 mail-la0-f52.google.com with SMTP id hs14so43624054lab.11 for ; Wed, 21 Jan 2015 18:33:52 -0800 (PST) X-Received: by 10.152.182.235 with SMTP id eh11mr30235347lac.9.1421894032565; Wed, 21 Jan 2015 18:33:52 -0800 (PST) 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.9.200 with SMTP id c8csp110171lbb; Wed, 21 Jan 2015 18:33:51 -0800 (PST) X-Received: by 10.70.29.67 with SMTP id i3mr39204408pdh.132.1421894030706; Wed, 21 Jan 2015 18:33:50 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qt7si10546475pbc.63.2015.01.21.18.33.49; Wed, 21 Jan 2015 18:33:50 -0800 (PST) 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 S1754684AbbAVCdq (ORCPT + 28 others); Wed, 21 Jan 2015 21:33:46 -0500 Received: from mail-qc0-f174.google.com ([209.85.216.174]:58854 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754343AbbAVCcI (ORCPT ); Wed, 21 Jan 2015 21:32:08 -0500 Received: by mail-qc0-f174.google.com with SMTP id s11so18926861qcv.5 for ; Wed, 21 Jan 2015 18:32:07 -0800 (PST) X-Received: by 10.229.192.5 with SMTP id do5mr74820534qcb.12.1421893927520; Wed, 21 Jan 2015 18:32:07 -0800 (PST) Received: from ip-10-181-65-231.ec2.internal ([54.235.93.228]) by mx.google.com with ESMTPSA id w9sm5174891qab.18.2015.01.21.18.32.06 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Jan 2015 18:32:07 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Thomas Gleixner , Alessandro Zummo , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [PATCH 3/5] rtc: Modify rtc_hctosys() to address y2038 issues Date: Thu, 22 Jan 2015 02:31:53 +0000 Message-Id: <1421893915-19309-3-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1421893915-19309-1-git-send-email-pang.xunlei@linaro.org> References: <1421893915-19309-1-git-send-email-pang.xunlei@linaro.org> 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: pang.xunlei@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: , rtc_hctosys() has a number of y2038 issues. This patch resolves them by: - Replace rtc_tm_to_time() with y2038-safe rtc_tm_to_time64() - Replace do_settimeofday() with y2038-safe do_settimeofday64() After this patch, it should not have any remaining y2038 issues. Reviewed-by: John Stultz Reviewed-by: Arnd Bergmann Signed-off-by: Xunlei Pang --- drivers/rtc/hctosys.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 4aa60d7..2153b52 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -26,7 +26,7 @@ static int __init rtc_hctosys(void) { int err = -ENODEV; struct rtc_time tm; - struct timespec tv = { + struct timespec64 tv64 = { .tv_nsec = NSEC_PER_SEC >> 1, }; struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); @@ -52,16 +52,16 @@ static int __init rtc_hctosys(void) goto err_invalid; } - rtc_tm_to_time(&tm, &tv.tv_sec); + tv64.tv_sec = rtc_tm_to_time64(&tm); - err = do_settimeofday(&tv); + err = do_settimeofday64(&tv64); dev_info(rtc->dev.parent, "setting system clock to " - "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", + "%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, - (unsigned int) tv.tv_sec); + (long long) tv64.tv_sec); err_invalid: err_read: