29 #include <linux/kernel.h>
30 #include <linux/sched.h>
31 #include <linux/errno.h>
32 #include <linux/slab.h>
33 #include <linux/module.h>
35 #include <linux/list.h>
37 #include <linux/netdevice.h>
38 #include <linux/if_arp.h>
40 #include <linux/ethtool.h>
41 #include <linux/wireless.h>
51 #define DRIVER_NAME "at76c50x-usb"
52 #define DRIVER_VERSION "0.17"
53 #define DRIVER_DESC "Atmel at76x USB Wireless LAN Driver"
56 #define DBG_PROGRESS 0x00000001
57 #define DBG_BSS_TABLE 0x00000002
58 #define DBG_IOCTL 0x00000004
59 #define DBG_MAC_STATE 0x00000008
60 #define DBG_TX_DATA 0x00000010
61 #define DBG_TX_DATA_CONTENT 0x00000020
62 #define DBG_TX_MGMT 0x00000040
63 #define DBG_RX_DATA 0x00000080
64 #define DBG_RX_DATA_CONTENT 0x00000100
65 #define DBG_RX_MGMT 0x00000200
66 #define DBG_RX_BEACON 0x00000400
67 #define DBG_RX_CTRL 0x00000800
68 #define DBG_RX_MGMT_CONTENT 0x00001000
69 #define DBG_RX_FRAGS 0x00002000
70 #define DBG_DEVSTART 0x00004000
71 #define DBG_URB 0x00008000
72 #define DBG_RX_ATMEL_HDR 0x00010000
73 #define DBG_PROC_ENTRY 0x00020000
74 #define DBG_PM 0x00040000
75 #define DBG_BSS_MATCH 0x00080000
76 #define DBG_PARAMS 0x00100000
77 #define DBG_WAIT_COMPLETE 0x00200000
78 #define DBG_RX_FRAGS_SKB 0x00400000
79 #define DBG_BSS_TABLE_RM 0x00800000
80 #define DBG_MONITOR_MODE 0x01000000
81 #define DBG_MIB 0x02000000
82 #define DBG_MGMT_TIMER 0x04000000
83 #define DBG_WE_EVENTS 0x08000000
84 #define DBG_FW 0x10000000
85 #define DBG_DFU 0x20000000
86 #define DBG_CMD 0x40000000
87 #define DBG_MAC80211 0x80000000
89 #define DBG_DEFAULTS 0
92 #define at76_dbg(bits, format, arg...) \
94 if (at76_debug & (bits)) \
95 printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
98 #define at76_dbg_dump(bits, buf, len, format, arg...) \
100 if (at76_debug & (bits)) { \
101 printk(KERN_DEBUG DRIVER_NAME ": " format "\n", ##arg); \
102 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \
109 static struct mutex fw_mutex;
111 static struct fwentry firmwares[] = {
115 [
BOARD_503] = {
"atmel_at76c503-rfmd.bin" },
117 [
BOARD_505] = {
"atmel_at76c505-rfmd.bin" },
119 [
BOARD_505A] = {
"atmel_at76c505a-rfmd2958.bin" },
131 #define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
272 static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 };
274 static const char *
const preambles[] = {
"long",
"short",
"auto" };
278 #define STATE_IDLE 0x00
279 #define STATE_DETACH 0x01
280 #define STATE_DFU_IDLE 0x02
281 #define STATE_DFU_DOWNLOAD_SYNC 0x03
282 #define STATE_DFU_DOWNLOAD_BUSY 0x04
283 #define STATE_DFU_DOWNLOAD_IDLE 0x05
284 #define STATE_DFU_MANIFEST_SYNC 0x06
285 #define STATE_DFU_MANIFEST 0x07
286 #define STATE_DFU_MANIFEST_WAIT_RESET 0x08
287 #define STATE_DFU_UPLOAD_IDLE 0x09
288 #define STATE_DFU_ERROR 0x0a
294 #define DFU_GETSTATUS 3
295 #define DFU_CLRSTATUS 4
296 #define DFU_GETSTATE 5
299 #define FW_BLOCK_SIZE 1024
318 static inline int at76_is_505a(
enum board_type board)
324 static int at76_load_int_fw_block(
struct usb_device *
udev,
int blockno,
330 USB_CTRL_GET_TIMEOUT);
333 static int at76_dfu_get_status(
struct usb_device *udev,
341 USB_CTRL_GET_TIMEOUT);
345 static int at76_dfu_get_state(
struct usb_device *udev,
u8 *
state)
351 0, 0, state, 1, USB_CTRL_GET_TIMEOUT);
356 static inline unsigned long at76_get_timeout(
struct dfu_status *
s)
365 static int at76_usbdfu_download(
struct usb_device *udev,
u8 *
buf,
u32 size,
366 int manifest_sync_timeout)
371 int need_dfu_state = 1;
379 manifest_sync_timeout);
382 dev_printk(
KERN_ERR, &udev->dev,
"FW buffer length invalid!\n");
391 if (need_dfu_state) {
392 ret = at76_dfu_get_state(udev, &dfu_state);
395 "cannot get DFU state: %d\n", ret);
404 ret = at76_dfu_get_status(udev, &dfu_stat_buf);
406 dfu_state = dfu_stat_buf.state;
407 dfu_timeout = at76_get_timeout(&dfu_stat_buf);
411 "at76_dfu_get_status returned %d\n",
430 memcpy(block, buf, bsize);
432 "bsize = %4d, blockno = %2d", size, bsize,
435 at76_load_int_fw_block(udev, blockno, block, bsize);
442 "at76_load_int_fw_block "
443 "returned %d\n", ret);
450 ret = at76_dfu_get_status(udev, &dfu_stat_buf);
454 dfu_state = dfu_stat_buf.state;
455 dfu_timeout = at76_get_timeout(&dfu_stat_buf);
460 if (manifest_sync_timeout > 0)
461 dfu_timeout = manifest_sync_timeout;
491 }
while (!is_done && (ret >= 0));
502 static int tx_activity;
503 static void at76_ledtrig_tx_timerfunc(
unsigned long data);
504 static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0);
507 static void at76_ledtrig_tx_timerfunc(
unsigned long data)
509 static int tx_lastactivity;
511 if (tx_lastactivity != tx_activity) {
512 tx_lastactivity = tx_activity;
519 static void at76_ledtrig_tx_activity(
void)
522 if (!timer_pending(&ledtrig_tx_timer))
526 static int at76_remap(
struct usb_device *udev)
532 USB_CTRL_GET_TIMEOUT);
538 static int at76_get_op_mode(
struct usb_device *udev)
550 USB_CTRL_GET_TIMEOUT);
563 static inline int at76_load_ext_fw_block(
struct usb_device *udev,
int blockno,
564 void *block,
int size)
568 0x0802, blockno, block, size,
569 USB_CTRL_GET_TIMEOUT);
572 static inline int at76_get_hw_cfg(
struct usb_device *udev,
578 buf, buf_size, USB_CTRL_GET_TIMEOUT);
582 static inline int at76_get_hw_cfg_intersil(
struct usb_device *udev,
588 buf, buf_size, USB_CTRL_GET_TIMEOUT);
603 ret = at76_get_hw_cfg_intersil(priv->
udev, hwcfg,
609 }
else if (at76_is_503rfmd(priv->
board_type)) {
610 ret = at76_get_hw_cfg(priv->
udev, hwcfg,
sizeof(hwcfg->
r3));
616 ret = at76_get_hw_cfg(priv->
udev, hwcfg,
sizeof(hwcfg->
r5));
626 wiphy_err(priv->
hw->wiphy,
"cannot get HW Config (error %d)\n",
636 { 0x10,
"FCC (USA)", 0x7ff },
637 { 0x20,
"IC (Canada)", 0x7ff },
638 { 0x30,
"ETSI (most of Europe)", 0x1fff },
639 { 0x31,
"Spain", 0x600 },
640 { 0x32,
"France", 0x1e00 },
641 { 0x40,
"MKK (Japan)", 0x2000 },
642 { 0x41,
"MKK1 (Japan)", 0x3fff },
643 { 0x50,
"Israel", 0x3fc },
644 { 0x00,
"<unknown>", 0xffffffff }
649 if (code == fd_tab[i].code)
655 static inline int at76_get_mib(
struct usb_device *udev,
u16 mib,
void *buf,
663 USB_CTRL_GET_TIMEOUT);
664 if (ret >= 0 && ret != buf_size)
670 static inline int at76_get_cmd_status(
struct usb_device *udev,
u8 cmd)
682 40, USB_CTRL_GET_TIMEOUT);
690 #define MAKE_CMD_CASE(c) case (c): return #c
693 switch (cmd_status) {
707 static int at76_set_card_command(
struct usb_device *udev,
u8 cmd,
void *buf,
723 "issuing command %s (0x%02x)",
724 at76_get_cmd_string(cmd), cmd);
730 USB_CTRL_GET_TIMEOUT);
735 #define MAKE_CMD_STATUS_CASE(c) case (c): return #c
736 static const char *at76_get_cmd_status_string(
u8 cmd_status)
738 switch (cmd_status) {
754 static int at76_wait_completion(
struct at76_priv *priv,
int cmd)
760 status = at76_get_cmd_status(priv->
udev, cmd);
763 "at76_get_cmd_status failed: %d\n",
769 "%s: Waiting on cmd %d, status = %d (%s)",
770 wiphy_name(priv->
hw->wiphy), cmd, status,
771 at76_get_cmd_status_string(status));
780 "completion timeout for command %d\n", cmd);
802 "set_mib: at76_wait_completion failed with %d\n",
821 ret = at76_set_card_command(priv->
udev, cmd,
NULL, 0);
824 "at76_set_card_command(%d) failed: %d\n", cmd, ret);
833 static int at76_set_pm_mode(
struct at76_priv *priv)
842 ret = at76_set_mib(priv, &priv->
mib_buf);
844 wiphy_err(priv->
hw->wiphy,
"set_mib (pm_mode) failed: %d\n",
859 ret = at76_set_mib(priv, &priv->
mib_buf);
861 wiphy_err(priv->
hw->wiphy,
"set_mib (preamble) failed: %d\n",
867 static int at76_set_frag(
struct at76_priv *priv,
u16 size)
876 ret = at76_set_mib(priv, &priv->
mib_buf);
879 "set_mib (frag threshold) failed: %d\n", ret);
884 static int at76_set_rts(
struct at76_priv *priv,
u16 size)
893 ret = at76_set_mib(priv, &priv->
mib_buf);
895 wiphy_err(priv->
hw->wiphy,
"set_mib (rts) failed: %d\n", ret);
900 static int at76_set_autorate_fallback(
struct at76_priv *priv,
int onoff)
909 ret = at76_set_mib(priv, &priv->
mib_buf);
912 "set_mib (autorate fallback) failed: %d\n", ret);
917 static void at76_dump_mib_mac_addr(
struct at76_priv *priv)
931 "at76_get_mib (MAC_ADDR) failed: %d\n", ret);
936 wiphy_name(priv->
hw->wiphy),
940 "status %d", wiphy_name(priv->
hw->wiphy),
i,
946 static void at76_dump_mib_mac_wep(
struct at76_priv *priv)
960 "at76_get_mib (MAC_WEP) failed: %d\n", ret);
965 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u "
966 "encr_level %u key %d", wiphy_name(priv->
hw->wiphy),
978 wiphy_name(priv->
hw->wiphy),
i,
984 static void at76_dump_mib_mac_mgmt(
struct at76_priv *priv)
997 "at76_get_mib (MAC_MGMT) failed: %d\n", ret);
1001 at76_dbg(
DBG_MIB,
"%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration "
1002 "%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d "
1003 "CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d "
1004 "current_bssid %pM current_essid %*phD current_bss_type %d "
1005 "pm_mode %d ibss_change %d res %d "
1006 "multi_domain_capability_implemented %d "
1007 "international_roaming %d country_string %.3s",
1022 static void at76_dump_mib_mac(
struct at76_priv *priv)
1033 "at76_get_mib (MAC) failed: %d\n", ret);
1038 "max_rx_lifetime %d frag_threshold %d rts_threshold %d "
1039 "cwmin %d cwmax %d short_retry_time %d long_retry_time %d "
1040 "scan_type %d scan_channel %d probe_delay %u "
1041 "min_channel_time %d max_channel_time %d listen_int %d "
1042 "desired_ssid %*phD desired_bssid %pM desired_bsstype %d",
1043 wiphy_name(priv->
hw->wiphy),
1059 static void at76_dump_mib_phy(
struct at76_priv *priv)
1070 "at76_get_mib (PHY) failed: %d\n", ret);
1075 "sifs_time %d preamble_length %d plcp_header_length %d "
1076 "mpdu_max_length %d cca_mode_supported %d operation_rate_set "
1077 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d "
1078 "phy_type %d current_reg_domain %d",
1092 static void at76_dump_mib_local(
struct at76_priv *priv)
1103 "at76_get_mib (LOCAL) failed: %d\n", ret);
1108 "txautorate_fallback %d ssid_size %d promiscuous_mode %d "
1109 "preamble_type %d", wiphy_name(priv->
hw->wiphy),
1117 static void at76_dump_mib_mdomain(
struct at76_priv *priv)
1129 "at76_get_mib (MDOMAIN) failed: %d\n", ret);
1134 wiphy_name(priv->
hw->wiphy),
1138 wiphy_name(priv->
hw->wiphy),
1145 static int at76_start_monitor(
struct at76_priv *priv)
1155 scan.international_scan = 0;
1169 static inline int at76_calc_padding(
int wlen)
1180 return 64 + 50 - wlen;
1185 static void at76_rx_callback(
struct urb *
urb)
1193 static int at76_submit_rx_urb(
struct at76_priv *priv)
1200 wiphy_err(priv->
hw->wiphy,
"%s: priv->rx_urb is NULL\n",
1209 "cannot allocate rx skbuff\n");
1219 size = skb_tailroom(skb);
1221 skb_put(skb, size), size, at76_rx_callback, priv);
1226 "usb_submit_urb returned -ENODEV");
1229 "rx, usb_submit_urb failed: %d\n", ret);
1233 if (ret < 0 && ret != -
ENODEV)
1235 "cannot submit rx urb - please unload the driver and/or power cycle the device\n");
1241 static int at76_load_external_fw(
struct usb_device *udev,
struct fwentry *fwe)
1254 op_mode = at76_get_op_mode(udev);
1258 dev_printk(
KERN_ERR, &udev->dev,
"unexpected opmode %d\n",
1272 memcpy(block, buf, bsize);
1274 "ext fw, size left = %5d, bsize = %4d, blockno = %2d",
1275 size, bsize, blockno);
1276 ret = at76_load_ext_fw_block(udev, blockno, block, bsize);
1279 "loading %dth firmware block failed: %d\n",
1286 }
while (bsize > 0);
1297 "downloading external firmware failed: %d\n", ret);
1302 static int at76_load_internal_fw(
struct usb_device *udev,
struct fwentry *fwe)
1305 int need_remap = !at76_is_505a(fwe->
board_type);
1308 need_remap ? 0 : 2 *
HZ);
1312 "downloading internal fw failed with %d\n", ret);
1320 ret = at76_remap(udev);
1323 "sending REMAP failed with %d\n", ret);
1336 static int at76_startup_device(
struct at76_priv *priv)
1342 "%s param: ssid %.*s (%*phD) mode %s ch %d wep %s key %d "
1343 "keylen %d", wiphy_name(priv->
hw->wiphy), priv->
essid_size,
1349 "%s param: preamble %s rts %d retry %d frag %d "
1350 "txrate %s auth_mode %d", wiphy_name(priv->
hw->wiphy),
1359 "%s param: pm_mode %d pm_period %d auth_mode %s "
1360 "scan_times %d %d scan_mode %s",
1404 wiphy_err(priv->
hw->wiphy,
"at76_set_card_command failed: %d\n",
1414 if (at76_set_radio(priv, 1) == 1)
1429 ret = at76_set_autorate_fallback(priv,
1434 ret = at76_set_pm_mode(priv);
1439 at76_dump_mib_mac(priv);
1440 at76_dump_mib_mac_addr(priv);
1441 at76_dump_mib_mac_mgmt(priv);
1442 at76_dump_mib_mac_wep(priv);
1443 at76_dump_mib_mdomain(priv);
1444 at76_dump_mib_phy(priv);
1445 at76_dump_mib_local(priv);
1468 ret = at76_set_mib(priv, &priv->
mib_buf);
1471 "set_mib (promiscuous_mode) failed: %d\n", ret);
1477 static void at76_work_submit_rx(
struct work_struct *work)
1483 at76_submit_rx_urb(priv);
1487 static void at76_rx_tasklet(
unsigned long param)
1489 struct urb *
urb = (
struct urb *)param;
1505 if (urb->status != 0) {
1508 "%s %s: - nonzero Rx bulk status received: %d",
1509 __func__, wiphy_name(priv->
hw->wiphy),
1515 "%s: rx frame: rate %d rssi %d noise %d link %d",
1530 memcpy(IEEE80211_SKB_RXCB(priv->
rx_skb), &rx_status,
sizeof(rx_status));
1536 at76_submit_rx_urb(priv);
1540 static struct fwentry *at76_load_firmware(
struct usb_device *udev,
1558 dev_printk(
KERN_ERR, &udev->dev,
"firmware %s not found!\n",
1561 "you may need to download the firmware from "
1562 "http://developer.berlios.de/projects/at76c503a/\n");
1569 if (fwe->
fw->size <=
sizeof(*fwh)) {
1571 "firmware is too short (0x%zx)\n", fwe->
fw->size);
1579 "board type mismatch, requested %u, got %u\n",
1598 "using firmware %s (version %d.%d.%d-%d)\n",
1615 static int at76_join(
struct at76_priv *priv)
1629 ret = at76_set_card_command(priv->
udev,
CMD_JOIN, &join,
1633 wiphy_err(priv->
hw->wiphy,
"at76_set_card_command failed: %d\n",
1638 ret = at76_wait_completion(priv,
CMD_JOIN);
1641 wiphy_err(priv->
hw->wiphy,
"at76_wait_completion failed: %d\n",
1646 at76_set_pm_mode(priv);
1651 static void at76_work_join_bssid(
struct work_struct *work)
1661 if (is_valid_ether_addr(priv->
bssid))
1667 static void at76_mac80211_tx_callback(
struct urb *urb)
1674 switch (urb->status) {
1686 __func__, urb->status);
1713 "%s called while tx urb is pending\n", __func__);
1726 if (!ether_addr_equal(priv->
bssid, mgmt->
bssid)) {
1736 at76_ledtrig_tx_activity();
1741 padding = at76_calc_padding(skb->
len);
1745 memset(tx_buffer, 0,
sizeof(*tx_buffer));
1748 tx_buffer->
tx_rate = ieee80211_get_tx_rate(hw, info)->hw_value;
1758 "%s(): tx_buffer %d bytes:", __func__, submit_len);
1760 submit_len, at76_mac80211_tx_callback, priv);
1763 wiphy_err(priv->
hw->wiphy,
"error in tx submit urb: %d\n", ret);
1766 "-EINVAL: tx urb %p hcpriv %p complete %p\n",
1772 static int at76_mac80211_start(
struct ieee80211_hw *hw)
1781 ret = at76_submit_rx_urb(priv);
1783 wiphy_err(priv->
hw->wiphy,
"open: submit_rx_urb failed: %d\n",
1788 at76_startup_device(priv);
1790 at76_start_monitor(priv);
1798 static void at76_mac80211_stop(
struct ieee80211_hw *hw)
1813 at76_set_radio(priv, 0);
1833 switch (vif->
type) {
1848 static void at76_remove_interface(
struct ieee80211_hw *hw,
1854 static void at76_dwork_hw_scan(
struct work_struct *work)
1877 if (is_valid_ether_addr(priv->
bssid))
1910 ssid = req->
ssids[0].ssid;
1911 len = req->
ssids[0].ssid_len;
1918 scan.essid_size = len;
1924 scan.international_scan = 0;
1930 wiphy_err(priv->
hw->wiphy,
"CMD_SCAN failed: %d\n", ret);
1948 __func__, hw->
conf.channel->hw_value);
1955 if (is_valid_ether_addr(priv->
bssid))
1958 at76_start_monitor(priv);
1965 static void at76_bss_info_changed(
struct ieee80211_hw *hw,
1983 if (is_valid_ether_addr(priv->
bssid))
1991 static void at76_configure_filter(
struct ieee80211_hw *hw,
1992 unsigned int changed_flags,
1993 unsigned int *total_flags,
u64 multicast)
1999 "total_flags=0x%08x",
2000 __func__, changed_flags, *total_flags);
2013 if (flags && !priv->
promisc) {
2016 }
else if (!flags && priv->
promisc) {
2067 at76_startup_device(priv);
2075 .tx = at76_mac80211_tx,
2076 .add_interface = at76_add_interface,
2077 .remove_interface = at76_remove_interface,
2078 .config = at76_config,
2079 .bss_info_changed = at76_bss_info_changed,
2080 .configure_filter = at76_configure_filter,
2081 .start = at76_mac80211_start,
2082 .stop = at76_mac80211_stop,
2083 .hw_scan = at76_hw_scan,
2084 .set_key = at76_set_key,
2088 static struct at76_priv *at76_alloc_new_device(
struct usb_device *udev)
2117 priv->
hw->channel_change_time = 100000;
2122 static int at76_alloc_urbs(
struct at76_priv *priv,
2128 struct usb_host_interface *iface_desc;
2133 interface->altsetting[0].desc.bNumEndpoints);
2137 iface_desc = interface->cur_altsetting;
2138 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
2139 endpoint = &iface_desc->endpoint[
i].desc;
2145 if (!ep_in && usb_endpoint_is_bulk_in(endpoint))
2148 if (!ep_out && usb_endpoint_is_bulk_out(endpoint))
2152 if (!ep_in || !ep_out) {
2153 dev_printk(
KERN_ERR, &interface->dev,
2154 "bulk endpoints missing\n");
2164 dev_printk(
KERN_ERR, &interface->dev,
"cannot allocate URB\n");
2171 dev_printk(
KERN_ERR, &interface->dev,
2172 "cannot allocate output buffer\n");
2189 { .center_freq = 2412, .hw_value = 1 },
2190 { .center_freq = 2417, .hw_value = 2 },
2191 { .center_freq = 2422, .hw_value = 3 },
2192 { .center_freq = 2427, .hw_value = 4 },
2193 { .center_freq = 2432, .hw_value = 5 },
2194 { .center_freq = 2437, .hw_value = 6 },
2195 { .center_freq = 2442, .hw_value = 7 },
2196 { .center_freq = 2447, .hw_value = 8 },
2197 { .center_freq = 2452, .hw_value = 9 },
2198 { .center_freq = 2457, .hw_value = 10 },
2199 { .center_freq = 2462, .hw_value = 11 },
2200 { .center_freq = 2467, .hw_value = 12 },
2201 { .center_freq = 2472, .hw_value = 13 },
2202 { .center_freq = 2484, .hw_value = 14 }
2206 .channels = at76_channels,
2208 .bitrates = at76_rates,
2213 static int at76_init_new_device(
struct at76_priv *priv,
2224 interface->cur_altsetting->desc.bNumEndpoints);
2226 ret = at76_alloc_urbs(priv, interface);
2231 ret = at76_get_hw_config(priv);
2233 dev_printk(
KERN_ERR, &interface->dev,
2234 "cannot get MAC address\n");
2255 wiphy = priv->
hw->wiphy;
2256 priv->
hw->wiphy->max_scan_ssids = 1;
2257 priv->
hw->wiphy->max_scan_ie_len = 0;
2262 priv->
hw->max_signal = 100;
2264 SET_IEEE80211_DEV(priv->
hw, &interface->dev);
2265 SET_IEEE80211_PERM_ADDR(priv->
hw, priv->
mac_addr);
2283 wiphy_info(priv->
hw->wiphy,
"USB %s, MAC %pM, firmware %d.%d.%d-%d\n",
2284 dev_name(&interface->dev), priv->
mac_addr,
2287 wiphy_info(priv->
hw->wiphy,
"regulatory domain 0x%02x: %s\n",
2294 static void at76_delete_device(
struct at76_priv *priv)
2338 struct usb_device *
udev;
2340 int need_ext_fw = 0;
2342 int board_type = (
int)id->driver_info;
2344 udev =
usb_get_dev(interface_to_usbdev(interface));
2347 fwe = at76_load_firmware(udev, board_type);
2353 op_mode = at76_get_op_mode(udev);
2361 dev_printk(
KERN_ERR, &interface->dev,
2362 "cannot handle a device in HW_CONFIG_MODE\n");
2371 "downloading internal firmware\n");
2372 ret = at76_load_internal_fw(udev, fwe);
2374 dev_printk(
KERN_ERR, &interface->dev,
2375 "error %d downloading internal firmware\n",
2394 if (ret < 0 || (fwv.major | fwv.minor) == 0)
2402 "downloading external firmware\n");
2404 ret = at76_load_external_fw(udev, fwe);
2411 dev_printk(
KERN_ERR, &interface->dev,
2412 "error %d getting firmware version\n", ret);
2417 priv = at76_alloc_new_device(udev);
2423 usb_set_intfdata(interface, priv);
2428 ret = at76_init_new_device(priv, interface);
2430 at76_delete_device(priv);
2439 static void at76_disconnect(
struct usb_interface *interface)
2443 priv = usb_get_intfdata(interface);
2444 usb_set_intfdata(interface,
NULL);
2451 at76_delete_device(priv);
2452 dev_printk(
KERN_INFO, &interface->dev,
"disconnected\n");
2456 static struct usb_driver at76_driver = {
2458 .probe = at76_probe,
2459 .disconnect = at76_disconnect,
2460 .id_table = dev_table,
2461 .disable_hub_initiated_lpm = 1,
2464 static int __init at76_mod_init(
void)
2473 result = usb_register(&at76_driver);
2476 ": usb_register failed (status %d)\n", result);
2482 static void __exit at76_mod_exit(
void)