rt2x00: Fix beacon de-synchronization while update beacon
[pandora-kernel.git] / drivers / net / wireless / rt2x00 / rt2500pci.c
index e1be67c..4186582 100644 (file)
@@ -199,7 +199,6 @@ static const struct rt2x00debug rt2500pci_rt2x00debug = {
 };
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 
-#ifdef CONFIG_RT2X00_LIB_RFKILL
 static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
@@ -207,9 +206,6 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
        rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
        return rt2x00_get_field32(reg, GPIOCSR_BIT0);
 }
-#else
-#define rt2500pci_rfkill_poll  NULL
-#endif /* CONFIG_RT2X00_LIB_RFKILL */
 
 #ifdef CONFIG_RT2X00_LIB_LEDS
 static void rt2500pci_brightness_set(struct led_classdev *led_cdev,
@@ -341,10 +337,11 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
        preamble_mask = erp->short_preamble << 3;
 
        rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
-       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT,
-                          erp->ack_timeout);
+       rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, erp->ack_timeout);
        rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME,
                           erp->ack_consume_time);
+       rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
+       rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
        rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
 
        rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
@@ -377,6 +374,11 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field32(&reg, CSR11_SLOT_TIME, erp->slot_time);
        rt2x00pci_register_write(rt2x00dev, CSR11, reg);
 
+       rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
+       rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL, erp->beacon_int * 16);
+       rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION, erp->beacon_int * 16);
+       rt2x00pci_register_write(rt2x00dev, CSR12, reg);
+
        rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
        rt2x00_set_field32(&reg, CSR18_SIFS, erp->sifs);
        rt2x00_set_field32(&reg, CSR18_PIFS, erp->pifs);
@@ -552,24 +554,6 @@ static void rt2500pci_config_retry_limit(struct rt2x00_dev *rt2x00dev,
        rt2x00pci_register_write(rt2x00dev, CSR11, reg);
 }
 
-static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev,
-                                     struct rt2x00lib_conf *libconf)
-{
-       u32 reg;
-
-       rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
-       rt2x00_set_field32(&reg, TXCSR1_TSF_OFFSET, IEEE80211_HEADER);
-       rt2x00_set_field32(&reg, TXCSR1_AUTORESPONDER, 1);
-       rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
-
-       rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
-       rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL,
-                          libconf->conf->beacon_int * 16);
-       rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION,
-                          libconf->conf->beacon_int * 16);
-       rt2x00pci_register_write(rt2x00dev, CSR12, reg);
-}
-
 static void rt2500pci_config_ps(struct rt2x00_dev *rt2x00dev,
                                struct rt2x00lib_conf *libconf)
 {
@@ -581,7 +565,7 @@ static void rt2500pci_config_ps(struct rt2x00_dev *rt2x00dev,
        if (state == STATE_SLEEP) {
                rt2x00pci_register_read(rt2x00dev, CSR20, &reg);
                rt2x00_set_field32(&reg, CSR20_DELAY_AFTER_TBCN,
-                                  (libconf->conf->beacon_int - 20) * 16);
+                                  (rt2x00dev->beacon_int - 20) * 16);
                rt2x00_set_field32(&reg, CSR20_TBCN_BEFORE_WAKEUP,
                                   libconf->conf->listen_interval - 1);
 
@@ -609,8 +593,6 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
                                         libconf->conf->power_level);
        if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
                rt2500pci_config_retry_limit(rt2x00dev, libconf);
-       if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
-               rt2500pci_config_duration(rt2x00dev, libconf);
        if (flags & IEEE80211_CONF_CHANGE_PS)
                rt2500pci_config_ps(rt2x00dev, libconf);
 }
@@ -1245,8 +1227,6 @@ static void rt2500pci_write_beacon(struct queue_entry *entry)
         * otherwise we might be sending out invalid data.
         */
        rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
-       rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 0);
-       rt2x00_set_field32(&reg, CSR14_TBCN, 0);
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 
@@ -1562,10 +1542,8 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
        /*
         * Detect if this device has an hardware controlled radio.
         */
-#ifdef CONFIG_RT2X00_LIB_RFKILL
        if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
                __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
-#endif /* CONFIG_RT2X00_LIB_RFKILL */
 
        /*
         * Check if the BBP tuning should be enabled.
@@ -1879,14 +1857,15 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = {
        .add_interface          = rt2x00mac_add_interface,
        .remove_interface       = rt2x00mac_remove_interface,
        .config                 = rt2x00mac_config,
-       .config_interface       = rt2x00mac_config_interface,
        .configure_filter       = rt2x00mac_configure_filter,
+       .set_tim                = rt2x00mac_set_tim,
        .get_stats              = rt2x00mac_get_stats,
        .bss_info_changed       = rt2x00mac_bss_info_changed,
        .conf_tx                = rt2x00mac_conf_tx,
        .get_tx_stats           = rt2x00mac_get_tx_stats,
        .get_tsf                = rt2500pci_get_tsf,
        .tx_last_beacon         = rt2500pci_tx_last_beacon,
+       .rfkill_poll            = rt2x00mac_rfkill_poll,
 };
 
 static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {