rt2x00: Fix MCS register intialization
[pandora-kernel.git] / drivers / net / wireless / mwl8k.c
index a263d5c..c32e93c 100644 (file)
@@ -261,7 +261,7 @@ struct mwl8k_vif {
         */
 };
 
-#define MWL8K_VIF(_vif) (struct mwl8k_vif *)(&((_vif)->drv_priv))
+#define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
 
 static const struct ieee80211_channel mwl8k_channels[] = {
        { .center_freq = 2412, .hw_value = 1, },
@@ -1012,6 +1012,8 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
                rmb();
 
                skb = rxq->rx_skb[rxq->rx_head];
+               if (skb == NULL)
+                       break;
                rxq->rx_skb[rxq->rx_head] = NULL;
 
                rxq->rx_head = (rxq->rx_head + 1) % MWL8K_RX_DESCS;
@@ -1047,7 +1049,8 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
                status.flag = 0;
                status.band = IEEE80211_BAND_2GHZ;
                status.freq = ieee80211_channel_to_frequency(rx_desc->channel);
-               ieee80211_rx_irqsafe(hw, skb, &status);
+               memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
+               ieee80211_rx_irqsafe(hw, skb);
 
                processed++;
        }
@@ -1591,6 +1594,9 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
        timeout = wait_for_completion_timeout(&cmd_wait,
                                msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS));
 
+       pci_unmap_single(priv->pdev, dma_addr, dma_size,
+                                       PCI_DMA_BIDIRECTIONAL);
+
        result = &cmd->result;
        if (!timeout) {
                spin_lock_irq(&priv->fw_lock);
@@ -1610,8 +1616,6 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
                               *result);
        }
 
-       pci_unmap_single(priv->pdev, dma_addr, dma_size,
-                                       PCI_DMA_BIDIRECTIONAL);
        return rc;
 }
 
@@ -1654,18 +1658,18 @@ static int mwl8k_cmd_get_hw_spec(struct ieee80211_hw *hw)
        memset(cmd->perm_addr, 0xff, sizeof(cmd->perm_addr));
        cmd->ps_cookie = cpu_to_le32(priv->cookie_dma);
        cmd->rx_queue_ptr = cpu_to_le32(priv->rxq[0].rx_desc_dma);
-       cmd->num_tx_queues = MWL8K_TX_QUEUES;
+       cmd->num_tx_queues = cpu_to_le32(MWL8K_TX_QUEUES);
        for (i = 0; i < MWL8K_TX_QUEUES; i++)
                cmd->tx_queue_ptrs[i] = cpu_to_le32(priv->txq[i].tx_desc_dma);
-       cmd->num_tx_desc_per_queue = MWL8K_TX_DESCS;
-       cmd->total_rx_desc = MWL8K_RX_DESCS;
+       cmd->num_tx_desc_per_queue = cpu_to_le32(MWL8K_TX_DESCS);
+       cmd->total_rx_desc = cpu_to_le32(MWL8K_RX_DESCS);
 
        rc = mwl8k_post_cmd(hw, &cmd->header);
 
        if (!rc) {
                SET_IEEE80211_PERM_ADDR(hw, cmd->perm_addr);
                priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs);
-               priv->fw_rev = cmd->fw_rev;
+               priv->fw_rev = le32_to_cpu(cmd->fw_rev);
                priv->hw_rev = cmd->hw_rev;
                priv->region_code = le16_to_cpu(cmd->region_code);
        }
@@ -2270,7 +2274,6 @@ static int mwl8k_cmd_update_sta_db(struct ieee80211_hw *hw,
        struct mwl8k_cmd_update_sta_db *cmd;
        struct peer_capability_info *peer_info;
        struct ieee80211_rate *bitrates = mv_vif->legacy_rates;
-       DECLARE_MAC_BUF(mac);
        int rc;
        __u8 count, *rates;
 
@@ -3028,13 +3031,6 @@ static int mwl8k_config_wt(struct work_struct *wt)
        struct mwl8k_priv *priv = hw->priv;
        int rc = 0;
 
-       if (!conf->radio_enabled) {
-               mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_DISABLE);
-               priv->current_channel = NULL;
-               rc = 0;
-               goto mwl8k_config_exit;
-       }
-
        if (mwl8k_cmd_802_11_radio_control(hw, MWL8K_RADIO_ENABLE)) {
                rc = -EINVAL;
                goto mwl8k_config_exit;
@@ -3216,15 +3212,19 @@ static int mwl8k_configure_filter_wt(struct work_struct *wt)
        struct dev_addr_list *mclist = worker->mclist;
 
        struct mwl8k_priv *priv = hw->priv;
-       struct mwl8k_vif *mv_vif;
        int rc = 0;
 
        if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
                if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
                        rc = mwl8k_cmd_set_pre_scan(hw);
                else {
-                       mv_vif = MWL8K_VIF(priv->vif);
-                       rc = mwl8k_cmd_set_post_scan(hw, mv_vif->bssid);
+                       u8 *bssid;
+
+                       bssid = "\x00\x00\x00\x00\x00\x00";
+                       if (priv->vif != NULL)
+                               bssid = MWL8K_VIF(priv->vif)->bssid;
+
+                       rc = mwl8k_cmd_set_post_scan(hw, bssid);
                }
        }
 
