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: <20180420161433.3721192-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:5q6Yn/6t1PHM/iTwtOaUQDAOWGhqGQWn6ZhUBQMPfwOfzH+FHzT lPcDQWyLVkYwosho7qesbDYm9bKzB8SEehzgf7dFfSdhlCMVzD+M6V+OSVuf3PyAXzHOBf0 JUciYlMbFP4xPEvDvkkKr2m7SIyaLtodIGHfERJe2+ascePIaow3A6krgqcx/AuCdjwkJMy xfAXAgLzuw317DAFfRjOQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:g6+nH7Yf/T0=:uwuoSN6lV6R9JG4aoWip+T RGzfW6EpOXgfsFg6v7VpSuCFhlBRXu/VsUz6YKeGu7QByI9QzSOeL4o7803I1ZTDWBLrjzz+x Fh4Zdwqr0XI5sdDgCHdq/DJyWYPBkgh0mFgRHS40tHREkjr75yHNqLPDvSjVxxcPmMLv/LWtv a4U5UCDPojT78iz/cMhGMW/sNV5VMpS718gh3Uxh/XdmxEqCmpEq36yQQwX/DaZM6YREoUplj d8RljjZv9NxQZyve5z+q2xc+V0LVJ0i8sauCbDYDnA3g6GW1Cwso8ekGRyReu7OEnoxvypcCI ooz+wpF8KqS3eDYbTHiD9un0vTAezeYQpUeuSQiUA8oSCojUW8LFVaMToWUi0sPC4metPttRx W0Xf7GZP0YdzCspwm7GK2OcvLKI0We6QvoJoOZgzFZPCdprP9MySg2WMctzjjt6WWjchdfKm9 H7TiK5pNNs+PcQthIFeCRZESlUkVtXjn5hr9LWQ9SzP+w3indY1xE5BFgp9LB4QWirGGKOTJo 18N1fWPS5mG1qpwEtMZoZYlNPeTRTadT9TzcvZtMGc+faxoMmF0/lkcVPqC9RdsiYkU7VPu8Y FGKSOKun2hQ2rp98I/Q1Lo7xZHr8CjI6kyaiMj4Sh4eZzsHn3Uq8nSiUfPkrzd3zWXKgJMXIh 15kTswAAZEnb5PxeYC5xL+1hRNriDOddZSvkBeAWhSnoJu9O56TwmanPZXDCMYmjJ3OI915kh RuzQgBlSNajILJLQgLdNpGZDWEahtedKtMlbVA== 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); From patchwork Fri Apr 20 16:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133910 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp464201ljf; Fri, 20 Apr 2018 09:15:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx485exS6LaNBdMc9E9XYpGC4SCDJ0ULayUs16HhAmk9ybrutwppCFrcPqU+XvNfCCk6U9AGg X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr11024914plb.179.1524240938894; Fri, 20 Apr 2018 09:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524240938; cv=none; d=google.com; s=arc-20160816; b=mD9y9dZV8eTMzhN0l8DdRU0VRzDqZFHJpeqGlotA6VsZOo9icyU3iDw39bhIvRGqsn 9RgPIgSywTGtziDkphSiM3NEKRbhtyHD5iAu22FDc1+RMbfdmlPsloZ7R5zwxszE/hmw vZfqRHWZybRintw7TpCAEH6GY0VFtZF1fX6C6DKRMbuMPbAFmYRyd2LHF34A/wVzlMB9 N2hkxd3q7Jj9fNmkyRtZ3H3yQqYxEGuEcQTeObbAhu0ogLNoqVg2RcoUoVIDWgGI92N2 ubZ+bkCC1R2VWfRl/X0E4BVJxTiGvL8ytTvAWd+UmcTF0GqICuUYIVGMOJnRO5/l6PBq Q6ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fFfIcCPPjK4SQYijRwKK/JLUi1zp8qgddjBIWDHpxzQ=; b=hkBox7syj06CWnUJFbJJf0RDLIDcLGXogypLYeolwWn9Uld9u3OzWry4YTtEcejUFH z9Q7Xs4u6lYfgXkhjVuDtTFzMOOG2IXQxgdOsgl1kGMt8ncfXrP9J9a2u8PdzPiUve5+ 4Mac11Y9EcycePSm6ujroX0gmXdSXZE62imGpa3l1h4sft5mWAPfsXomED26MEXJDz9P 5OKc4s0OmJZc4Hcw4/Hxl7hjtKuFKMsbm6pKdfv9+0FV1hSiKFOaCJSjgC0/w7BbL+5u sTBFyfpwmNLS66YcU0gjUpNf56vuOTTNKYj1h4UhT2d5mQ8PJnEMCkKmqhp712bcWSNj FPrw== 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 k185si5206374pgk.2.2018.04.20.09.15.38; Fri, 20 Apr 2018 09:15:38 -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 S1752731AbeDTQPh (ORCPT + 29 others); Fri, 20 Apr 2018 12:15:37 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:52585 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbeDTQO6 (ORCPT ); Fri, 20 Apr 2018 12:14:58 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0MEJGG-1fBmf33Mb2-00FVyc; Fri, 20 Apr 2018 18:14:41 +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 2/3] rtc: ls1x: remove mktime usage Date: Fri, 20 Apr 2018 18:14:25 +0200 Message-Id: <20180420161433.3721192-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180420161433.3721192-1-arnd@arndb.de> References: <20180420161433.3721192-1-arnd@arndb.de> X-Provags-ID: V03:K1:jLE80nIlTuHNBXQS5Q/kQoDTiwWNUWQEnwnlls4orHmeBQUKjjB N77cwiVuy6dsEhFiEXrwHIi9VkkjydOE/7GwGMuK5h7N27usXUdEy0mqvlyNW2cdBGbuhxO VczAqeW+ALJK3NgfG3vT/lV/akWejvHBZmQmu3QjroztusFbju0KENnqVEKqFKHBAeRBYkZ 05/1TJCNDmQjATPXoEREA== X-UI-Out-Filterresults: notjunk:1; V01:K0:4BCmzUPsy58=:umGPZc5w0R0G9gUX/EFSYp 5h/BwkQdvU83AX1DnPvFpsVD+t4tUuV2Y7eabH9Z5bchs/vfHkUI0gwcDofv5gKBmThHHAlCu W1wgGlfecIAz5/DR8oh5KLo9bfM4hQT4ZK4n29pY9PEIGXagZcpmhUEv6i3Ezzxl6rNFMcXfV fBnVtJhE5Y+PFNGwO+ckQPFO199/bde840s6qDVwPz7ncHlOUGJz8hiEIFjFJj4FXWbQk+l3q wR7wNvlt9Ph9EF3osXjD1OfOUHuTPM8DG3pNarzjdLRPzj5jrmmBaCHz3tBPJsOjns3bpb69s Zeh3gGWTH5sfXsz6o0x6JVXOoGd2dGy99HHx3itiTClxAHIrScdkqQdiBqfIjEU4bET1DeHqp oXgMME0xyr3cJiWV1E2nLvN7NjEXdalE1bUkvb7wyXwV/qI2Q2aTDP3hoVmVWgdpHfepvZnru hT0hs5PNx6rSnCNURlryRi8AEFwa+/AFbSZ77WvGwE4AbdDHF0jDT30AsAqSMWWB3QkiiPKeF KwumMcnOcJhfSauan7GIsnRz4LDBZYNZEHRCKYlYxHeWnYuR2OVdPU3DlRcVRf8tnVfau/lcb +7iHg8kxkWU9Mg/J2+YmswZloppSF9DK9wRMIXHUUoh0TIzqLmDz3mfIL7p66z/qlTvw1/bVO PJPkyRopIAvbcH0Qps7jkZjmUfJGJm0D8FCbaaKe72CzqjunvjEV3hSrWlw6Xz+jtJjjq2vjS 8jv1VoHmLfxQn/dTp4swoPYt9NiQG8PC9pBR+w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The loongson1 platform is 32-bit, so storing a time value in 32 bits suffers from limited range. In this case it is likely to be correct until 2106, but it's better to avoid the limitation and just use the time64_t based mktime64() and rtc_time64_to_tm() interfaces. The hardware uses a 32-bit year number, and time64_t can cover that entire range. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-ls1x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c index 045af1135e48..de86f9fabc11 100644 --- a/drivers/rtc/rtc-ls1x.c +++ b/drivers/rtc/rtc-ls1x.c @@ -87,16 +87,17 @@ static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm) { - unsigned long v, t; + unsigned long v; + time64_t t; v = readl(SYS_TOYREAD0); t = readl(SYS_TOYREAD1); memset(rtm, 0, sizeof(struct rtc_time)); - t = mktime((t & LS1X_YEAR_MASK), ls1x_get_month(v), + t = mktime64((t & LS1X_YEAR_MASK), ls1x_get_month(v), ls1x_get_day(v), ls1x_get_hour(v), ls1x_get_min(v), ls1x_get_sec(v)); - rtc_time_to_tm(t, rtm); + rtc_time64_to_tm(t, rtm); return 0; } From patchwork Fri Apr 20 16:14:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133909 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp463669ljf; Fri, 20 Apr 2018 09:15:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+gTxJDtZy+/OeXkE9TCmTznyffIWSCCann5EOmu9ntiI+RWrCGUeShaGlPa3fT6ZmRqx1N X-Received: by 10.101.92.139 with SMTP id a11mr9253390pgt.204.1524240910245; Fri, 20 Apr 2018 09:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524240910; cv=none; d=google.com; s=arc-20160816; b=RE12nTgWM0/MsTsfe1Am42Chl9W9MJiC3kaOP7Lw6qgRHaoB9VsPDESal+WtCz3rOa g+Kvz7hahrDKCiV20NarH6y2ugtZpZVvkYNRPWmi5jJuXQTnmEpA+p08Iu2intuAmglo iYhp+vO5pvQ6vlroDIoitCD2EkJbkGG5ylK2cprOd/g2jmLw4pt61JZESLg1pUwjIgCj +mkXPowRSMmf5S+S1tM/82zbJHfUx7GalQLfiMMXpKK8kNqUyiq6qgCzie7+DI+ORn2M iJr+im22gGtvjFK031kCXFCqXnS043WVaw7ySfDF9HTFBXlfarc72RdYfQgbe5KoA2dS DQLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=u9/LFbFf82RW8Tjj1y4DmjcNim1gesMAuQd7WBxkp24=; b=OBRM+s/KC5a4NWiJxgnavc4/LF/dSixRQXaMYPB+qmrGfq5RjwAryl83OR/etLBMZJ jo//UYqraFPnPgM9qfIVGpghArfxDwq4HgHTgzBwojK3CsDijWfjxwQritFEpNhXRtyP a/EJVZo7H5+r7DWILfT7/w1f/4vWDvZ9YrJMnrEycu1QBhlq0Umv6m6+lbG+iwqhF/yk BOnR93Uj0lLjPUTPbOh8kTkCiurZdMHKlvAoMe6T6oNBrPsVDGyDj8Gh8cFCb/6JavlO G3Vl+Or5OXiI/TReeINp0Ypc47rxaIJfzmnxxcGD8H4qBF+zSqc+ni86m+202X+9bUFj YW6w== 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 a23si1851420pfh.295.2018.04.20.09.15.09; Fri, 20 Apr 2018 09:15:10 -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 S1752578AbeDTQPH (ORCPT + 29 others); Fri, 20 Apr 2018 12:15:07 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:36201 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeDTQPD (ORCPT ); Fri, 20 Apr 2018 12:15:03 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0LhzeA-1eeMmj0RU2-00nC2K; Fri, 20 Apr 2018 18:14:47 +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 3/3] rtc: tps6586x: remove mktime usage Date: Fri, 20 Apr 2018 18:14:26 +0200 Message-Id: <20180420161433.3721192-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180420161433.3721192-1-arnd@arndb.de> References: <20180420161433.3721192-1-arnd@arndb.de> X-Provags-ID: V03:K1:uFk+XX53/Bun0nehYpCnUvhWFTU85ztqI+ZUVYREyY7ClPW/b/m dYt+MXwYQY2GDInUkNGWZE5D3jKkkfnMg3q2JdF1GpEvqU/NyZ7W7W8s8/0PC5bmoxU+9Nr o0fP/J2pJiQpiSNeM4sCZanRYykTof5qHxjIQv27wp+quVhXDeNWfNfKxhL7Qtsb8eS3/PY G3CEZUkV3EqQVQ2kd+EIg== X-UI-Out-Filterresults: notjunk:1; V01:K0:f7sSTuXSSpE=:PscYx+5khXoWBuyf9Kwhn0 NeIp+C3b+2Es1jINxyzosxTkiD10E6MXnSGg4M+us+apa4fg4PSXA73QlQhVe80EXdkT3Kjv9 i41npYRTsRQbjCipg5VcTBqNlz8drtOUqKAe4zq/21Qd+l/wO4qyE/YdBu3TYJUCjVnOGPIGB Dil1zMfYqZhmajD8Atg08VE7DrBLWaCmTHutZdO3ZWUpT25q3DIspwLcJF5yfZj5XNvQpbb6p f+Ojq9e0Za4gmbWzf+DZFgrXr5XjmjjV0gOi9WlsJn1yEqgnLKceOvJDIwjVTG7Kn+22TN6HV WyeSomVeOhyPxLzKvki03Iu6d5kBjXlVYhW9SR86Oh6CC2Aew60jMTg0B8X4yFFfUek+S1/Qu gS8cSEd/0Snoul2EDbN9JdMTXCKDT6pzs4QLlOfeypm4EPmfJ4zFv6mRdzvvkn6CAC9xaGD8n 33O4Wgo3LFMB0j1Mpi1CH2LTigjzzpgky/uWJAF3FZmWk0mTGg4F91YepTVyBeagwIeX9FN6k /0mumc+0kWI4VW1VuKLGI6ijuhDy2WI9TiogYbb+tX6JaWdZwljT0ZliSGOvq2d9cW/ofSHX1 9dB8cKuOJyThqL3XXLhy/o7iIcxhNprRpBNjvwu/OoCLAPkBg7kfIsxVl2xNp4vhYlYHz8AFp N4tEXCwh/V22gr/BALpOptjkKAgJo7YuKHcPNa8VOMkvPssqoZSrxPr6geikRktufm9GwmGEb zQ8cn9yb+SJshUAg+NowlUWdc0ow0h6IRe+azw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The tps6586x use a 64-bit 'epoch_start' value, but then computes that value using an 'mktime()', which has a smaller range and overflows in 2106 at the latest. As both the hardware and the subsystem interface support wider than 32-bit ranges for rtc times here, let's change all the operations on 'seconds' to time64_t. Signed-off-by: Arnd Bergmann --- drivers/rtc/rtc-tps6586x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.9.0 diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c index d7785ae0a2b4..46a19adf9a96 100644 --- a/drivers/rtc/rtc-tps6586x.c +++ b/drivers/rtc/rtc-tps6586x.c @@ -58,7 +58,7 @@ struct tps6586x_rtc { struct rtc_device *rtc; int irq; bool irq_en; - unsigned long long epoch_start; + time64_t epoch_start; }; static inline struct device *to_tps6586x_dev(struct device *dev) @@ -71,7 +71,7 @@ static int tps6586x_rtc_read_time(struct device *dev, struct rtc_time *tm) struct tps6586x_rtc *rtc = dev_get_drvdata(dev); struct device *tps_dev = to_tps6586x_dev(dev); unsigned long long ticks = 0; - unsigned long seconds; + time64_t seconds; u8 buff[6]; int ret; int i; @@ -98,11 +98,11 @@ static int tps6586x_rtc_set_time(struct device *dev, struct rtc_time *tm) struct tps6586x_rtc *rtc = dev_get_drvdata(dev); struct device *tps_dev = to_tps6586x_dev(dev); unsigned long long ticks; - unsigned long seconds; + time64_t seconds; u8 buff[5]; int ret; - rtc_tm_to_time(tm, &seconds); + seconds = rtc_tm_to_time64(tm); if (seconds < rtc->epoch_start) { dev_err(dev, "requested time unsupported\n"); return -EINVAL; @@ -157,7 +157,7 @@ static int tps6586x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct tps6586x_rtc *rtc = dev_get_drvdata(dev); struct device *tps_dev = to_tps6586x_dev(dev); - unsigned long seconds; + time64_t seconds; unsigned long ticks; unsigned long rtc_current_time; unsigned long long rticks = 0; @@ -166,7 +166,7 @@ static int tps6586x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) int ret; int i; - rtc_tm_to_time(&alrm->time, &seconds); + seconds = rtc_tm_to_time64(&alrm->time); if (alrm->enabled && (seconds < rtc->epoch_start)) { dev_err(dev, "can't set alarm to requested time\n"); @@ -213,7 +213,7 @@ static int tps6586x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) struct tps6586x_rtc *rtc = dev_get_drvdata(dev); struct device *tps_dev = to_tps6586x_dev(dev); unsigned long ticks; - unsigned long seconds; + time64_t seconds; u8 buff[3]; int ret; @@ -227,7 +227,7 @@ static int tps6586x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) seconds = ticks >> 10; seconds += rtc->epoch_start; - rtc_time_to_tm(seconds, &alrm->time); + rtc_time64_to_tm(seconds, &alrm->time); return 0; } @@ -261,7 +261,7 @@ static int tps6586x_rtc_probe(struct platform_device *pdev) rtc->irq = platform_get_irq(pdev, 0); /* Set epoch start as 00:00:00:01:01:2009 */ - rtc->epoch_start = mktime(2009, 1, 1, 0, 0, 0); + rtc->epoch_start = mktime64(2009, 1, 1, 0, 0, 0); /* 1 kHz tick mode, enable tick counting */ ret = tps6586x_update(tps_dev, RTC_CTRL,