orinoco: correct timeout logic in __orinoco_hw_set_tkip_key()
authorPavel Roskin <proski@gnu.org>
Fri, 10 Apr 2009 01:41:05 +0000 (21:41 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 16 Apr 2009 14:39:17 +0000 (10:39 -0400)
If the value read from HERMES_RID_TXQUEUEEMPTY becomes 0 after exactly
100 readings, we wrongly consider it a timeout.  Rewrite the clever
while loop as a for loop that does the right thing and looks simpler.

Reported by Juha Leppanen <juha_motorsportcom@luukku.com>

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/orinoco/hw.c

index 081428d9409eb1f7328d5303a06afeb05f141baa..632fac86a3085ee33713a1fb2f718e50527da053 100644 (file)
@@ -372,15 +372,13 @@ int __orinoco_hw_set_tkip_key(hermes_t *hw, int key_idx, int set_tx,
        }
 
        /* Wait upto 100ms for tx queue to empty */
-       k = 100;
-       do {
-               k--;
+       for (k = 100; k > 0; k--) {
                udelay(1000);
                ret = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_TXQUEUEEMPTY,
                                          &xmitting);
-               if (ret)
+               if (ret || !xmitting)
                        break;
-       } while ((k > 0) && xmitting);
+       }
 
        if (k == 0)
                ret = -ETIMEDOUT;