Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3658221imm; Mon, 4 Jun 2018 07:17:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLh/7F5tXIUc0UeKEeh4zuMOTP6Op5UJWt/mkmnEfYx+46zKa3jOvuH8h6+BaJ2LYsQzoVK X-Received: by 2002:a17:902:563:: with SMTP id 90-v6mr22484103plf.327.1528121868605; Mon, 04 Jun 2018 07:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528121868; cv=none; d=google.com; s=arc-20160816; b=ahpzc8QflM4Awb+nXY18zcj6LXWaVBKmtX7K1EDc5pSvmNXwdiAIh8r93Ggnlnb4+N dYUWB7XabbQqc6+eBotQGmEMTZpLGlJ8lLzgSBYTQ6pFYXtVXWRrIqIwu/Jj5s5clz8V tGaR1kMW4GT8xZ2Qu28X1GEH/Nq92sRBovDf0Agto5UvSomnPCq1zV14cIO6qD1QyOSJ U13pU8SULkAhzKQFrd3yPlfv1MLlyltevZO2pmblTjpcE1fN7GwuvE2pXEkUTt3UPqtX I/dub1cGncZSosk3qil/Rbp8QBwvom5hrQvIIj4DwPXMzicCBKhQ0yTvBQrZpKiy7PJI 4cPQ== 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=ZalHtuIWvSrsuFdHCeS0Mzkl4z0X9t7w/cTJwjl7tao=; b=wyUeZzyBoWrVM0j8NvxM8ErAGO2YAqDZeY4RnuKXhK870V8UHgPd1k4tVVOOjO5bxL QJT3nqaz/5R2dSmzs5uHX+/XiQ0y34AwKpwREfiAAGeSVy29j7ibyKGv5iPGKKAGYOvW c6ljldcB3DBSh0FB0Yg3TA7Xs5K6WEP2Kff7m81ydOaNMp0p9/OiDCfDA4P3tks8gfFo p/l0ke/2HXatzfSf7CWftG2gGgixzWYEU8lLCFwn1iUvZrnGJnCekUi/AVqwi5BJVPLD buCQt94S4MuLDjcXgquJDL/0vbEFO4JsYxm0EaL8BtOc1zfkSvMvdYcbsfFEi9eE1tS6 ziuA== 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 h8-v6si21523647pgc.370.2018.06.04.07.17.34; Mon, 04 Jun 2018 07:17:48 -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 S1753984AbeFDOQB (ORCPT + 99 others); Mon, 4 Jun 2018 10:16:01 -0400 Received: from mail.bootlin.com ([62.4.15.54]:51386 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753719AbeFDOP7 (ORCPT ); Mon, 4 Jun 2018 10:15:59 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 658A0207FA; Mon, 4 Jun 2018 16:15:57 +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 85177203EC; Mon, 4 Jun 2018 16:15:56 +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 3/3] rtc: ftrtc010: let the core handle range Date: Mon, 4 Jun 2018 16:15:28 +0200 Message-Id: <20180604141528.15635-3-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 The current range handling is highly suspicious. Anyway, let the core handle it. The RTC has a 32 bit counter on top of days + hh:mm:ss registers. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ftrtc010.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c index 2cdc78ffeb17..61f798c6101f 100644 --- a/drivers/rtc/rtc-ftrtc010.c +++ b/drivers/rtc/rtc-ftrtc010.c @@ -95,9 +95,6 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) u32 sec, min, hour, day, offset; timeu64_t time; - if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ - return -EINVAL; - time = rtc_tm_to_time64(tm); sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); @@ -120,6 +117,7 @@ static const struct rtc_class_ops ftrtc010_rtc_ops = { static int ftrtc010_rtc_probe(struct platform_device *pdev) { + u32 days, hour, min, sec; struct ftrtc010_rtc *rtc; struct device *dev = &pdev->dev; struct resource *res; @@ -172,6 +170,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) rtc->rtc_dev->ops = &ftrtc010_rtc_ops; + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); + days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); + + rtc->rtc_dev->range_min = (u64)days * 86400 + hour * 3600 + + min * 60 + sec; + rtc->rtc_dev->range_max = U32_MAX + rtc->rtc_dev->range_min; + ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, IRQF_SHARED, pdev->name, dev); if (unlikely(ret)) -- 2.17.1