]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
rt2x00: Fix chipset revision validation
authorIvo van Doorn <ivdoorn@gmail.com>
Mon, 12 Nov 2007 14:02:22 +0000 (15:02 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 15 Nov 2007 02:21:15 +0000 (21:21 -0500)
The validation of the chipset revision was broken
since for rt2500usb and rt73usb different registers
should be read. When rt2500usb was loaded for a rt73
device it would false think the chipset was correct
because the wrong register was read and validated.

This has been fixed by expanding the check to also
see if the first 4 bits of the revision is not-0
(When reading the wrong register offset the returned
value is usually 0 which can be interpreted as invalid)

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt73usb.c

index ff2d63267b19e8acb41b356e8524e3451014f291..702321c30164d6e46310b9f959c4497a27d68bb9 100644 (file)
@@ -620,7 +620,7 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
         * up to version C the link tuning should halt after 20
         * seconds.
         */
-       if (rt2x00_get_rev(&rt2x00dev->chip) < RT2560_VERSION_D &&
+       if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D &&
            rt2x00dev->link.count > 20)
                return;
 
@@ -630,7 +630,7 @@ static void rt2500pci_link_tuner(struct rt2x00_dev *rt2x00dev)
         * Chipset versions C and lower should directly continue
         * to the dynamic CCA tuning.
         */
-       if (rt2x00_get_rev(&rt2x00dev->chip) < RT2560_VERSION_D)
+       if (rt2x00_rev(&rt2x00dev->chip) < RT2560_VERSION_D)
                goto dynamic_cca_tune;
 
        /*
index 7cdc80a122bb9aaa10b9f9eb514fad6c1d0005de..277a020b35e9039c994e583c1c0a276c11511e1a 100644 (file)
@@ -753,7 +753,7 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
        rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 1);
        rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
 
-       if (rt2x00_get_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) {
+       if (rt2x00_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) {
                rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg);
                reg &= ~0x0002;
        } else {
@@ -1257,7 +1257,7 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
        rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
 
-       if (rt2x00_rev(&rt2x00dev->chip, 0xffff0)) {
+       if (!rt2x00_check_rev(&rt2x00dev->chip, 0)) {
                ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
                return -ENODEV;
        }
index 9845e584b731a48454ebf0ccf08ef606dffb8ea8..d1ad5251a77a89d1f0afbee37c2ebf1dd77f328a 100644 (file)
@@ -751,14 +751,16 @@ static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip)
        return (chipset->rf == chip);
 }
 
-static inline u16 rt2x00_get_rev(const struct rt2x00_chip *chipset)
+static inline u16 rt2x00_rev(const struct rt2x00_chip *chipset)
 {
        return chipset->rev;
 }
 
-static inline u16 rt2x00_rev(const struct rt2x00_chip *chipset, const u32 mask)
+static inline u16 rt2x00_check_rev(const struct rt2x00_chip *chipset,
+                                  const u32 rev)
 {
-       return chipset->rev & mask;
+       return (((chipset->rev & 0xffff0) == rev) &&
+               !!(chipset->rev & 0x0000f));
 }
 
 /*
index 46c8c0840a6531703ed85d31a0604598502f4baf..dc640bf6b5ebe86f3b4ee99cb29e871949e8da8c 100644 (file)
@@ -1486,7 +1486,7 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        rt73usb_register_read(rt2x00dev, MAC_CSR0, &reg);
        rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
 
-       if (!rt2x00_rev(&rt2x00dev->chip, 0x25730)) {
+       if (!rt2x00_check_rev(&rt2x00dev->chip, 0x25730)) {
                ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
                return -ENODEV;
        }