Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3659378imm; Mon, 4 Jun 2018 07:18:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3Eu4a9aOAZ8qseOIRzjc/ev6kxuf4ci7l2wJIqDYVlU1A1hkqd3xbOUacivj7nsQCab87 X-Received: by 2002:a62:b201:: with SMTP id x1-v6mr17939579pfe.189.1528121932981; Mon, 04 Jun 2018 07:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528121932; cv=none; d=google.com; s=arc-20160816; b=cA5uxwV51zUaz0C1O38gdRumgnVHX5ZIJoWebZ/M8G8nbVsIuDqiWkIZ8v9lgGEYPY pO/ixVF7znQ62p4ATS7w8eJdeuKH8Fn0vq1GyjXpnyxdBZm9Ow9gd9y5Kqqm7V3iblpl GcmqfzSSq9whUBUO6SbLj6HPOHA8P+qTRNiO7VfHDfqm3ZLNz1Upo5tWeoFrEEzhBZfC aPmKoEFRzTbpOaHKMtQorVwoZtG4OrBmphHbCbTCFgvU6OwMKuL0dOiIde+Typ+R+VJo dPW9RnqHkZ/gdAwFTxtplG2ergDo4dlAz7UHDsc1S6vA9XZ7M3bNUzJt2p17+ZRRU7hd xx2Q== 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=0p1gsFQvKXenCWiMptMh6ry4mO7vAW3LC5yneZ2OslU=; b=QowxWtB9L/bUoCJBjT04MEKpzbqvVMgYGmQgiNd+9yada8tuoR1QIjqP9IKabhylAu YDtZhonshSl/5wn43Mco2RR5oayVBku35VABt99HY2xRUqhKeIDK0wRL3W7F/f/9VjPm UuWSUTp3iicVE5n+DQbrHSg7ld7ukKVBtQSVLrzFc5Rt4oGK5kmJuMlqhMvJVySuGAnJ HAIR/eatAJdbjZ5hK7HtafR24U2WTotSceNuZkMwF988w/vzKK+COY0fNGuE7maYnKM8 LNb9jlE7l6ZkbhOf0ybUSiWB9b2D/8ILcDhSeOrtzgTUjRfjAoml8x8iqY4A1ZssfQ6Q 8j/A== 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 d6-v6si314717pgn.493.2018.06.04.07.18.37; Mon, 04 Jun 2018 07:18:52 -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 S1753794AbeFDOQi (ORCPT + 99 others); Mon, 4 Jun 2018 10:16:38 -0400 Received: from mail.bootlin.com ([62.4.15.54]:51381 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753720AbeFDOPz (ORCPT ); Mon, 4 Jun 2018 10:15:55 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id DFF62207A9; Mon, 4 Jun 2018 16:15:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (hy283-1-82-246-155-60.fbx.proxad.net [82.246.155.60]) by mail.bootlin.com (Postfix) with ESMTPSA id 576E7203EC; Mon, 4 Jun 2018 16:15:53 +0200 (CEST) From: Alexandre Belloni To: linux-rtc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Hans Ulli Kroll , Linus Walleij , linux-arm-kernel@lists.infradead.org, Alexandre Belloni Subject: [PATCH 2/3] rtc: ftrtc010: handle dates after 2106 Date: Mon, 4 Jun 2018 16:15:27 +0200 Message-Id: <20180604141528.15635-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180604141528.15635-1-alexandre.belloni@bootlin.com> References: <20180604141528.15635-1-alexandre.belloni@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use correct types for offset and time and use rtc_time64_to_tm/rtc_tm_to_time64 to handle dates after 2106 properly. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ftrtc010.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c index 165d0b62db00..2cdc78ffeb17 100644 --- a/drivers/rtc/rtc-ftrtc010.c +++ b/drivers/rtc/rtc-ftrtc010.c @@ -73,8 +73,8 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); - unsigned int days, hour, min, sec; - unsigned long offset, time; + u32 days, hour, min, sec, offset; + timeu64_t time; sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); @@ -84,7 +84,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) time = offset + days * 86400 + hour * 3600 + min * 60 + sec; - rtc_time_to_tm(time, tm); + rtc_time64_to_tm(time, tm); return 0; } @@ -92,13 +92,13 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct ftrtc010_rtc *rtc = dev_get_drvdata(dev); - unsigned int sec, min, hour, day; - unsigned long offset, time; + u32 sec, min, hour, day, offset; + timeu64_t time; if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ return -EINVAL; - rtc_tm_to_time(tm, &time); + time = rtc_tm_to_time64(tm); sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); -- 2.17.1