linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wl12xx: loop off by one.
@ 2009-07-06 19:20 Roel Kluin
  2009-07-16  9:23 ` Kalle Valo
  2009-07-16 10:36 ` Roel Kluin
  0 siblings, 2 replies; 4+ messages in thread
From: Roel Kluin @ 2009-07-06 19:20 UTC (permalink / raw)
  To: kalle.valo, linux-wireless, Andrew Morton

with `while (loop++ < INIT_LOOP)' `loop' reaches -1 after the loop.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c
index 48ac08c..8899905 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -247,7 +247,7 @@ int wl12xx_boot_run_firmware(struct wl12xx *wl)
 		}
 	}
 
-	if (loop >= INIT_LOOP) {
+	if (loop > INIT_LOOP) {
 		wl12xx_error("timeout waiting for the hardware to "
 			     "complete initialization");
 		return -EIO;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] wl12xx: loop off by one.
  2009-07-06 19:20 [PATCH] wl12xx: loop off by one Roel Kluin
@ 2009-07-16  9:23 ` Kalle Valo
  2009-07-16 10:36 ` Roel Kluin
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2009-07-16  9:23 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linux-wireless, Andrew Morton

Roel Kluin <roel.kluin@gmail.com> writes:

> with `while (loop++ < INIT_LOOP)' `loop' reaches -1 after the loop.

Sorry, my brains are on vacation mode right now and I can't understand
how loop can reach -1. Here's the code:

    loop = 0;
    while (loop++ < INIT_LOOP) {
          ...
    }

    if (loop >= INIT_LOOP) {
       wl1251_error("timeout waiting for the hardware to "
                    "complete initialization");
       return -EIO;
    }

What am I missing?

Also the patch won't apply to wireless-testing because main.c is renamed
to wl1251_main.c.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] wl12xx: loop off by one.
  2009-07-06 19:20 [PATCH] wl12xx: loop off by one Roel Kluin
  2009-07-16  9:23 ` Kalle Valo
@ 2009-07-16 10:36 ` Roel Kluin
  2009-07-16 13:44   ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-07-16 10:36 UTC (permalink / raw)
  To: Roel Kluin; +Cc: kalle.valo, linux-wireless, Andrew Morton

With `while (loop++ < INIT_LOOP)' `loop' becomes INIT_LOOP + 1 after
the loop.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
>> with `while (loop++ < INIT_LOOP)' `loop' reaches -1 after the loop.
>
> Sorry, my brains are on vacation mode right now and I can't understand
> how loop can reach -1.

The confusion is my fault. The changelog should have as above. The patch
is correct though.

> Here's the code:

>    loop = 0;
>    while (loop++ < INIT_LOOP) {
>          ...
>    }
>
>    if (loop >= INIT_LOOP) {
>       wl1251_error("timeout waiting for the hardware to "
>                    "complete initialization");
>       return -EIO;
>    }

In the last iteration `loop' is `INIT_LOOP -1', the test occurs and then
the increment to `INIT_LOOP'. If just then the break occurs:
`if (interrupt & wl->chip.intr_init_complete)' evaluates to true, then
we error out, although there was no timeout. This could be very unlikely
to occur.

> Also the patch won't apply to wireless-testing because main.c is renamed
> to wl1251_main.c.

Ok, this is against your tree

diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index d8a155d..b2ae71c 100644
--- a/drivers/net/wireless/wl12xx/wl1251_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -247,7 +247,7 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
 		}
 	}
 
-	if (loop >= INIT_LOOP) {
+	if (loop > INIT_LOOP) {
 		wl1251_error("timeout waiting for the hardware to "
 			     "complete initialization");
 		return -EIO;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] wl12xx: loop off by one.
  2009-07-16 10:36 ` Roel Kluin
@ 2009-07-16 13:44   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2009-07-16 13:44 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linux-wireless, Andrew Morton, John W. Linville

Roel Kluin <roel.kluin@gmail.com> writes:

> With `while (loop++ < INIT_LOOP)' `loop' becomes INIT_LOOP + 1 after
> the loop.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
>>> with `while (loop++ < INIT_LOOP)' `loop' reaches -1 after the loop.
>>
>> Sorry, my brains are on vacation mode right now and I can't understand
>> how loop can reach -1.
>
> The confusion is my fault. The changelog should have as above. The patch
> is correct though.

Ah. Thanks for explaining this to me, I understand this now. Good catch,
thanks for fixing this.

Acked-by: Kalle Valo <kalle.valo@nokia.com>

John, please take this patch. Please holler if we need to resend it.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-16 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-06 19:20 [PATCH] wl12xx: loop off by one Roel Kluin
2009-07-16  9:23 ` Kalle Valo
2009-07-16 10:36 ` Roel Kluin
2009-07-16 13:44   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).