public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: joe@perches•com (Joe Perches)
To: linux-arm-kernel@lists•infradead.org
Subject: [rtc-linux] [PATCH v3 2/3] rtc: mediatek: Add MT6397 RTC driver
Date: Tue, 05 May 2015 13:44:21 -0700	[thread overview]
Message-ID: <1430858661.9365.20.camel@perches.com> (raw)
In-Reply-To: <20150505200010.GP4276@piout.net>

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;
}

  reply	other threads:[~2015-05-05 20:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28  7:35 [PATCH v3 0/3] Add Mediatek SoC RTC driver Eddie Huang
2015-04-28  7:35 ` [PATCH v3 1/3] mfd: provide RTC resource in MT6397 MFD Eddie Huang
2015-04-28  7:45   ` Uwe Kleine-König
2015-04-28 10:07   ` Lee Jones
2015-04-28  7:35 ` [PATCH v3 2/3] rtc: mediatek: Add MT6397 RTC driver Eddie Huang
2015-05-05 20:00   ` [rtc-linux] " Alexandre Belloni
2015-05-05 20:44     ` Joe Perches [this message]
2015-05-05 21:01       ` Alexandre Belloni
2015-05-06  3:32         ` Eddie Huang
2015-04-28  7:35 ` [PATCH v3 3/3] MAINTAINERS: add Mediatek " Eddie Huang
2015-05-05 20:03   ` [rtc-linux] " Alexandre Belloni
2015-05-06  3:36     ` Eddie Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430858661.9365.20.camel@perches.com \
    --to=joe@perches$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox