Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752551AbdFTJzv (ORCPT ); Tue, 20 Jun 2017 05:55:51 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:33501 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdFTJh1 (ORCPT ); Tue, 20 Jun 2017 05:37:27 -0400 From: Benjamin Gaignard To: benjamin.gaignard@linaro.org Cc: linaro-kernel@lists.linaro.org, Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH 10/51] rtc: at91sam9: stop using rtc deprecated functions Date: Tue, 20 Jun 2017 11:35:18 +0200 Message-Id: <1497951359-13334-11-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497951359-13334-1-git-send-email-benjamin.gaignard@linaro.org> References: <1497951359-13334-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2428 Lines: 74 rtc_time_to_tm() and rtc_tm_to_time() are deprecated because they rely on 32bits variables and that will make rtc break in y2038/2016. Stop using those two functions to safer 64bits ones. Signed-off-by: Benjamin Gaignard CC: Alessandro Zummo CC: Alexandre Belloni CC: rtc-linux@googlegroups.com CC: linux-kernel@vger.kernel.org --- drivers/rtc/rtc-at91sam9.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 7418a76..be1f37e 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -122,7 +122,7 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm) if (secs != secs2) secs = rtt_readl(rtc, VR); - rtc_time_to_tm(offset + secs, tm); + rtc_time64_to_tm((u64)(offset + secs), tm); dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readtime", 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, @@ -137,17 +137,14 @@ static int at91_rtc_readtime(struct device *dev, struct rtc_time *tm) static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) { struct sam9_rtc *rtc = dev_get_drvdata(dev); - int err; u32 offset, alarm, mr; - unsigned long secs; + unsigned long long secs; dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "settime", 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - err = rtc_tm_to_time(tm, &secs); - if (err != 0) - return err; + secs = rtc_tm_to_time64(tm); mr = rtt_readl(rtc, MR); @@ -197,7 +194,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) memset(alrm, 0, sizeof(*alrm)); if (alarm != ALARM_DISABLED && offset != 0) { - rtc_time_to_tm(offset + alarm, tm); + rtc_time64_to_tm((u64)(offset + alarm), tm); dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readalarm", 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, @@ -214,14 +211,11 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct sam9_rtc *rtc = dev_get_drvdata(dev); struct rtc_time *tm = &alrm->time; - unsigned long secs; + unsigned long long secs; u32 offset; u32 mr; - int err; - err = rtc_tm_to_time(tm, &secs); - if (err != 0) - return err; + secs = rtc_tm_to_time64(tm); offset = gpbr_readl(rtc); if (offset == 0) { -- 1.9.1