]> git.karo-electronics.de Git - linux-beck.git/commitdiff
rt2x00: Refactor rt2800 version constants.
authorGertjan van Wingerde <gwingerde@gmail.com>
Sun, 11 Apr 2010 12:31:10 +0000 (14:31 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 12 Apr 2010 19:22:11 +0000 (15:22 -0400)
The rt2800 version constants are inconsistent, and the version number don't
mean a lot of things anyway. Refactor the constants to have some more
meaningful names, and introduce and use some new helpers to check these
chipset revisions. At the same time rename to revision, as they are more
revision numbers rather than version numbers.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800.h
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2x00.h

index 4d5871b01caca96dd6dabc288c206bee3e5a5d7c..ec893721cc80c6ff6133c1119f093be9247d21b9 100644 (file)
 #define RF3320                         0x000b
 
 /*
- * Chipset version.
- */
-#define RT2860C_VERSION                        0x0100
-#define RT2860D_VERSION                        0x0101
-#define RT2880E_VERSION                        0x0200
-#define RT2883_VERSION                 0x0300
-#define RT3070_VERSION                 0x0200
+ * Chipset revisions.
+ */
+#define REV_RT2860C                    0x0100
+#define REV_RT2860D                    0x0101
+#define REV_RT2870D                    0x0101
+#define REV_RT2872E                    0x0200
+#define REV_RT3070E                    0x0200
+#define REV_RT3070F                    0x0201
+#define REV_RT3071E                    0x0211
+#define REV_RT3090E                    0x0211
+#define REV_RT3390E                    0x0211
 
 /*
  * Signal information.
index 2ab88840a3e5a797429023a6edf71fa97075f8a5..8a4ed7642bcf933354a1d6b408610c98d2670876 100644 (file)
@@ -896,8 +896,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
        rt2800_bbp_write(rt2x00dev, 3, bbp);
 
-       if (rt2x00_rt(rt2x00dev, RT2860) &&
-           (rt2x00_rev(rt2x00dev) == RT2860C_VERSION)) {
+       if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) {
                if (conf_is_ht40(conf)) {
                        rt2800_bbp_write(rt2x00dev, 69, 0x1a);
                        rt2800_bbp_write(rt2x00dev, 70, 0x0a);
@@ -1060,8 +1059,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
 {
        if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
                if (rt2x00_is_usb(rt2x00dev) &&
-                   rt2x00_rt(rt2x00dev, RT3070) &&
-                   (rt2x00_rev(rt2x00dev) == RT3070_VERSION))
+                   rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E))
                        return 0x1c + (2 * rt2x00dev->lna_gain);
                else
                        return 0x2e + rt2x00dev->lna_gain;
@@ -1092,8 +1090,7 @@ EXPORT_SYMBOL_GPL(rt2800_reset_tuner);
 void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
                       const u32 count)
 {
-       if (rt2x00_rt(rt2x00dev, RT2860) &&
-           (rt2x00_rev(rt2x00dev) == RT2860C_VERSION))
+       if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C))
                return;
 
        /*
@@ -1179,8 +1176,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
        rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
 
        if (rt2x00_is_usb(rt2x00dev) &&
-           rt2x00_rt(rt2x00dev, RT3070) &&
-           (rt2x00_rev(rt2x00dev) == RT3070_VERSION)) {
+           rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E)) {
                rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400);
                rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
                rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
@@ -1207,11 +1203,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
 
        rt2800_register_read(rt2x00dev, MAX_LEN_CFG, &reg);
        rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
-       if ((rt2x00_rt(rt2x00dev, RT2872) &&
-            (rt2x00_rev(rt2x00dev) >= RT2880E_VERSION)) ||
+       if (rt2x00_rt_rev_gte(rt2x00dev, RT2872, REV_RT2872E) ||
            rt2x00_rt(rt2x00dev, RT2883) ||
-           (rt2x00_rt(rt2x00dev, RT3070) &&
-            (rt2x00_rev(rt2x00dev) < RT3070_VERSION)))
+           rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070E))
                rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 2);
        else
                rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 1);
@@ -1490,14 +1484,12 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
        rt2800_bbp_write(rt2x00dev, 103, 0x00);
        rt2800_bbp_write(rt2x00dev, 105, 0x05);
 
-       if (rt2x00_rt(rt2x00dev, RT2860) &&
-           (rt2x00_rev(rt2x00dev) == RT2860C_VERSION)) {
+       if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) {
                rt2800_bbp_write(rt2x00dev, 69, 0x16);
                rt2800_bbp_write(rt2x00dev, 73, 0x12);
        }
 
-       if (rt2x00_rt(rt2x00dev, RT2860) &&
-           (rt2x00_rev(rt2x00dev) > RT2860D_VERSION))
+       if (rt2x00_rt_rev_gte(rt2x00dev, RT2860, REV_RT2860D))
                rt2800_bbp_write(rt2x00dev, 84, 0x19);
 
        if (rt2x00_rt(rt2x00dev, RT2872)) {
@@ -1507,8 +1499,7 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
        }
 
        if (rt2x00_is_usb(rt2x00dev) &&
-           rt2x00_rt(rt2x00dev, RT3070) &&
-           (rt2x00_rev(rt2x00dev) == RT3070_VERSION)) {
+           rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E)) {
                rt2800_bbp_write(rt2x00dev, 70, 0x0a);
                rt2800_bbp_write(rt2x00dev, 84, 0x99);
                rt2800_bbp_write(rt2x00dev, 105, 0x05);
@@ -1594,8 +1585,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
        u8 bbp;
 
        if (rt2x00_is_usb(rt2x00dev) &&
-           rt2x00_rt(rt2x00dev, RT3070) &&
-           (rt2x00_rev(rt2x00dev) != RT3070_VERSION))
+           !rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E))
                return 0;
 
        if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) {
index 16aa850d3700a76561b7fe2a1b676c1e210dce31..4de505b98331fb203ac369c82e039e3f702e4f15 100644 (file)
@@ -929,12 +929,12 @@ static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
             rt2x00dev->chip.rt, rt2x00dev->chip.rf, rt2x00dev->chip.rev);
 }
 
-static inline char rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
+static inline bool rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
 {
        return (rt2x00dev->chip.rt == rt);
 }
 
-static inline char rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
+static inline bool rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
 {
        return (rt2x00dev->chip.rf == rf);
 }
@@ -944,6 +944,24 @@ static inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev)
        return rt2x00dev->chip.rev;
 }
 
+static inline bool rt2x00_rt_rev(struct rt2x00_dev *rt2x00dev,
+                                const u16 rt, const u16 rev)
+{
+       return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) == rev);
+}
+
+static inline bool rt2x00_rt_rev_lt(struct rt2x00_dev *rt2x00dev,
+                                   const u16 rt, const u16 rev)
+{
+       return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) < rev);
+}
+
+static inline bool rt2x00_rt_rev_gte(struct rt2x00_dev *rt2x00dev,
+                                    const u16 rt, const u16 rev)
+{
+       return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) >= rev);
+}
+
 static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev,
                                        enum rt2x00_chip_intf intf)
 {