wl1271: Optimize scan duration
[pandora-kernel.git] / drivers / net / wireless / at76c50x-usb.c
index cd8caea..91c5f73 100644 (file)
 #define DBG_DEFAULTS           0
 
 /* Use our own dbg macro */
-#define at76_dbg(bits, format, arg...) \
-       do { \
-               if (at76_debug & (bits))                                 \
-                       printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \
-                              ## arg);                                  \
-       } while (0)
-
-#define at76_dbg_dump(bits, buf, len, format, arg...)  \
-       do { \
-               if (at76_debug & (bits)) { \
-                       printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \
-                              ## arg);                                  \
-                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,     \
-                                            buf, len);                  \
-               }                                                        \
-       } while (0)
+#define at76_dbg(bits, format, arg...)                                 \
+do {                                                                   \
+       if (at76_debug & (bits))                                        \
+               printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
+} while (0)
+
+#define at76_dbg_dump(bits, buf, len, format, arg...)                  \
+do {                                                                   \
+       if (at76_debug & (bits)) {                                      \
+               printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
+               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \
+       }                                                               \
+} while (0)
 
 static uint at76_debug = DBG_DEFAULTS;
 
@@ -658,8 +655,8 @@ static int at76_get_hw_config(struct at76_priv *priv)
 exit:
        kfree(hwcfg);
        if (ret < 0)
-               printk(KERN_ERR "%s: cannot get HW Config (error %d)\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "cannot get HW Config (error %d)\n",
+                         ret);
 
        return ret;
 }
@@ -794,8 +791,9 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
        do {
                status = at76_get_cmd_status(priv->udev, cmd);
                if (status < 0) {
-                       printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n",
-                              wiphy_name(priv->hw->wiphy), status);
+                       wiphy_err(priv->hw->wiphy,
+                                 "at76_get_cmd_status failed: %d\n",
+                                 status);
                        break;
                }
 
@@ -810,9 +808,8 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
 
                schedule_timeout_interruptible(HZ / 10);        /* 100 ms */
                if (time_after(jiffies, timeout)) {
-                       printk(KERN_ERR
-                              "%s: completion timeout for command %d\n",
-                              wiphy_name(priv->hw->wiphy), cmd);
+                       wiphy_err(priv->hw->wiphy,
+                                 "completion timeout for command %d\n", cmd);
                        status = -ETIMEDOUT;
                        break;
                }
@@ -833,9 +830,9 @@ static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf)
 
        ret = at76_wait_completion(priv, CMD_SET_MIB);
        if (ret != CMD_STATUS_COMPLETE) {
-               printk(KERN_INFO
-                      "%s: set_mib: at76_wait_completion failed "
-                      "with %d\n", wiphy_name(priv->hw->wiphy), ret);
+               wiphy_info(priv->hw->wiphy,
+                          "set_mib: at76_wait_completion failed with %d\n",
+                          ret);
                ret = -EIO;
        }
 
@@ -855,8 +852,8 @@ static int at76_set_radio(struct at76_priv *priv, int enable)
 
        ret = at76_set_card_command(priv->udev, cmd, NULL, 0);
        if (ret < 0)
-               printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), cmd, ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_set_card_command(%d) failed: %d\n", cmd, ret);
        else
                ret = 1;
 
@@ -876,8 +873,8 @@ static int at76_set_pm_mode(struct at76_priv *priv)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "set_mib (pm_mode) failed: %d\n",
+                         ret);
 
        return ret;
 }
@@ -893,8 +890,8 @@ static int at76_set_preamble(struct at76_priv *priv, u8 type)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "set_mib (preamble) failed: %d\n",
+                         ret);
 
        return ret;
 }
@@ -910,8 +907,8 @@ static int at76_set_frag(struct at76_priv *priv, u16 size)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "set_mib (frag threshold) failed: %d\n", ret);
 
        return ret;
 }
