From patchwork Fri Jun 16 14:03:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9791777 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 32D106038E for ; Fri, 16 Jun 2017 14:05:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382EA28564 for ; Fri, 16 Jun 2017 14:05:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C8AE28649; Fri, 16 Jun 2017 14:05:51 +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 7EB432863F for ; Fri, 16 Jun 2017 14:05:50 +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=8tPk+5O6N/OoQplRidu0ylglzwc2zFDfp18yQjo5B7U=; b=QOyTSZQQdDdCtZlXtvPX8AiDYe DGh0MKIk0GRvV06+xx/ced7z2sDa+lVQaO0XsmeMGfjdKB384JtOYx9kJ3sShBMuC1h12fA4N7BgV BPpptqDp2HviMmAYJsGHl3xoCuo0PGio+IffbtErehzYSQ/xF661S6KHQXUz9Mf9eSXbh5ZNrhAqm R4LdytYlzf5p/t88wDK5Q9py3U4HMRr4ompkr0rR42GcnHeey1mKtmajSsUs9jS1jiAtOJrIlnLc/ 89e65IUh6lIhMv6hDla/0+YOxlDNikP76shp5DtzF86ZOo1A/RVxaxIpWQ8QfLKh5ER0SF5zPNIVh X3GhOGxA==; 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 1dLrsi-0005S7-Hx; Fri, 16 Jun 2017 14:05:48 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dLrsC-0003Jo-N6 for linux-arm-kernel@lists.infradead.org; Fri, 16 Jun 2017 14:05:21 +0000 Received: by mail-wm0-x22f.google.com with SMTP id d73so24817356wma.0 for ; Fri, 16 Jun 2017 07:04:56 -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=Pmp86WE71VCG0xAL+4P23X8e6KOwOfaABNMuBuupcYc=; b=OZ3jR2eYEtsrW7RAs/1/beU8SmUz3iA7p9hQ6KRVXMp0/pV3n/Pe12PZvEeNVIDHQn 2MHNJlCVEu+pbZimX/u/CFkvnaucJzsQOEvJATQ1ifOrBfeK8iDO3Ki+bQM4uS8dnUAb VTtSFP2TtrsAubmMoCEcuaxWd+zc1fuPBaEOw= 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=Pmp86WE71VCG0xAL+4P23X8e6KOwOfaABNMuBuupcYc=; b=kajsWTXZ5ydFfSz3m5A0z6mkiMob0JiINkALXr4ILSQO8qFm6bgRoS6AvWDvP9SPeX NeQ/EDh8dmH7kKBesb6c/s6FP+1kEgX5x9CPP4QfoR+XfusChgK0ljpCeAZIzvITjRLP 8vPcl8WWpzzjteyNipC81T5gV+NDdsCdEBDuanhU2DajM5eJtKcK9rXdsOS6+/Ivy3AH SRDvRCDq6B01qCEmg8Mps9rLODMvDNZpOpWVNAfEer9IwnNgV2KR6ZIJxV3HWjSfQwwx G60TQ0rd0Vcdw/sdBvFZesnK31Sl3JjCj+dfPtL2XkuL+s00tpIvu6lng7WB5YLGp1qo ZQQA== X-Gm-Message-State: AKS2vOwf05lwUWYoysFZoXIWhMwmyODnYRZD/njXzjLGByzNLwbvp0h5 yeM7sJcYXGnU4EQD X-Received: by 10.28.23.4 with SMTP id 4mr7663744wmx.119.1497621894966; Fri, 16 Jun 2017 07:04:54 -0700 (PDT) Received: from lmenx321.st.com. ([80.214.78.131]) by smtp.gmail.com with ESMTPSA id h12sm1883277wrc.43.2017.06.16.07.04.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 07:04:54 -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 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Date: Fri, 16 Jun 2017 16:03:53 +0200 Message-Id: <1497621833-9942-4-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497621833-9942-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497621833-9942-1-git-send-email-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170616_070517_336426_AF137ABE X-CRM114-Status: GOOD ( 12.11 ) 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)