@@ -3244,31 +3244,50 @@ mwl8k_configure_filter_exit:
        return rc;
 }
 
+static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw,
+                                  int mc_count, struct dev_addr_list *mclist)
+{
+       struct mwl8k_configure_filter_worker *worker;
+
+       worker = kzalloc(sizeof(*worker), GFP_ATOMIC);
+
+       if (!worker)
+               return 0;
+
+       /*
+        * XXX: This is _HORRIBLY_ broken!!
+        *
+        *      No locking, the mclist pointer might be invalid as soon as this
+        *      function returns, something in the list might be invalidated
+        *      once we get to the worker, etc...
+        */
+       worker->mc_count = mc_count;
+       worker->mclist = mclist;
+
+       return (u64)worker;
+}
+
 static void mwl8k_configure_filter(struct ieee80211_hw *hw,
                                   unsigned int changed_flags,
                                   unsigned int *total_flags,
-                                  int mc_count,
-                                  struct dev_addr_list *mclist)
+                                  u64 multicast)
 {
 
-       struct mwl8k_configure_filter_worker *worker;
+       struct mwl8k_configure_filter_worker *worker = (void *)multicast;
        struct mwl8k_priv *priv = hw->priv;
 
        /* Clear unsupported feature flags */
        *total_flags &= MWL8K_SUPPORTED_IF_FLAGS;
 
-       if (!(changed_flags & MWL8K_SUPPORTED_IF_FLAGS) && !mc_count)
+       if (!(changed_flags & MWL8K_SUPPORTED_IF_FLAGS))
                return;
 
-       worker = kzalloc(sizeof(*worker), GFP_ATOMIC);
        if (worker == NULL)
                return;
 
        worker->header.options = MWL8K_WQ_QUEUE_ONLY | MWL8K_WQ_TX_WAIT_EMPTY;
        worker->changed_flags = changed_flags;
        worker->total_flags = total_flags;
-       worker->mc_count = mc_count;
-       worker->mclist = mclist;
 
        mwl8k_queue_work(hw, &worker->header, priv->config_wq,
                         mwl8k_configure_filter_wt);
@@ -3434,6 +3453,7 @@ static const struct ieee80211_ops mwl8k_ops = {
        .remove_interface       = mwl8k_remove_interface,
        .config                 = mwl8k_config,
        .bss_info_changed       = mwl8k_bss_info_changed,
+       .prepare_multicast      = mwl8k_prepare_multicast,
        .configure_filter       = mwl8k_configure_filter,
        .set_rts_threshold      = mwl8k_set_rts_threshold,
        .conf_tx                = mwl8k_conf_tx,
@@ -3479,7 +3499,6 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
 {
        struct ieee80211_hw *hw;
        struct mwl8k_priv *priv;
-       DECLARE_MAC_BUF(mac);
        int rc;
        int i;
        u8 *fw;
@@ -3668,8 +3687,8 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
                MWL8K_DESC);
        printk(KERN_INFO "%s: Driver Ver:%s  Firmware Ver:%u.%u.%u.%u\n",
                priv->name, MWL8K_VERSION, fw[3], fw[2], fw[1], fw[0]);
-       printk(KERN_INFO "%s: MAC Address: %s\n", priv->name,
-              print_mac(mac, hw->wiphy->perm_addr));
+       printk(KERN_INFO "%s: MAC Address: %pM\n", priv->name,
+               hw->wiphy->perm_addr);
 
        return 0;
 
@@ -3726,6 +3745,8 @@ static void __devexit mwl8k_remove(struct pci_dev *pdev)
 
        ieee80211_stop_queues(hw);
 
+       ieee80211_unregister_hw(hw);
+
        /* Remove tx reclaim tasklet */
        tasklet_kill(&priv->tx_reclaim_task);
 
@@ -3739,8 +3760,6 @@ static void __devexit mwl8k_remove(struct pci_dev *pdev)
        for (i = 0; i < MWL8K_TX_QUEUES; i++)
                mwl8k_txq_reclaim(hw, i, 1);
 
-       ieee80211_unregister_hw(hw);
-
        for (i = 0; i < MWL8K_TX_QUEUES; i++)
                mwl8k_txq_deinit(hw, i);