aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/at76c50x-usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/at76c50x-usb.c')
-rw-r--r--drivers/net/wireless/at76c50x-usb.c168
1 files changed, 80 insertions, 88 deletions
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
index cd8caeab86ea..d5140a87f073 100644
--- a/drivers/net/wireless/at76c50x-usb.c
+++ b/drivers/net/wireless/at76c50x-usb.c
@@ -89,22 +89,19 @@
89#define DBG_DEFAULTS 0 89#define DBG_DEFAULTS 0
90 90
91/* Use our own dbg macro */ 91/* Use our own dbg macro */
92#define at76_dbg(bits, format, arg...) \ 92#define at76_dbg(bits, format, arg...) \
93 do { \ 93do { \
94 if (at76_debug & (bits)) \ 94 if (at76_debug & (bits)) \
95 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \ 95 printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
96 ## arg); \ 96} while (0)
97 } while (0) 97
98 98#define at76_dbg_dump(bits, buf, len, format, arg...) \
99#define at76_dbg_dump(bits, buf, len, format, arg...) \ 99do { \
100 do { \ 100 if (at76_debug & (bits)) { \
101 if (at76_debug & (bits)) { \ 101 printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
102 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \ 102 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \
103 ## arg); \ 103 } \
104 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, \ 104} while (0)
105 buf, len); \
106 } \
107 } while (0)
108 105
109static uint at76_debug = DBG_DEFAULTS; 106static uint at76_debug = DBG_DEFAULTS;
110 107
@@ -658,8 +655,8 @@ static int at76_get_hw_config(struct at76_priv *priv)
658exit: 655exit:
659 kfree(hwcfg); 656 kfree(hwcfg);
660 if (ret < 0) 657 if (ret < 0)
661 printk(KERN_ERR "%s: cannot get HW Config (error %d)\n", 658 wiphy_err(priv->hw->wiphy, "cannot get hw config (error %d)\n",
662 wiphy_name(priv->hw->wiphy), ret); 659 ret);
663 660
664 return ret; 661 return ret;
665} 662}
@@ -794,8 +791,9 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
794 do { 791 do {
795 status = at76_get_cmd_status(priv->udev, cmd); 792 status = at76_get_cmd_status(priv->udev, cmd);
796 if (status < 0) { 793 if (status < 0) {
797 printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n", 794 wiphy_err(priv->hw->wiphy,
798 wiphy_name(priv->hw->wiphy), status); 795 "at76_get_cmd_status failed: %d\n",
796 status);
799 break; 797 break;
800 } 798 }
801 799
@@ -810,9 +808,8 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
810 808
811 schedule_timeout_interruptible(HZ / 10); /* 100 ms */ 809 schedule_timeout_interruptible(HZ / 10); /* 100 ms */
812 if (time_after(jiffies, timeout)) { 810 if (time_after(jiffies, timeout)) {
813 printk(KERN_ERR 811 wiphy_err(priv->hw->wiphy,
814 "%s: completion timeout for command %d\n", 812 "completion timeout for command %d\n", cmd);
815 wiphy_name(priv->hw->wiphy), cmd);
816 status = -ETIMEDOUT; 813 status = -ETIMEDOUT;
817 break; 814 break;
818 } 815 }
@@ -833,9 +830,9 @@ static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf)
833 830
834 ret = at76_wait_completion(priv, CMD_SET_MIB); 831 ret = at76_wait_completion(priv, CMD_SET_MIB);
835 if (ret != CMD_STATUS_COMPLETE) { 832 if (ret != CMD_STATUS_COMPLETE) {
836 printk(KERN_INFO 833 wiphy_info(priv->hw->wiphy,
837 "%s: set_mib: at76_wait_completion failed " 834 "set_mib: at76_wait_completion failed with %d\n",
838 "with %d\n", wiphy_name(priv->hw->wiphy), ret); 835 ret);
839 ret = -EIO; 836 ret = -EIO;
840 } 837 }
841 838
@@ -855,8 +852,8 @@ static int at76_set_radio(struct at76_priv *priv, int enable)
855 852
856 ret = at76_set_card_command(priv->udev, cmd, NULL, 0); 853 ret = at76_set_card_command(priv->udev, cmd, NULL, 0);
857 if (ret < 0) 854 if (ret < 0)
858 printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n", 855 wiphy_err(priv->hw->wiphy,
859 wiphy_name(priv->hw->wiphy), cmd, ret); 856 "at76_set_card_command(%d) failed: %d\n", cmd, ret);
860 else 857 else
861 ret = 1; 858 ret = 1;
862 859
@@ -876,8 +873,8 @@ static int at76_set_pm_mode(struct at76_priv *priv)
876 873
877 ret = at76_set_mib(priv, &priv->mib_buf); 874 ret = at76_set_mib(priv, &priv->mib_buf);
878 if (ret < 0) 875 if (ret < 0)
879 printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n", 876 wiphy_err(priv->hw->wiphy, "set_mib (pm_mode) failed: %d\n",
880 wiphy_name(priv->hw->wiphy), ret); 877 ret);
881 878
882 return ret; 879 return ret;
883} 880}
@@ -893,8 +890,8 @@ static int at76_set_preamble(struct at76_priv *priv, u8 type)
893 890
894 ret = at76_set_mib(priv, &priv->mib_buf); 891 ret = at76_set_mib(priv, &priv->mib_buf);
895 if (ret < 0) 892 if (ret < 0)
896 printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n", 893 wiphy_err(priv->hw->wiphy, "set_mib (preamble) failed: %d\n",
897 wiphy_name(priv->hw->wiphy), ret); 894 ret);
898 895
899 return ret; 896 return ret;
900} 897}
@@ -910,8 +907,8 @@ static int at76_set_frag(struct at76_priv *priv, u16 size)
910 907
911 ret = at76_set_mib(priv, &priv->mib_buf); 908 ret = at76_set_mib(priv, &priv->mib_buf);
912 if (ret < 0) 909 if (ret < 0)
913 printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n", 910 wiphy_err(priv->hw->wiphy,
914 wiphy_name(priv->hw->wiphy), ret); 911 "set_mib (frag threshold) failed: %d\n", ret);
915 912
916 return ret; 913 return ret;
917} 914}
@@ -927,8 +924,7 @@ static int at76_set_rts(struct at76_priv *priv, u16 size)
927 924
928 ret = at76_set_mib(priv, &priv->mib_buf); 925 ret = at76_set_mib(priv, &priv->mib_buf);
929 if (ret < 0) 926 if (ret < 0)
930 printk(KERN_ERR "%s: set_mib (rts) failed: %d\n", 927 wiphy_err(priv->hw->wiphy, "set_mib (rts) failed: %d\n", ret);
931 wiphy_name(priv->hw->wiphy), ret);
932 928
933 return ret; 929 return ret;
934} 930}
@@ -944,8 +940,8 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff)
944 940
945 ret = at76_set_mib(priv, &priv->mib_buf); 941 ret = at76_set_mib(priv, &priv->mib_buf);
946 if (ret < 0) 942 if (ret < 0)
947 printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n", 943 wiphy_err(priv->hw->wiphy,
948 wiphy_name(priv->hw->wiphy), ret); 944 "set_mib (autorate fallback) failed: %d\n", ret);
949 945
950 return ret; 946 return ret;
951} 947}
@@ -963,8 +959,8 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv)
963 ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, 959 ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m,
964 sizeof(struct mib_mac_addr)); 960 sizeof(struct mib_mac_addr));
965 if (ret < 0) { 961 if (ret < 0) {
966 printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n", 962 wiphy_err(priv->hw->wiphy,
967 wiphy_name(priv->hw->wiphy), ret); 963 "at76_get_mib (mac_addr) failed: %d\n", ret);
968 goto exit; 964 goto exit;
969 } 965 }
970 966
@@ -992,8 +988,8 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
992 ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, 988 ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m,
993 sizeof(struct mib_mac_wep)); 989 sizeof(struct mib_mac_wep));
994 if (ret < 0) { 990 if (ret < 0) {
995 printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n", 991 wiphy_err(priv->hw->wiphy,
996 wiphy_name(priv->hw->wiphy), ret); 992 "at76_get_mib (mac_wep) failed: %d\n", ret);
997 goto exit; 993 goto exit;
998 } 994 }
999 995
@@ -1029,8 +1025,8 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1029 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, 1025 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m,
1030 sizeof(struct mib_mac_mgmt)); 1026 sizeof(struct mib_mac_mgmt));
1031 if (ret < 0) { 1027 if (ret < 0) {
1032 printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n", 1028 wiphy_err(priv->hw->wiphy,
1033 wiphy_name(priv->hw->wiphy), ret); 1029 "at76_get_mib (mac_mgmt) failed: %d\n", ret);
1034 goto exit; 1030 goto exit;
1035 } 1031 }
1036 1032
@@ -1065,8 +1061,8 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
1065 1061
1066 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); 1062 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac));
1067 if (ret < 0) { 1063 if (ret < 0) {
1068 printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n", 1064 wiphy_err(priv->hw->wiphy,
1069 wiphy_name(priv->hw->wiphy), ret); 1065 "at76_get_mib (mac) failed: %d\n", ret);
1070 goto exit; 1066 goto exit;
1071 } 1067 }
1072 1068
@@ -1102,8 +1098,8 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
1102 1098
1103 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); 1099 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy));
1104 if (ret < 0) { 1100 if (ret < 0) {
1105 printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n", 1101 wiphy_err(priv->hw->wiphy,
1106 wiphy_name(priv->hw->wiphy), ret); 1102 "at76_get_mib (phy) failed: %d\n", ret);
1107 goto exit; 1103 goto exit;
1108 } 1104 }
1109 1105
@@ -1135,8 +1131,8 @@ static void at76_dump_mib_local(struct at76_priv *priv)
1135 1131
1136 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local)); 1132 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local));
1137 if (ret < 0) { 1133 if (ret < 0) {
1138 printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n", 1134 wiphy_err(priv->hw->wiphy,
1139 wiphy_name(priv->hw->wiphy), ret); 1135 "at76_get_mib (local) failed: %d\n", ret);
1140 goto exit; 1136 goto exit;
1141 } 1137 }
1142 1138
@@ -1161,8 +1157,8 @@ static void at76_dump_mib_mdomain(struct at76_priv *priv)
1161 ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, 1157 ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m,
1162 sizeof(struct mib_mdomain)); 1158 sizeof(struct mib_mdomain));
1163 if (ret < 0) { 1159 if (ret < 0) {
1164 printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n", 1160 wiphy_err(priv->hw->wiphy,
1165 wiphy_name(priv->hw->wiphy), ret); 1161 "at76_get_mib (mdomain) failed: %d\n", ret);
1166 goto exit; 1162 goto exit;
1167 } 1163 }
1168 1164
@@ -1233,16 +1229,16 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1233 struct sk_buff *skb = priv->rx_skb; 1229 struct sk_buff *skb = priv->rx_skb;
1234 1230
1235 if (!priv->rx_urb) { 1231 if (!priv->rx_urb) {
1236 printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n", 1232 wiphy_err(priv->hw->wiphy, "%s: priv->rx_urb is null\n",
1237 wiphy_name(priv->hw->wiphy), __func__); 1233 __func__);
1238 return -EFAULT; 1234 return -EFAULT;
1239 } 1235 }
1240 1236
1241 if (!skb) { 1237 if (!skb) {
1242 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer)); 1238 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
1243 if (!skb) { 1239 if (!skb) {
1244 printk(KERN_ERR "%s: cannot allocate rx skbuff\n", 1240 wiphy_err(priv->hw->wiphy,
1245 wiphy_name(priv->hw->wiphy)); 1241 "cannot allocate rx skbuff\n");
1246 ret = -ENOMEM; 1242 ret = -ENOMEM;
1247 goto exit; 1243 goto exit;
1248 } 1244 }
@@ -1261,15 +1257,14 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1261 at76_dbg(DBG_DEVSTART, 1257 at76_dbg(DBG_DEVSTART,
1262 "usb_submit_urb returned -ENODEV"); 1258 "usb_submit_urb returned -ENODEV");
1263 else 1259 else
1264 printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n", 1260 wiphy_err(priv->hw->wiphy,
1265 wiphy_name(priv->hw->wiphy), ret); 1261 "rx, usb_submit_urb failed: %d\n", ret);
1266 } 1262 }
1267 1263
1268exit: 1264exit:
1269 if (ret < 0 && ret != -ENODEV) 1265 if (ret < 0 && ret != -ENODEV)
1270 printk(KERN_ERR "%s: cannot submit rx urb - please unload the " 1266 wiphy_err(priv->hw->wiphy,
1271 "driver and/or power cycle the device\n", 1267 "cannot submit rx urb - please unload the driver and/or power cycle the device\n");
1272 wiphy_name(priv->hw->wiphy));
1273 1268
1274 return ret; 1269 return ret;
1275} 1270}
@@ -1438,8 +1433,8 @@ static int at76_startup_device(struct at76_priv *priv)
1438 ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config, 1433 ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config,
1439 sizeof(struct at76_card_config)); 1434 sizeof(struct at76_card_config));
1440 if (ret < 0) { 1435 if (ret < 0) {
1441 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 1436 wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n",
1442 wiphy_name(priv->hw->wiphy), ret); 1437 ret);
1443 return ret; 1438 return ret;
1444 } 1439 }
1445 1440
@@ -1504,8 +1499,8 @@ static void at76_work_set_promisc(struct work_struct *work)
1504 1499
1505 ret = at76_set_mib(priv, &priv->mib_buf); 1500 ret = at76_set_mib(priv, &priv->mib_buf);
1506 if (ret < 0) 1501 if (ret < 0)
1507 printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n", 1502 wiphy_err(priv->hw->wiphy,
1508 wiphy_name(priv->hw->wiphy), ret); 1503 "set_mib (promiscuous_mode) failed: %d\n", ret);
1509 1504
1510 mutex_unlock(&priv->mtx); 1505 mutex_unlock(&priv->mtx);
1511} 1506}
@@ -1668,16 +1663,16 @@ static int at76_join(struct at76_priv *priv)
1668 sizeof(struct at76_req_join)); 1663 sizeof(struct at76_req_join));
1669 1664
1670 if (ret < 0) { 1665 if (ret < 0) {
1671 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 1666 wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n",
1672 wiphy_name(priv->hw->wiphy), ret); 1667 ret);
1673 return 0; 1668 return 0;
1674 } 1669 }
1675 1670
1676 ret = at76_wait_completion(priv, CMD_JOIN); 1671 ret = at76_wait_completion(priv, CMD_JOIN);
1677 at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret); 1672 at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret);
1678 if (ret != CMD_STATUS_COMPLETE) { 1673 if (ret != CMD_STATUS_COMPLETE) {
1679 printk(KERN_ERR "%s: at76_wait_completion failed: %d\n", 1674 wiphy_err(priv->hw->wiphy, "at76_wait_completion failed: %d\n",
1680 wiphy_name(priv->hw->wiphy), ret); 1675 ret);
1681 return 0; 1676 return 0;
1682 } 1677 }
1683 1678
@@ -1745,8 +1740,8 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1745 at76_dbg(DBG_MAC80211, "%s()", __func__); 1740 at76_dbg(DBG_MAC80211, "%s()", __func__);
1746 1741
1747 if (priv->tx_urb->status == -EINPROGRESS) { 1742 if (priv->tx_urb->status == -EINPROGRESS) {
1748 printk(KERN_ERR "%s: %s called while tx urb is pending\n", 1743 wiphy_err(priv->hw->wiphy,
1749 wiphy_name(priv->hw->wiphy), __func__); 1744 "%s called while tx urb is pending\n", __func__);
1750 return NETDEV_TX_BUSY; 1745 return NETDEV_TX_BUSY;
1751 } 1746 }
1752 1747
@@ -1794,13 +1789,12 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1794 submit_len, at76_mac80211_tx_callback, priv); 1789 submit_len, at76_mac80211_tx_callback, priv);
1795 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC); 1790 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1796 if (ret) { 1791 if (ret) {
1797 printk(KERN_ERR "%s: error in tx submit urb: %d\n", 1792 wiphy_err(priv->hw->wiphy, "error in tx submit urb: %d\n", ret);
1798 wiphy_name(priv->hw->wiphy), ret);
1799 if (ret == -EINVAL) 1793 if (ret == -EINVAL)
1800 printk(KERN_ERR 1794 wiphy_err(priv->hw->wiphy,
1801 "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n", 1795 "-einval: tx urb %p hcpriv %p complete %p\n",
1802 wiphy_name(priv->hw->wiphy), priv->tx_urb, 1796 priv->tx_urb,
1803 priv->tx_urb->hcpriv, priv->tx_urb->complete); 1797 priv->tx_urb->hcpriv, priv->tx_urb->complete);
1804 } 1798 }
1805 1799
1806 return 0; 1800 return 0;
@@ -1817,8 +1811,8 @@ static int at76_mac80211_start(struct ieee80211_hw *hw)
1817 1811
1818 ret = at76_submit_rx_urb(priv); 1812 ret = at76_submit_rx_urb(priv);
1819 if (ret < 0) { 1813 if (ret < 0) {
1820 printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n", 1814 wiphy_err(priv->hw->wiphy, "open: submit_rx_urb failed: %d\n",
1821 wiphy_name(priv->hw->wiphy), ret); 1815 ret);
1822 goto error; 1816 goto error;
1823 } 1817 }
1824 1818
@@ -2316,14 +2310,12 @@ static int at76_init_new_device(struct at76_priv *priv,
2316 2310
2317 priv->mac80211_registered = 1; 2311 priv->mac80211_registered = 1;
2318 2312
2319 printk(KERN_INFO "%s: USB %s, MAC %pM, firmware %d.%d.%d-%d\n", 2313 wiphy_info(priv->hw->wiphy, "usb %s, mac %pm, firmware %d.%d.%d-%d\n",
2320 wiphy_name(priv->hw->wiphy), 2314 dev_name(&interface->dev), priv->mac_addr,
2321 dev_name(&interface->dev), priv->mac_addr, 2315 priv->fw_version.major, priv->fw_version.minor,
2322 priv->fw_version.major, priv->fw_version.minor, 2316 priv->fw_version.patch, priv->fw_version.build);
2323 priv->fw_version.patch, priv->fw_version.build); 2317 wiphy_info(priv->hw->wiphy, "regulatory domain 0x%02x: %s\n",
2324 printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", 2318 priv->regulatory_domain, priv->domain->name);
2325 wiphy_name(priv->hw->wiphy),
2326 priv->regulatory_domain, priv->domain->name);
2327 2319
2328exit: 2320exit:
2329 return ret; 2321 return ret;
@@ -2485,7 +2477,7 @@ static void at76_disconnect(struct usb_interface *interface)
2485 if (!priv) 2477 if (!priv)
2486 return; 2478 return;
2487 2479
2488 printk(KERN_INFO "%s: disconnecting\n", wiphy_name(priv->hw->wiphy)); 2480 wiphy_info(priv->hw->wiphy, "disconnecting\n");
2489 at76_delete_device(priv); 2481 at76_delete_device(priv);
2490 dev_printk(KERN_INFO, &interface->dev, "disconnected\n"); 2482 dev_printk(KERN_INFO, &interface->dev, "disconnected\n");
2491} 2483}