Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600AbdFSH6o (ORCPT ); Mon, 19 Jun 2017 03:58:44 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:48801 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751090AbdFSH6n (ORCPT ); Mon, 19 Jun 2017 03:58:43 -0400 From: Patrice CHOTARD To: Benjamin Gaignard , "john.stultz@linaro.org" , "tglx@linutronix.de" , "sboyd@codeaurora.org" , "shuah@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "a.zummo@towertech.it" , "alexandre.belloni@free-electrons.com" , "linux-arm-kernel@lists.infradead.org" , "rtc-linux@googlegroups.com" CC: "linaro-kernel@lists.linaro.org" Subject: Re: [PATCH 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Thread-Topic: [PATCH 3/3] rtc: st-lpc: make it robust against y2038/2106 bug Thread-Index: AQHS5qmIqsSGSExQcUSj8/YrjHE8raIrtKEA Date: Mon, 19 Jun 2017 07:57:48 +0000 Message-ID: References: <1497621833-9942-1-git-send-email-benjamin.gaignard@linaro.org> <1497621833-9942-4-git-send-email-benjamin.gaignard@linaro.org> In-Reply-To: <1497621833-9942-4-git-send-email-benjamin.gaignard@linaro.org> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.46] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-19_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v5J7wmuY010697 Content-Length: 1964 Lines: 64 Hi Benjamin On 06/16/2017 04:03 PM, Benjamin Gaignard wrote: > Make driver use u64 variables and functions to be sure that > it will support dates after year 2038. > > Signed-off-by: Benjamin Gaignard > --- > 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) > Acked-by: Patrice Chotard Thanks