@@ -927,8 +924,7 @@ static int at76_set_rts(struct at76_priv *priv, u16 size)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (rts) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "set_mib (rts) failed: %d\n", ret);
 
        return ret;
 }
@@ -944,8 +940,8 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "set_mib (autorate fallback) failed: %d\n", ret);
 
        return ret;
 }
@@ -963,8 +959,8 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv)
        ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m,
                           sizeof(struct mib_mac_addr));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (MAC_ADDR) failed: %d\n", ret);
                goto exit;
        }
 
@@ -992,8 +988,8 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
        ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m,
                           sizeof(struct mib_mac_wep));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (MAC_WEP) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1029,8 +1025,8 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
        ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m,
                           sizeof(struct mib_mac_mgmt));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (MAC_MGMT) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1065,8 +1061,8 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
 
        ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (MAC) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1102,8 +1098,8 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
 
        ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (PHY) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1135,8 +1131,8 @@ static void at76_dump_mib_local(struct at76_priv *priv)
 
        ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (LOCAL) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1161,8 +1157,8 @@ static void at76_dump_mib_mdomain(struct at76_priv *priv)
        ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m,
                           sizeof(struct mib_mdomain));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "at76_get_mib (MDOMAIN) failed: %d\n", ret);
                goto exit;
        }
 
@@ -1233,16 +1229,16 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
        struct sk_buff *skb = priv->rx_skb;
 
        if (!priv->rx_urb) {
-               printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n",
-                      wiphy_name(priv->hw->wiphy), __func__);
+               wiphy_err(priv->hw->wiphy, "%s: priv->rx_urb is NULL\n",
+                         __func__);
                return -EFAULT;
        }
 
        if (!skb) {
                skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
                if (!skb) {
-                       printk(KERN_ERR "%s: cannot allocate rx skbuff\n",
-                              wiphy_name(priv->hw->wiphy));
+                       wiphy_err(priv->hw->wiphy,
+                                 "cannot allocate rx skbuff\n");
                        ret = -ENOMEM;
                        goto exit;
                }
@@ -1261,15 +1257,14 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
                        at76_dbg(DBG_DEVSTART,
                                 "usb_submit_urb returned -ENODEV");
                else
-                       printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n",
-                              wiphy_name(priv->hw->wiphy), ret);
+                       wiphy_err(priv->hw->wiphy,
+                                 "rx, usb_submit_urb failed: %d\n", ret);
        }
 
 exit:
        if (ret < 0 && ret != -ENODEV)
-               printk(KERN_ERR "%s: cannot submit rx urb - please unload the "
-                      "driver and/or power cycle the device\n",
-                      wiphy_name(priv->hw->wiphy));
+               wiphy_err(priv->hw->wiphy,
+                         "cannot submit rx urb - please unload the driver and/or power cycle the device\n");
 
        return ret;
 }
@@ -1438,8 +1433,8 @@ static int at76_startup_device(struct at76_priv *priv)
        ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config,
                                    sizeof(struct at76_card_config));
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_set_card_command failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n",
+                         ret);
                return ret;
        }
 
@@ -1504,8 +1499,8 @@ static void at76_work_set_promisc(struct work_struct *work)
 
        ret = at76_set_mib(priv, &priv->mib_buf);
        if (ret < 0)
-               printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy,
+                         "set_mib (promiscuous_mode) failed: %d\n", ret);
 
        mutex_unlock(&priv->mtx);
 }
@@ -1668,16 +1663,16 @@ static int at76_join(struct at76_priv *priv)
                                    sizeof(struct at76_req_join));
 
        if (ret < 0) {
-               printk(KERN_ERR "%s: at76_set_card_command failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n",
+                         ret);
                return 0;
        }
 
        ret = at76_wait_completion(priv, CMD_JOIN);
        at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret);
        if (ret != CMD_STATUS_COMPLETE) {
-               printk(KERN_ERR "%s: at76_wait_completion failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "at76_wait_completion failed: %d\n",
+                         ret);
                return 0;
        }
 
