rt2x00: Fix HW crypto key handling
authorIvo van Doorn <ivdoorn@gmail.com>
Mon, 22 Sep 2008 17:40:04 +0000 (19:40 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 24 Sep 2008 20:18:03 +0000 (16:18 -0400)
When a crypto key is being removed, rt2x00mac should not
reset the key->hw_key_idx value because that will prevent
the driver from removing the correct key from the hardware.

Furthermore ffz() starts counting at 0 instead of 1, so we don't
need to substract 1 from the resulting value.

Signed-off-by: Stephen Blackheath <tramp.enshrine.stephen@blacksapphire.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2x00mac.c
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt73usb.c

index 485c40de5cc0448f02cd93aa78790696c55cfbf2..2c6cc5c374ff3be765b681e07d17fede815a3d22 100644 (file)
@@ -543,7 +543,8 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
         * provided but key 0 is not, then the key is not found
         * by the hardware during RX).
         */
-       key->hw_key_idx = 0;
+       if (cmd == SET_KEY)
+               key->hw_key_idx = 0;
 
        if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
                set_key = rt2x00dev->ops->lib->config_pairwise_key;
index 2c36b91ff4c79da5525e6163c604fbdd22f6a65b..a461620b489f0350536bb06148e2813c609ea77f 100644 (file)
@@ -381,7 +381,7 @@ static int rt61pci_config_shared_key(struct rt2x00_dev *rt2x00dev,
                if (reg && reg == mask)
                        return -ENOSPC;
 
-               key->hw_key_idx += reg ? (ffz(reg) - 1) : 0;
+               key->hw_key_idx += reg ? ffz(reg) : 0;
 
                /*
                 * Upload key to hardware
@@ -477,7 +477,7 @@ static int rt61pci_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
                                return -ENOSPC;
                }
 
-               key->hw_key_idx += reg ? (ffz(reg) - 1) : 0;
+               key->hw_key_idx += reg ? ffz(reg) : 0;
 
                /*
                 * Upload key to hardware
index 27dde3e34603705a5fdc56cdf1a5fe8fbc8debd4..934f8e03c5aae99fa9f6175d0c509d48fc245a48 100644 (file)
@@ -393,7 +393,7 @@ static int rt73usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
                if (reg && reg == mask)
                        return -ENOSPC;
 
-               key->hw_key_idx += reg ? (ffz(reg) - 1) : 0;
+               key->hw_key_idx += reg ? ffz(reg) : 0;
 
                /*
                 * Upload key to hardware
@@ -494,7 +494,7 @@ static int rt73usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
                                return -ENOSPC;
                }
 
-               key->hw_key_idx += reg ? (ffz(reg) - 1) : 0;
+               key->hw_key_idx += reg ? ffz(reg) : 0;
 
                /*
                 * Upload key to hardware