[PATCH] rt2x00: Move TSF sync values into rt2x00config
authorIvo van Doorn <ivdoorn@gmail.com>
Sat, 6 Oct 2007 12:14:29 +0000 (14:14 +0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:55:12 +0000 (16:55 -0700)
All drivers use the same values for TSF sync,
this will move the value determination into rt2x00config.c,
and the definition for the values to rt2x00reg.h

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

index 28999ffaba2ebe19e7d5297efb92396e1c14feab..0e345659f42190e4ce4622b277f34a88f81a8f8f 100644 (file)
@@ -265,9 +265,9 @@ static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev,
                                      (2 * sizeof(__le32)));
 }
 
-static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
+static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                                 const int tsf_sync)
 {
-       struct interface *intf = &rt2x00dev->interface;
        u32 reg;
 
        rt2x00pci_register_write(rt2x00dev, CSR14, 0);
@@ -287,13 +287,7 @@ static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
        rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
        rt2x00_set_field32(&reg, CSR14_TBCN, 1);
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-           is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-       else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-       else
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 }
 
index 9d9b4377a6f2f4b91bc3228f4575ad65d371b737..fa8669f5c965fd7a9aabdc7d93ae7c164658d904 100644 (file)
@@ -265,9 +265,9 @@ static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev,
                                      (2 * sizeof(__le32)));
 }
 
-static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                                 const int tsf_sync)
 {
-       struct interface *intf = &rt2x00dev->interface;
        u32 reg;
 
        rt2x00pci_register_write(rt2x00dev, CSR14, 0);
@@ -291,13 +291,7 @@ static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
        rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
        rt2x00_set_field32(&reg, CSR14_TBCN, 1);
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-           is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-       else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-       else
-               rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 }
 
index 3dbd381f142838f845071767a91bb9b7c0d91bfd..6d5444b58e6cffe2626b0eea0d864c0d47c9b7c0 100644 (file)
@@ -268,9 +268,9 @@ static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev,
                                      (3 * sizeof(__le16)));
 }
 
-static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                                 const int tsf_sync)
 {
-       struct interface *intf = &rt2x00dev->interface;
        u16 reg;
 
        rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0);
@@ -281,7 +281,7 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
        rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
        rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET,
                           (PREAMBLE + get_duration(IEEE80211_HEADER, 2)) >> 6);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
+       if (type == IEEE80211_IF_TYPE_STA)
                rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 0);
        else
                rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 2);
@@ -298,13 +298,7 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
        rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
        rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
        rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-           is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 2);
-       else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 1);
-       else
-               rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0);
+       rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, tsf_sync);
        rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
 }
 
index 235e5ad21908ded71e8dc03f6171ea29caf8dcf8..27bec6ec33dfbb2556ff936aca8ef2396c00b427 100644 (file)
@@ -410,7 +410,8 @@ struct rt2x00lib_ops {
         */
        void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
        void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
-       void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type);
+       void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type,
+                                                          const int tsf_sync);
        void (*config) (struct rt2x00_dev *rt2x00dev, const unsigned int flags,
                        struct ieee80211_conf *conf);
 #define CONFIG_UPDATE_PHYMODE          ( 1 << 1 )
index aeeaa0c142450df8bca317a9aeda758f46bab4ec..f8e87aa863357d015b1762856c2ca73447414d2e 100644 (file)
@@ -74,10 +74,24 @@ void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
        rt2x00dev->ops->lib->config_bssid(rt2x00dev, &reg[0]);
 }
 
-void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
+void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 {
-       if (type != INVALID_INTERFACE)
-               rt2x00dev->ops->lib->config_type(rt2x00dev, type);
+       int tsf_sync;
+
+       switch (type) {
+       case IEEE80211_IF_TYPE_IBSS:
+       case IEEE80211_IF_TYPE_AP:
+               tsf_sync = TSF_SYNC_BEACON;
+               break;
+       case IEEE80211_IF_TYPE_STA:
+               tsf_sync = TSF_SYNC_INFRA;
+               break;
+       default:
+               tsf_sync = TSF_SYNC_NONE;
+               break;
+       }
+
+       rt2x00dev->ops->lib->config_type(rt2x00dev, type, tsf_sync);
 }
 
 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
index 0ab39cad3cc874ac9df768aa2c8241d2f50c9943..29ca932d77aba5ef9362ac1d224b7bab12d782ff 100644 (file)
@@ -52,7 +52,7 @@ void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev);
  */
 void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac);
 void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid);
-void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type);
+void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type);
 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
                      struct ieee80211_conf *conf, const int force_config);
 
index 7927d5f7bcc72ed890479ec1602b85589fd39560..838421216da0d52a0d7aedd0f78ec56a09ec9756 100644 (file)
@@ -58,6 +58,15 @@ enum led_mode {
        LED_MODE_ALPHA = 4,
 };
 
+/*
+ * TSF sync values
+ */
+enum tsf_sync {
+       TSF_SYNC_NONE = 0,
+       TSF_SYNC_INFRA = 1,
+       TSF_SYNC_BEACON = 2,
+};
+
 /*
  * Device states
  */
index 1c3937a3f9dcd5356c0c99080e279d7c70ba5193..1c0789f2a4118532ca27c585f89005daccb57c51 100644 (file)
@@ -300,9 +300,9 @@ static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
                                      (2 * sizeof(__le32)));
 }
 
-static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                               const int tsf_sync)
 {
-       struct interface *intf = &rt2x00dev->interface;
        u32 reg;
 
        /*
@@ -324,13 +324,7 @@ static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
        rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
        rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
        rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-           is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
-       else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
-       else
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, tsf_sync);
        rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
 }
 
index 6d1635b5cd07baa7eb8e505514277fdc6e10ffc8..919cca593bc193a1923776464ab5e94f23266d72 100644 (file)
@@ -279,9 +279,9 @@ static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
                                    (2 * sizeof(__le32)));
 }
 
-static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+                               const int tsf_sync)
 {
-       struct interface *intf = &rt2x00dev->interface;
        u32 reg;
 
        /*
@@ -303,13 +303,7 @@ static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
        rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
        rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
        rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
-       if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-           is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
-       else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
-       else
-               rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
+       rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, tsf_sync);
        rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
 }