From: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Mike Rapoport <mike-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>
Subject: Re: [PATCH] i2c-pxa.c: timeouts off by 1
Date: Wed, 29 Apr 2009 22:06:58 +0200 [thread overview]
Message-ID: <20090429200658.GA12251@pengutronix.de> (raw)
In-Reply-To: <20090423163507.9588a73d.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2131 bytes --]
On Thu, Apr 23, 2009 at 04:35:07PM -0700, Andrew Morton wrote:
> On Thu, 23 Apr 2009 17:02:18 +0200
> Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
>
> > On Thu, 23 Apr 2009 16:27:39 +0200, Roel Kluin wrote:
> > > Ok, here's for drivers/i2c/busses/i2c-pxa.c. Note that I found another,
> > > the last hunk.
> > > --------------------------->8-------------8<------------------------------
> > > With `while (timeout--)' timeout reaches -1 after the loop, so the tests
> > > below are off by one.
> > >
> > > Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > ---
> >
> > Ben, Wolfram, I'll let you handle this one as it's an arm driver.
> >
>
> The patch looks OK,
Yup.
Acked-by: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>
> : static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
> : {
> : int timeout = DEF_TIMEOUT;
> :
> : while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
> : if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
> : timeout += 4;
> :
> : msleep(2);
> : show_state(i2c);
> : }
> :
> : if (timeout < 0)
> : show_state(i2c);
> :
> : return timeout < 0 ? I2C_RETRY : 0;
> : }
>
> The timeout+=4 inside the loop makes my brain hurt. It makes the loop
> potentially almost-infinite. By effectively doing timeout+=3 each time
> we'll break out of the loop after we've wrapped through 0x100000000
> three times. Or something. Help!
Well, it only adds 4 if there was its own I2C-slave address detected. Without
knowing the details, I assume there is a reason; I wouldn't dare changing it.
> Also, i2c_pxa_pio_set_master() does
>
> long timeout = 2 * DEF_TIMEOUT;
>
> whereas i2c_pxa_wait_bus_not_bus() does
>
> int timeout = DEF_TIMEOUT;
>
>
> `int' seems an appropriate choice.
This driver seems to have quite some more potential for cleaning up :)
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
prev parent reply other threads:[~2009-04-29 20:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-25 11:00 [PATCH] i2c: timeouts off by 1 Roel Kluin
[not found] ` <49A524E4.5050108-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-04-23 12:36 ` Jean Delvare
[not found] ` <20090423143654.7fc2327e-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-04-23 14:27 ` [PATCH] i2c-pxa.c: " Roel Kluin
[not found] ` <49F07ADB.1030300-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-04-23 15:02 ` Jean Delvare
[not found] ` <20090423170218.66dda625-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-04-23 23:35 ` Andrew Morton
[not found] ` <20090423163507.9588a73d.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-04-29 20:06 ` Wolfram Sang [this message]
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=20090429200658.GA12251@pengutronix.de \
--to=w.sang-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@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