@@ -1745,8 +1740,8 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
        at76_dbg(DBG_MAC80211, "%s()", __func__);
 
        if (priv->tx_urb->status == -EINPROGRESS) {
-               printk(KERN_ERR "%s: %s called while tx urb is pending\n",
-                      wiphy_name(priv->hw->wiphy), __func__);
+               wiphy_err(priv->hw->wiphy,
+                         "%s called while tx urb is pending\n", __func__);
                return NETDEV_TX_BUSY;
        }
 
@@ -1794,13 +1789,12 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                          submit_len, at76_mac80211_tx_callback, priv);
        ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
        if (ret) {
-               printk(KERN_ERR "%s: error in tx submit urb: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "error in tx submit urb: %d\n", ret);
                if (ret == -EINVAL)
-                       printk(KERN_ERR
-                              "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
-                              wiphy_name(priv->hw->wiphy), priv->tx_urb,
-                              priv->tx_urb->hcpriv, priv->tx_urb->complete);
+                       wiphy_err(priv->hw->wiphy,
+                                 "-EINVAL: tx urb %p hcpriv %p complete %p\n",
+                                 priv->tx_urb,
+                                 priv->tx_urb->hcpriv, priv->tx_urb->complete);
        }
 
        return 0;
@@ -1817,8 +1811,8 @@ static int at76_mac80211_start(struct ieee80211_hw *hw)
 
        ret = at76_submit_rx_urb(priv);
        if (ret < 0) {
-               printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n",
-                      wiphy_name(priv->hw->wiphy), ret);
+               wiphy_err(priv->hw->wiphy, "open: submit_rx_urb failed: %d\n",
+                         ret);
                goto error;
        }
 
@@ -2067,11 +2061,12 @@ static int at76_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
        int i;
 
-       at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
+       at76_dbg(DBG_MAC80211, "%s(): cmd %d key->cipher %d key->keyidx %d "
                 "key->keylen %d",
-                __func__, cmd, key->alg, key->keyidx, key->keylen);
+                __func__, cmd, key->cipher, key->keyidx, key->keylen);
 
-       if (key->alg != ALG_WEP)
+       if ((key->cipher != WLAN_CIPHER_SUITE_WEP40) &&
+           (key->cipher != WLAN_CIPHER_SUITE_WEP104))
                return -EOPNOTSUPP;
 
        key->hw_key_idx = key->keyidx;
@@ -2316,14 +2311,12 @@ static int at76_init_new_device(struct at76_priv *priv,
 
        priv->mac80211_registered = 1;
 
-       printk(KERN_INFO "%s: USB %s, MAC %pM, firmware %d.%d.%d-%d\n",
-              wiphy_name(priv->hw->wiphy),
-              dev_name(&interface->dev), priv->mac_addr,
-              priv->fw_version.major, priv->fw_version.minor,
-              priv->fw_version.patch, priv->fw_version.build);
-       printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n",
-              wiphy_name(priv->hw->wiphy),
-              priv->regulatory_domain, priv->domain->name);
+       wiphy_info(priv->hw->wiphy, "USB %s, MAC %pM, firmware %d.%d.%d-%d\n",
+                  dev_name(&interface->dev), priv->mac_addr,
+                  priv->fw_version.major, priv->fw_version.minor,
+                  priv->fw_version.patch, priv->fw_version.build);
+       wiphy_info(priv->hw->wiphy, "regulatory domain 0x%02x: %s\n",
+                  priv->regulatory_domain, priv->domain->name);
 
 exit:
        return ret;
@@ -2485,7 +2478,7 @@ static void at76_disconnect(struct usb_interface *interface)
        if (!priv)
                return;
 
-       printk(KERN_INFO "%s: disconnecting\n", wiphy_name(priv->hw->wiphy));
+       wiphy_info(priv->hw->wiphy, "disconnecting\n");
        at76_delete_device(priv);
        dev_printk(KERN_INFO, &interface->dev, "disconnected\n");
 }