Search Linux Wireless

Re: [PATCH] wl12xx: loop off by one.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
---
>> 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;
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux