From patchwork Mon Jun 19 09:36:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9795617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 762C160381 for ; Mon, 19 Jun 2017 09:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1332623C for ; Mon, 19 Jun 2017 09:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A12BA26E4A; Mon, 19 Jun 2017 09:50:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 27C2B27F92 for ; Mon, 19 Jun 2017 09:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Sa2itI2MvRTxuXfnqZBNoZ53SQ1pKAn6iHwQ3lNqDzU=; b=WQgFQltrywDG8N2LdoNF6sTFVy FZekZxiaA0/og4hadR05g2k+bxVdFufTFTYIxN5FvoCb1AhmlBANtB/ftDLVU7vFU7CS/omlJJQqN L5ah0TRt5jGxqVWhQxr2MnFyvnGosHmYejrFVrqk7EwqF/PIiZglwhRH/FFo3lyaF8GjmZUYpsXgm B+1BRNK48W0Dw0+zSImohvA2V6Af6JmD+3RgDtRKSmVA53ZRZP4QXsRMKZpRq1WPaotd30VuCyVX7 5KOCgiqpMAMyNKle0fvOZMv7KhmM2hGSxpyDYKZAr+w1xAeleFeU3sbzOg/Xn+E+Z3qnzAPWWaFFq kqLe4QQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dMtKM-0003fH-LN; Mon, 19 Jun 2017 09:50:34 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dMt7Z-0005zQ-4c for linux-arm-kernel@lists.infradead.org; Mon, 19 Jun 2017 09:37:23 +0000 Received: by mail-wm0-x22c.google.com with SMTP id x70so73700365wme.0 for ; Mon, 19 Jun 2017 02:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F/N9eNsJZr2+7DPpKTbXLtBvEtQ7sHqQMh9idFnIQbQ=; b=Ngm4UyNcUo3CerdtKtpWTMmFHkCrcc03iQitey690RPW7OyKZazYrnzYl7muCA4wSo gbeOGKVZ7r4knPjJhUxSX5McYF36EUaLklaXV7KdU2xnCEeHAzbonvMq497XA8imr0g0 3aFlHU3BOrsBRtqXlRyj7q5JmxaJxMptnx6p8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F/N9eNsJZr2+7DPpKTbXLtBvEtQ7sHqQMh9idFnIQbQ=; b=TpGHcoSOyyrn3sBkBNmBe48qpKxFob8ovRBsGLMfUcxTP1hinUMQd/HoeOBCOeRnIE oV3VAVvUTS6tY5CYxVKLTiI8Pprn/NUdemSrBLU6NMylkIhEz71W7d0lezTLEHLBax7B Sgd/H9QM1CG9trCbIIRInT1CLkAQaPFMOIv8C71kzdijihoUr/LbhCOPoNYBf/wAy1Qf vvNv0W+J+jH4hQ6XjE1fewjIUaZiyF+4thvhEAtIXgETdaY83Btyn3U3lxGJq8CMeINa Y4dSZu8023hPyeXGDriQ97VTL1koQEL/08vrap5BVokvhGrZm5jSvVggnPfcklj0kTkR /O+Q== X-Gm-Message-State: AKS2vOzo4lm+WRKrNbaY8ZV2erHrZI5xjxFzeAvXE5DVpAd5q/mK00Vz CmAtqbH4KYy8TIx1 X-Received: by 10.28.126.67 with SMTP id z64mr4340008wmc.65.1497865019445; Mon, 19 Jun 2017 02:36:59 -0700 (PDT) Received: from lmenx321.st.com. ([80.215.35.135]) by smtp.gmail.com with ESMTPSA id y2sm11037024wme.12.2017.06.19.02.36.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jun 2017 02:36:59 -0700 (PDT) From: Benjamin Gaignard To: john.stultz@linaro.org, tglx@linutronix.de, sboyd@codeaurora.org, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, patrice.chotard@st.com, a.zummo@towertech.it, alexandre.belloni@free-electrons.com, linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com Subject: [PATCH v2 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Date: Mon, 19 Jun 2017 11:36:22 +0200 Message-Id: <1497864982-29284-4-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497864982-29284-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497864982-29284-1-git-send-email-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170619_023721_586084_5B2008C8 X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linaro-kernel@lists.linaro.org, Benjamin Gaignard MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Make driver use u64 variables and functions to be sure that it will support dates after year 2038. Signed-off-by: Benjamin Gaignard Acked-by: Patrice Chotard --- drivers/rtc/rtc-st-lpc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-st-lpc.c b/drivers/rtc/rtc-st-lpc.c index 74c0a33..82b0af1 100644 --- a/drivers/rtc/rtc-st-lpc.c +++ b/drivers/rtc/rtc-st-lpc.c @@ -99,7 +99,7 @@ static int st_rtc_read_time(struct device *dev, struct rtc_time *tm) lpt = ((unsigned long long)lpt_msb << 32) | lpt_lsb; do_div(lpt, rtc->clkrate); - rtc_time_to_tm(lpt, tm); + rtc_time64_to_tm(lpt, tm); return 0; } @@ -107,13 +107,10 @@ static int st_rtc_read_time(struct device *dev, struct rtc_time *tm) static int st_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct st_rtc *rtc = dev_get_drvdata(dev); - unsigned long long lpt; - unsigned long secs, flags; - int ret; + unsigned long long lpt, secs; + unsigned long flags; - ret = rtc_tm_to_time(tm, &secs); - if (ret) - return ret; + secs = rtc_tm_to_time64(tm); lpt = (unsigned long long)secs * rtc->clkrate; @@ -161,13 +158,13 @@ static int st_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) { struct st_rtc *rtc = dev_get_drvdata(dev); struct rtc_time now; - unsigned long now_secs; - unsigned long alarm_secs; + unsigned long long now_secs; + unsigned long long alarm_secs; unsigned long long lpa; st_rtc_read_time(dev, &now); - rtc_tm_to_time(&now, &now_secs); - rtc_tm_to_time(&t->time, &alarm_secs); + now_secs = rtc_tm_to_time64(&now); + alarm_secs = rtc_tm_to_time64(&t->time); /* Invalid alarm time */ if (now_secs > alarm_secs)