Merge branch 'hotfixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[pandora-kernel.git] / drivers / net / wireless / rt2x00 / rt2x00mac.c
index 3a1fb6d..c3ee4ec 100644 (file)
@@ -63,7 +63,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
         */
        memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb));
        rts_info = IEEE80211_SKB_CB(skb);
-       rts_info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT;
+       rts_info->control.hw_key = NULL;
        rts_info->flags &= ~IEEE80211_TX_CTL_USE_RTS_CTS;
        rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT;
        rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS;
@@ -83,6 +83,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
                                  (struct ieee80211_rts *)(skb->data));
 
        if (rt2x00queue_write_tx_frame(queue, skb)) {
+               dev_kfree_skb_any(skb);
                WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n");
                return NETDEV_TX_BUSY;
        }
@@ -309,6 +310,7 @@ EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);
 int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
 {
        struct rt2x00_dev *rt2x00dev = hw->priv;
+       int force_reconfig;
 
        /*
         * Mac80211 might be calling this function while we are trying
@@ -328,7 +330,17 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
                        rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
        }
 
-       rt2x00lib_config(rt2x00dev, conf, 0);
+       /*
+        * When the DEVICE_DIRTY_CONFIG flag is set, the device has recently
+        * been started and the configuration must be forced upon the hardware.
+        * Otherwise registers will not be intialized correctly and could
+        * result in non-working hardware because essential registers aren't
+        * initialized.
+        */
+       force_reconfig =
+           __test_and_clear_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags);
+
+       rt2x00lib_config(rt2x00dev, conf, force_reconfig);
 
        /*
         * Reenable RX only if the radio should be on.
@@ -348,7 +360,8 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
 {
        struct rt2x00_dev *rt2x00dev = hw->priv;
        struct rt2x00_intf *intf = vif_to_intf(vif);
-       int status;
+       int update_bssid = 0;
+       int status = 0;
 
        /*
         * Mac80211 might be calling this function while we are trying
@@ -360,12 +373,13 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
        spin_lock(&intf->lock);
 
        /*
-        * If the interface does not work in master mode,
-        * then the bssid value in the interface structure
-        * should now be set.
+        * conf->bssid can be NULL if coming from the internal
+        * beacon update routine.
         */
-       if (conf->type != IEEE80211_IF_TYPE_AP)
+       if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
+               update_bssid = 1;
                memcpy(&intf->bssid, conf->bssid, ETH_ALEN);
+       }
 
        spin_unlock(&intf->lock);
 
@@ -375,17 +389,14 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
         * values as arguments we make keep access to rt2x00_intf thread safe
         * even without the lock.
         */
-       rt2x00lib_config_intf(rt2x00dev, intf, conf->type, NULL, conf->bssid);
+       rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
+                             update_bssid ? conf->bssid : NULL);
 
        /*
-        * We only need to initialize the beacon when master mode is enabled.
+        * Update the beacon.
         */
-       if (conf->type != IEEE80211_IF_TYPE_AP || !conf->beacon)
-               return 0;
-
-       status = rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, conf->beacon);
-       if (status)
-               dev_kfree_skb(conf->beacon);
+       if (conf->changed & IEEE80211_IFCC_BEACON)
+               status = rt2x00queue_update_beacon(rt2x00dev, vif);
 
        return status;
 }
@@ -501,7 +512,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
         * When the erp information has changed, we should perform
         * additional configuration steps. For all other changes we are done.
         */
-       if (changes & BSS_CHANGED_ERP_PREAMBLE) {
+       if (changes & (BSS_CHANGED_ERP_PREAMBLE | BSS_CHANGED_ERP_CTS_PROT)) {
                if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
                        rt2x00lib_config_erp(rt2x00dev, intf, bss_conf);
                else
@@ -542,10 +553,7 @@ int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
        else
                queue->cw_max = 10; /* cw_min: 2^10 = 1024. */
 
-       if (params->aifs >= 0)
-               queue->aifs = params->aifs;
-       else
-               queue->aifs = 2;
+       queue->aifs = params->aifs;
 
        INFO(rt2x00dev,
             "Configured TX queue %d - CWmin: %d, CWmax: %d, Aifs: %d.\n",