From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [rtc-linux] [PATCH v3 2/3] rtc: mediatek: Add MT6397 RTC driver Date: Tue, 05 May 2015 13:44:21 -0700 Message-ID: <1430858661.9365.20.camel@perches.com> References: <1430206556-18254-1-git-send-email-eddie.huang@mediatek.com> <1430206556-18254-3-git-send-email-eddie.huang@mediatek.com> <20150505200010.GP4276@piout.net> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150505200010.GP4276@piout.net> Sender: linux-kernel-owner@vger.kernel.org To: Alexandre Belloni Cc: Eddie Huang , Lee Jones , Alessandro Zummo , Matthias Brugger , Andrew Morton , Tomasz Figa , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , srv_heupstream@mediatek.com, Samuel Ortiz , Greg KH , linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Tianping Fang List-Id: linux-mediatek@lists.infradead.org On Tue, 2015-05-05 at 22:00 +0200, Alexandre Belloni wrote: > Hi, > > This looks mostly good. Could you align the wrapped function parameters > to the open parenthesis (use checkpatch --strict)? > > On 28/04/2015 at 15:35:55 +0800, Eddie Huang wrote : > > +static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) > > +{ > > + unsigned long timeout = jiffies + HZ; > > + int ret; > > + u32 data; > > + > > + ret = regmap_write(rtc->regmap, rtc->addr_base + RTC_WRTGR, 1); > > + if (ret < 0) > > + return ret; > > + > > + do { > > + cpu_relax(); > > + ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, > > + &data); > > + if (ret < 0) > > + goto exit; > > + } while ((data & RTC_BBPU_CBUSY) && time_after(timeout, jiffies)); > > + > > Shouldn't you return -ETIMEDOUT if the loop breaks because of time_after? Probably yes. I believe as written the time_after test is too much for my little brain. I would have used time_before and reversed the args. I suggest moving the time_after() test into the loop, use break; and remove the exit label too. Maybe something like: while (1) { ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, &data); if (ret < 0) break; if (!(data & RTC_BBPU_CBUSY)) break; if (time_after(jiffies, timeout)) { ret = -ETIMEDOUT; break; } cpu_relax(); } return ret; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtprelay.hostedemail.com (smtprelay0042.hostedemail.com. [216.40.44.42]) by gmr-mx.google.com with ESMTP id ux4si46752igb.1.2015.05.05.13.44.27 for ; Tue, 05 May 2015 13:44:27 -0700 (PDT) Message-ID: <1430858661.9365.20.camel@perches.com> Subject: Re: [rtc-linux] [PATCH v3 2/3] rtc: mediatek: Add MT6397 RTC driver From: Joe Perches To: Alexandre Belloni Cc: Eddie Huang , Lee Jones , Alessandro Zummo , Matthias Brugger , Andrew Morton , Tomasz Figa , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , srv_heupstream@mediatek.com, Samuel Ortiz , Greg KH , linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Tianping Fang Date: Tue, 05 May 2015 13:44:21 -0700 In-Reply-To: <20150505200010.GP4276@piout.net> References: <1430206556-18254-1-git-send-email-eddie.huang@mediatek.com> <1430206556-18254-3-git-send-email-eddie.huang@mediatek.com> <20150505200010.GP4276@piout.net> Content-Type: text/plain; charset=UTF-8 Mime-Version: 1.0 Reply-To: rtc-linux@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , On Tue, 2015-05-05 at 22:00 +0200, Alexandre Belloni wrote: > Hi, > > This looks mostly good. Could you align the wrapped function parameters > to the open parenthesis (use checkpatch --strict)? > > On 28/04/2015 at 15:35:55 +0800, Eddie Huang wrote : > > +static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) > > +{ > > + unsigned long timeout = jiffies + HZ; > > + int ret; > > + u32 data; > > + > > + ret = regmap_write(rtc->regmap, rtc->addr_base + RTC_WRTGR, 1); > > + if (ret < 0) > > + return ret; > > + > > + do { > > + cpu_relax(); > > + ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, > > + &data); > > + if (ret < 0) > > + goto exit; > > + } while ((data & RTC_BBPU_CBUSY) && time_after(timeout, jiffies)); > > + > > Shouldn't you return -ETIMEDOUT if the loop breaks because of time_after? Probably yes. I believe as written the time_after test is too much for my little brain. I would have used time_before and reversed the args. I suggest moving the time_after() test into the loop, use break; and remove the exit label too. Maybe something like: while (1) { ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, &data); if (ret < 0) break; if (!(data & RTC_BBPU_CBUSY)) break; if (time_after(jiffies, timeout)) { ret = -ETIMEDOUT; break; } cpu_relax(); } return ret; } -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 From: joe@perches.com (Joe Perches) Date: Tue, 05 May 2015 13:44:21 -0700 Subject: [rtc-linux] [PATCH v3 2/3] rtc: mediatek: Add MT6397 RTC driver In-Reply-To: <20150505200010.GP4276@piout.net> References: <1430206556-18254-1-git-send-email-eddie.huang@mediatek.com> <1430206556-18254-3-git-send-email-eddie.huang@mediatek.com> <20150505200010.GP4276@piout.net> Message-ID: <1430858661.9365.20.camel@perches.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Tue, 2015-05-05 at 22:00 +0200, Alexandre Belloni wrote: > Hi, > > This looks mostly good. Could you align the wrapped function parameters > to the open parenthesis (use checkpatch --strict)? > > On 28/04/2015 at 15:35:55 +0800, Eddie Huang wrote : > > +static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc) > > +{ > > + unsigned long timeout = jiffies + HZ; > > + int ret; > > + u32 data; > > + > > + ret = regmap_write(rtc->regmap, rtc->addr_base + RTC_WRTGR, 1); > > + if (ret < 0) > > + return ret; > > + > > + do { > > + cpu_relax(); > > + ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, > > + &data); > > + if (ret < 0) > > + goto exit; > > + } while ((data & RTC_BBPU_CBUSY) && time_after(timeout, jiffies)); > > + > > Shouldn't you return -ETIMEDOUT if the loop breaks because of time_after? Probably yes. I believe as written the time_after test is too much for my little brain. I would have used time_before and reversed the args. I suggest moving the time_after() test into the loop, use break; and remove the exit label too. Maybe something like: while (1) { ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU, &data); if (ret < 0) break; if (!(data & RTC_BBPU_CBUSY)) break; if (time_after(jiffies, timeout)) { ret = -ETIMEDOUT; break; } cpu_relax(); } return ret; }