From patchwork Fri Apr 20 16:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133908 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp463471ljf; Fri, 20 Apr 2018 09:14:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iMhs0rmntqIvyNfbfAFTnd4sD+B+W7PoLWBz+dXTU9kOh4qVSRT2rGjO0Cxun6Jt4ixJj X-Received: by 2002:a17:902:ab83:: with SMTP id f3-v6mr10670237plr.344.1524240898391; Fri, 20 Apr 2018 09:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524240898; cv=none; d=google.com; s=arc-20160816; b=NG2wX//eB6WM0w6PuxVIMeanE2WLGYW2uOGZYS8jP63CDuqcqqdZPo65fIk/w5E3H5 aIxFVwV+nIspLkMyUqoDqX8zdmBTuKgNvVIYQX9F3UB6nsuYSQQ59VaatRaUo91RaLgp mI1BejxiQF85CdNn7LnozfO23MGw4/3QDykmtslHxYFgEx+f1gPexBsBEJaPE6Ed73tW ED1UR9weeoxHJ12frp7DQSRe9ixkQn9ajhxzJoAQ4XrDFbDQm+YkOmF16iLu2c4gqjub Ghaq9zUxNlQfN01g//1jjievHLqDEpn45QwX1J2tRVasjVtRrRR/ZtIMLEG/YIF9xOWD 9zdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rBRlSbUGEpCuAooNj5ORCkOtO8fWwXjcuyUH3nisRmw=; b=PwJwCSlPSpvNhyHp85ysU+wHYu5NJjTGPbPK/10+bpgsMISYoX50jKRrIxZHvpQ59d XhzVOEJJ0nG3XofiuGH6DdliT7qhm+SKQGOtmJI0AhSin87wKlKh52ZMIk5kyYEax9cq xuQyk4Ua/vyR/rhiyYXg1U7+1hzgI5nnJcXnaqq7pSICgdEDjfIGhsufbWB5ZmwpvdYr z8gyt3tvSfwiytR8uAtiNCJNCSgjm3BJ4y/G05Lo2x7cZff2PNKLfFqztEuyN2FvBXIH wZ8R+f5/vdiUJgw/VsLSwN7QHgupf6iLbx++aqbQvj0HC6RkyXyIgm662p2hDoMtiDFY SI+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r74si1134101pfe.168.2018.04.20.09.14.57; Fri, 20 Apr 2018 09:14:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752159AbeDTQOy (ORCPT + 29 others); Fri, 20 Apr 2018 12:14:54 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:55201 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbeDTQOw (ORCPT ); Fri, 20 Apr 2018 12:14:52 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0LuYSK-1eRniN2ZUW-00zmyA; Fri, 20 Apr 2018 18:14:35 +0200 From: Arnd Bergmann To: Alessandro Zummo , Alexandre Belloni Cc: y2038@lists.linaro.org, Arnd Bergmann , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] rtc: vr41xx: remove mktime usage Date: Fri, 20 Apr 2018 18:14:24 +0200 Message-Id: <20180420161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lSNajILJLQgLdNpGZDWEahtedKtMlbVA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver uses mktime() and rtc_time_to_tm() to convert between time values. This works fine on 64-bit kernels over the whole supported range, and the vr41xx chip is a 64-bit MIPS implementation, but it is inconsistent because it doesn't do the same thing on 32-bit kernels that overflow in 2106 or 2038. Changing it to use mktime64/rtc_time64_to_tm() should have no visible impact on vr41xx but gets us closer to removing the 32-bit interfaces. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-vr41xx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.9.0 diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 7ce22967fd16..480cffe8d321 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c @@ -88,7 +88,7 @@ static unsigned int alarm_enabled; static int aie_irq; static int pie_irq; -static inline unsigned long read_elapsed_second(void) +static inline time64_t read_elapsed_second(void) { unsigned long first_low, first_mid, first_high; @@ -105,10 +105,10 @@ static inline unsigned long read_elapsed_second(void) } while (first_low != second_low || first_mid != second_mid || first_high != second_high); - return (first_high << 17) | (first_mid << 1) | (first_low >> 15); + return ((u64)first_high << 17) | (first_mid << 1) | (first_low >> 15); } -static inline void write_elapsed_second(unsigned long sec) +static inline void write_elapsed_second(time64_t sec) { spin_lock_irq(&rtc_lock); @@ -121,22 +121,22 @@ static inline void write_elapsed_second(unsigned long sec) static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time) { - unsigned long epoch_sec, elapsed_sec; + time64_t epoch_sec, elapsed_sec; - epoch_sec = mktime(epoch, 1, 1, 0, 0, 0); + epoch_sec = mktime64(epoch, 1, 1, 0, 0, 0); elapsed_sec = read_elapsed_second(); - rtc_time_to_tm(epoch_sec + elapsed_sec, time); + rtc_time64_to_tm(epoch_sec + elapsed_sec, time); return 0; } static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time) { - unsigned long epoch_sec, current_sec; + time64_t epoch_sec, current_sec; - epoch_sec = mktime(epoch, 1, 1, 0, 0, 0); - current_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, + epoch_sec = mktime64(epoch, 1, 1, 0, 0, 0); + current_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec); write_elapsed_second(current_sec - epoch_sec); @@ -165,11 +165,11 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) { - unsigned long alarm_sec; + time64_t alarm_sec; struct rtc_time *time = &wkalrm->time; - alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, - time->tm_hour, time->tm_min, time->tm_sec); + alarm_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, + time->tm_hour, time->tm_min, time->tm_sec); spin_lock_irq(&rtc_lock);