From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "Ben Dooks (embedded platforms)"
<ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] i2c: test off by one in {piix4,vt596}_transaction()
Date: Wed, 6 Jan 2010 12:14:34 +0100 [thread overview]
Message-ID: <20100106121434.5553d1cc@hyperion.delvare> (raw)
In-Reply-To: <4B43AD8F.2030809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Tue, 05 Jan 2010 22:22:23 +0100, Roel Kluin wrote:
> With `while (timeout++ < MAX_TIMEOUT)' timeout reaches MAX_TIMEOUT + 1 after the loop
> This is probably unlikely to produce a problem.
>
> Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> > That's right... but I'd rather change the loops to use "++timeout" and
> > leave the conditions as is (or maybe change it to "=="). I think it's
> > easier to read that way. Would that be OK with you?
>
> Ok,
>
> drivers/i2c/busses/i2c-piix4.c | 4 ++--
> drivers/i2c/busses/i2c-viapro.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 1e245e9..e56e4b6 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -324,12 +324,12 @@ static int piix4_transaction(void)
> else
> msleep(1);
>
> - while ((timeout++ < MAX_TIMEOUT) &&
> + while ((++timeout < MAX_TIMEOUT) &&
> ((temp = inb_p(SMBHSTSTS)) & 0x01))
> msleep(1);
>
> /* If the SMBus is still busy, we give up */
> - if (timeout >= MAX_TIMEOUT) {
> + if (timeout == MAX_TIMEOUT) {
> dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
> result = -ETIMEDOUT;
> }
> diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
> index e4b1543..a84a909 100644
> --- a/drivers/i2c/busses/i2c-viapro.c
> +++ b/drivers/i2c/busses/i2c-viapro.c
> @@ -165,10 +165,10 @@ static int vt596_transaction(u8 size)
> do {
> msleep(1);
> temp = inb_p(SMBHSTSTS);
> - } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
> + } while ((temp & 0x01) && (++timeout < MAX_TIMEOUT));
>
> /* If the SMBus is still busy, we give up */
> - if (timeout >= MAX_TIMEOUT) {
> + if (timeout == MAX_TIMEOUT) {
> result = -ETIMEDOUT;
> dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
> }
Applied, thanks.
--
Jean Delvare
WARNING: multiple messages have this Message-ID (diff)
From: Jean Delvare <khali@linux-fr.org>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
linux-i2c@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] i2c: test off by one in {piix4,vt596}_transaction()
Date: Wed, 6 Jan 2010 12:14:34 +0100 [thread overview]
Message-ID: <20100106121434.5553d1cc@hyperion.delvare> (raw)
In-Reply-To: <4B43AD8F.2030809@gmail.com>
On Tue, 05 Jan 2010 22:22:23 +0100, Roel Kluin wrote:
> With `while (timeout++ < MAX_TIMEOUT)' timeout reaches MAX_TIMEOUT + 1 after the loop
> This is probably unlikely to produce a problem.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> > That's right... but I'd rather change the loops to use "++timeout" and
> > leave the conditions as is (or maybe change it to "=="). I think it's
> > easier to read that way. Would that be OK with you?
>
> Ok,
>
> drivers/i2c/busses/i2c-piix4.c | 4 ++--
> drivers/i2c/busses/i2c-viapro.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
> index 1e245e9..e56e4b6 100644
> --- a/drivers/i2c/busses/i2c-piix4.c
> +++ b/drivers/i2c/busses/i2c-piix4.c
> @@ -324,12 +324,12 @@ static int piix4_transaction(void)
> else
> msleep(1);
>
> - while ((timeout++ < MAX_TIMEOUT) &&
> + while ((++timeout < MAX_TIMEOUT) &&
> ((temp = inb_p(SMBHSTSTS)) & 0x01))
> msleep(1);
>
> /* If the SMBus is still busy, we give up */
> - if (timeout >= MAX_TIMEOUT) {
> + if (timeout == MAX_TIMEOUT) {
> dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
> result = -ETIMEDOUT;
> }
> diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
> index e4b1543..a84a909 100644
> --- a/drivers/i2c/busses/i2c-viapro.c
> +++ b/drivers/i2c/busses/i2c-viapro.c
> @@ -165,10 +165,10 @@ static int vt596_transaction(u8 size)
> do {
> msleep(1);
> temp = inb_p(SMBHSTSTS);
> - } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
> + } while ((temp & 0x01) && (++timeout < MAX_TIMEOUT));
>
> /* If the SMBus is still busy, we give up */
> - if (timeout >= MAX_TIMEOUT) {
> + if (timeout == MAX_TIMEOUT) {
> result = -ETIMEDOUT;
> dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
> }
Applied, thanks.
--
Jean Delvare
next prev parent reply other threads:[~2010-01-06 11:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-27 14:49 [PATCH] i2c: test off by one in {piix4,vt596}_transaction() Roel Kluin
2009-12-27 14:49 ` Roel Kluin
[not found] ` <4B3773F2.3010703-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-01-05 16:55 ` Jean Delvare
2010-01-05 16:55 ` Jean Delvare
[not found] ` <20100105175511.39dc6c42-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-01-05 21:22 ` Roel Kluin
2010-01-05 21:22 ` Roel Kluin
[not found] ` <4B43AD8F.2030809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-01-06 11:14 ` Jean Delvare [this message]
2010-01-06 11:14 ` 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=20100106121434.5553d1cc@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.