From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6706C43219 for ; Fri, 26 Apr 2019 14:38:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1E7D2077B for ; Fri, 26 Apr 2019 14:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726224AbfDZOiZ (ORCPT ); Fri, 26 Apr 2019 10:38:25 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:40617 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbfDZOiZ (ORCPT ); Fri, 26 Apr 2019 10:38:25 -0400 X-Originating-IP: 109.213.12.238 Received: from localhost (alyon-652-1-29-238.w109-213.abo.wanadoo.fr [109.213.12.238]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id F134740008; Fri, 26 Apr 2019 14:38:22 +0000 (UTC) Date: Fri, 26 Apr 2019 16:38:22 +0200 From: Alexandre Belloni To: Mathieu Malaterre Cc: linux-rtc@vger.kernel.org, Paul Cercueil , linux-arm-kernel@lists.infradead.org, LKML Subject: Re: [PATCH 2/7] rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64 Message-ID: <20190426143822.GS14604@piout.net> References: <20190418100045.29288-1-alexandre.belloni@bootlin.com> <20190418100045.29288-2-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org On 26/04/2019 16:29:36+0200, Mathieu Malaterre wrote: > On Thu, Apr 18, 2019 at 12:00 PM Alexandre Belloni > wrote: > > > > Call the 64bit versions of rtc_tm time conversion now that the range is > > enforced by the core. > > > > Signed-off-by: Alexandre Belloni > > --- > > drivers/rtc/rtc-jz4740.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c > > index 079469627bd7..15b6832f3931 100644 > > --- a/drivers/rtc/rtc-jz4740.c > > +++ b/drivers/rtc/rtc-jz4740.c > > @@ -171,7 +171,7 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time) > > if (timeout == 0) > > return -EIO; > > > > - rtc_time_to_tm(secs, time); > > + rtc_time64_to_tm(secs, time); > > > > return 0; > > } > > @@ -196,7 +196,7 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) > > alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE); > > alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF); > > > > - rtc_time_to_tm(secs, &alrm->time); > > + rtc_time64_to_tm(secs, &alrm->time); > > > > return rtc_valid_tm(&alrm->time); > > } > > @@ -205,9 +205,7 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) > > { > > int ret; > > struct jz4740_rtc *rtc = dev_get_drvdata(dev); > > - unsigned long secs; > > - > > - rtc_tm_to_time(&alrm->time, &secs); > > + unsigned long secs = rtc_tm_to_time64(&alrm->time); > > nitpick: all other declarations are done with uint32_t, so to make it > clear (maybe) with something like: > > uint32_t secs = lower_32_bits(rtc_tm_to_time64(&alrm->time)); > Ok, I'll change that. > Technically I would have stored the full time64_t here and put a > WARN_ON(secs > U32_MAX) but I am not sure what other driver are > supposed to do in this case. > Because range_max is set properly, the core will ensure that all the times passed to the driver fit within the range. Thanks for the review! -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00AEBC43219 for ; Fri, 26 Apr 2019 14:39:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C55502077B for ; Fri, 26 Apr 2019 14:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B7NqBcoH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C55502077B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vdM6YKAWSzA/VHeFTuNqMN6i69rlz+S1qPD32NHEgp8=; b=B7NqBcoHWAYpmq WB8jmybaa8nIVB5V1njPPGYdfj/IqEpId8YBeERNrNHL6ZDpaLC+h6ciU8gHmI62e0JwtOtV2yJnU Fj+x7dI948cwjIgtxAjp45CeeebSnNSnF4VS4UaPCwjGllSn3XQuNc/nadCqtksAuyfAYjtMtQeeU UuK6kmlxrnMLNkj4kakpqeTlri6IHaAWEcqIi4puDpDfbOBCQP7nNFTdgNNhEboHJ77PxQi2w8b/9 Y/xE0sNF7jf/xVqTz/sNugjpKyqOWxFjeWM3a+Lf0TREjFaRLC1m/A9CDrrQCLyQ+iQWGP0Ohb3+T XuSxE/Z9hr4qavoRGmrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hK20B-0006Gs-AE; Fri, 26 Apr 2019 14:38:59 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hK1zj-0005xo-TC for linux-arm-kernel@lists.infradead.org; Fri, 26 Apr 2019 14:38:38 +0000 X-Originating-IP: 109.213.12.238 Received: from localhost (alyon-652-1-29-238.w109-213.abo.wanadoo.fr [109.213.12.238]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id F134740008; Fri, 26 Apr 2019 14:38:22 +0000 (UTC) Date: Fri, 26 Apr 2019 16:38:22 +0200 From: Alexandre Belloni To: Mathieu Malaterre Subject: Re: [PATCH 2/7] rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64 Message-ID: <20190426143822.GS14604@piout.net> References: <20190418100045.29288-1-alexandre.belloni@bootlin.com> <20190418100045.29288-2-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190426_073832_514544_CFB7EBE9 X-CRM114-Status: GOOD ( 21.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rtc@vger.kernel.org, Paul Cercueil , LKML , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 26/04/2019 16:29:36+0200, Mathieu Malaterre wrote: > On Thu, Apr 18, 2019 at 12:00 PM Alexandre Belloni > wrote: > > > > Call the 64bit versions of rtc_tm time conversion now that the range is > > enforced by the core. > > > > Signed-off-by: Alexandre Belloni > > --- > > drivers/rtc/rtc-jz4740.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c > > index 079469627bd7..15b6832f3931 100644 > > --- a/drivers/rtc/rtc-jz4740.c > > +++ b/drivers/rtc/rtc-jz4740.c > > @@ -171,7 +171,7 @@ static int jz4740_rtc_read_time(struct device *dev, struct rtc_time *time) > > if (timeout == 0) > > return -EIO; > > > > - rtc_time_to_tm(secs, time); > > + rtc_time64_to_tm(secs, time); > > > > return 0; > > } > > @@ -196,7 +196,7 @@ static int jz4740_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) > > alrm->enabled = !!(ctrl & JZ_RTC_CTRL_AE); > > alrm->pending = !!(ctrl & JZ_RTC_CTRL_AF); > > > > - rtc_time_to_tm(secs, &alrm->time); > > + rtc_time64_to_tm(secs, &alrm->time); > > > > return rtc_valid_tm(&alrm->time); > > } > > @@ -205,9 +205,7 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) > > { > > int ret; > > struct jz4740_rtc *rtc = dev_get_drvdata(dev); > > - unsigned long secs; > > - > > - rtc_tm_to_time(&alrm->time, &secs); > > + unsigned long secs = rtc_tm_to_time64(&alrm->time); > > nitpick: all other declarations are done with uint32_t, so to make it > clear (maybe) with something like: > > uint32_t secs = lower_32_bits(rtc_tm_to_time64(&alrm->time)); > Ok, I'll change that. > Technically I would have stored the full time64_t here and put a > WARN_ON(secs > U32_MAX) but I am not sure what other driver are > supposed to do in this case. > Because range_max is set properly, the core will ensure that all the times passed to the driver fit within the range. Thanks for the review! -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel