Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751962AbdFTJ4c (ORCPT ); Tue, 20 Jun 2017 05:56:32 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38317 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752557AbdFTJhU (ORCPT ); Tue, 20 Jun 2017 05:37:20 -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 09/51] rtc: at32ap700x: stop using rtc deprecated functions Date: Tue, 20 Jun 2017 11:35:17 +0200 Message-Id: <1497951359-13334-10-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: 3140 Lines: 97 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-at32ap700x.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index de8bf56..db58cf5 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c @@ -61,7 +61,7 @@ struct rtc_at32ap700x { struct rtc_device *rtc; void __iomem *regs; - unsigned long alarm_time; + unsigned long long alarm_time; unsigned long irq; /* Protect against concurrent register access. */ spinlock_t lock; @@ -70,10 +70,10 @@ struct rtc_at32ap700x { static int at32_rtc_readtime(struct device *dev, struct rtc_time *tm) { struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); - unsigned long now; + unsigned long long now; now = rtc_readl(rtc, VAL); - rtc_time_to_tm(now, tm); + rtc_time64_to_tm(now, tm); return 0; } @@ -81,14 +81,12 @@ static int at32_rtc_readtime(struct device *dev, struct rtc_time *tm) static int at32_rtc_settime(struct device *dev, struct rtc_time *tm) { struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); - unsigned long now; - int ret; + unsigned long long now; - ret = rtc_tm_to_time(tm, &now); - if (ret == 0) - rtc_writel(rtc, VAL, now); + now = rtc_tm_to_time64(tm); + rtc_writel(rtc, VAL, now); - return ret; + return 0; } static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) @@ -96,7 +94,7 @@ static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); spin_lock_irq(&rtc->lock); - rtc_time_to_tm(rtc->alarm_time, &alrm->time); + rtc_time64_to_tm(rtc->alarm_time, &alrm->time); alrm->enabled = rtc_readl(rtc, IMR) & RTC_BIT(IMR_TOPI) ? 1 : 0; alrm->pending = rtc_readl(rtc, ISR) & RTC_BIT(ISR_TOPI) ? 1 : 0; spin_unlock_irq(&rtc->lock); @@ -107,15 +105,12 @@ static int at32_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct rtc_at32ap700x *rtc = dev_get_drvdata(dev); - unsigned long rtc_unix_time; - unsigned long alarm_unix_time; - int ret; + unsigned long long rtc_unix_time; + unsigned long long alarm_unix_time; rtc_unix_time = rtc_readl(rtc, VAL); - ret = rtc_tm_to_time(&alrm->time, &alarm_unix_time); - if (ret) - return ret; + alarm_unix_time = rtc_tm_to_time64(&alrm->time); if (alarm_unix_time < rtc_unix_time) return -EINVAL; @@ -131,7 +126,7 @@ static int at32_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) & ~RTC_BIT(CTRL_TOPEN)); spin_unlock_irq(&rtc->lock); - return ret; + return 0; } static int at32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) -- 1.9.1