public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mike Rapoport <mike-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>,
	Eric Miao <eric.miao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [PATCH] i2c: timeouts reach -1
Date: Sun, 1 Feb 2009 13:18:54 +0100	[thread overview]
Message-ID: <20090201131854.64f54b28@hyperion.delvare> (raw)
In-Reply-To: <20090131221043.23d3ecab-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

On Sat, 31 Jan 2009 22:10:43 +0100, Jean Delvare wrote:
> Hi Roel,
> 
> On Sat, 31 Jan 2009 11:22:58 +0100, Roel Kluin wrote:
> > With a postfix decrement these timeouts reach -1 rather than 0,
> > but after the loop it is tested whether they have become 0.
> > 
> > Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > (...)
> > diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> > index 6af6814..6379ec1 100644
> > --- a/drivers/i2c/busses/i2c-pxa.c
> > +++ b/drivers/i2c/busses/i2c-pxa.c
> > @@ -644,7 +644,7 @@ static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,
> >  
> >  	i2c_pxa_start_message(i2c);
> >  
> > -	while (timeout-- && i2c->msg_num > 0) {
> > +	while (--timeout && i2c->msg_num > 0) {
> >  		i2c_pxa_handler(0, i2c);
> >  		udelay(10);
> >  	}
> 
> Good catch. Applied, thanks for reporting.

On second thought, shouldn't the msg_num test be done first and the
timeout test second? With the current order, you could exit with a
timeout error while all the messages were successfully transferred.

-- 
Jean Delvare

  parent reply	other threads:[~2009-02-01 12:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-31 10:22 [PATCH] i2c: timeouts reach -1 Roel Kluin
     [not found] ` <49842682.2020903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-01-31 21:10   ` Jean Delvare
     [not found]     ` <20090131221043.23d3ecab-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-01 12:18       ` Jean Delvare [this message]
     [not found]         ` <20090201131854.64f54b28-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-02 21:50           ` Roel Kluin
     [not found]             ` <49876AB7.5030100-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-03 19:08               ` Jean Delvare

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=20090201131854.64f54b28@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=eric.miao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mike-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org \
    --cc=roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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