Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include "htc.h" |
| 18 | |
John W. Linville | d0ee0eb | 2010-06-23 14:20:45 -0400 | [diff] [blame] | 19 | /* identify firmware images */ |
| 20 | #define FIRMWARE_AR7010 "ar7010.fw" |
| 21 | #define FIRMWARE_AR7010_1_1 "ar7010_1_1.fw" |
| 22 | #define FIRMWARE_AR9271 "ar9271.fw" |
| 23 | |
| 24 | MODULE_FIRMWARE(FIRMWARE_AR7010); |
| 25 | MODULE_FIRMWARE(FIRMWARE_AR7010_1_1); |
| 26 | MODULE_FIRMWARE(FIRMWARE_AR9271); |
| 27 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 28 | static struct usb_device_id ath9k_hif_usb_ids[] = { |
Sujith | 4e63f76 | 2010-06-17 10:29:01 +0530 | [diff] [blame] | 29 | { USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */ |
| 30 | { USB_DEVICE(0x0cf3, 0x1006) }, /* Atheros */ |
Sujith | 4e63f76 | 2010-06-17 10:29:01 +0530 | [diff] [blame] | 31 | { USB_DEVICE(0x0846, 0x9030) }, /* Netgear N150 */ |
Sujith | 4e63f76 | 2010-06-17 10:29:01 +0530 | [diff] [blame] | 32 | { USB_DEVICE(0x07D1, 0x3A10) }, /* Dlink Wireless 150 */ |
| 33 | { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */ |
| 34 | { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */ |
Haitao Zhang | ac618d7 | 2010-11-07 12:50:24 +0800 | [diff] [blame] | 35 | { USB_DEVICE(0x13D3, 0x3346) }, /* IMC Networks */ |
Rajkumar Manoharan | 32b0895 | 2010-11-10 17:51:24 +0530 | [diff] [blame] | 36 | { USB_DEVICE(0x13D3, 0x3348) }, /* Azurewave */ |
| 37 | { USB_DEVICE(0x13D3, 0x3349) }, /* Azurewave */ |
| 38 | { USB_DEVICE(0x13D3, 0x3350) }, /* Azurewave */ |
Sujith | 4e63f76 | 2010-06-17 10:29:01 +0530 | [diff] [blame] | 39 | { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */ |
Rajkumar Manoharan | 32b0895 | 2010-11-10 17:51:24 +0530 | [diff] [blame] | 40 | { USB_DEVICE(0x040D, 0x3801) }, /* VIA */ |
Sujith Manoharan | 452d7dd | 2010-12-13 07:39:32 +0530 | [diff] [blame] | 41 | { USB_DEVICE(0x0cf3, 0xb003) }, /* Ubiquiti WifiStation Ext */ |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 42 | |
| 43 | { USB_DEVICE(0x0cf3, 0x7015), |
| 44 | .driver_info = AR9287_USB }, /* Atheros */ |
Rajkumar Manoharan | 64f1217 | 2010-11-19 16:53:20 +0530 | [diff] [blame] | 45 | { USB_DEVICE(0x1668, 0x1200), |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 46 | .driver_info = AR9287_USB }, /* Verizon */ |
| 47 | |
| 48 | { USB_DEVICE(0x0cf3, 0x7010), |
| 49 | .driver_info = AR9280_USB }, /* Atheros */ |
| 50 | { USB_DEVICE(0x0846, 0x9018), |
| 51 | .driver_info = AR9280_USB }, /* Netgear WNDA3200 */ |
| 52 | { USB_DEVICE(0x083A, 0xA704), |
| 53 | .driver_info = AR9280_USB }, /* SMC Networks */ |
| 54 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 55 | { }, |
| 56 | }; |
| 57 | |
| 58 | MODULE_DEVICE_TABLE(usb, ath9k_hif_usb_ids); |
| 59 | |
| 60 | static int __hif_usb_tx(struct hif_device_usb *hif_dev); |
| 61 | |
| 62 | static void hif_usb_regout_cb(struct urb *urb) |
| 63 | { |
| 64 | struct cmd_buf *cmd = (struct cmd_buf *)urb->context; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 65 | |
| 66 | switch (urb->status) { |
| 67 | case 0: |
| 68 | break; |
| 69 | case -ENOENT: |
| 70 | case -ECONNRESET: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 71 | case -ENODEV: |
| 72 | case -ESHUTDOWN: |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 73 | goto free; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 74 | default: |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | if (cmd) { |
| 79 | ath9k_htc_txcompletion_cb(cmd->hif_dev->htc_handle, |
| 80 | cmd->skb, 1); |
| 81 | kfree(cmd); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 82 | } |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 83 | |
| 84 | return; |
| 85 | free: |
Ming Lei | 0fa35a5 | 2010-04-13 00:29:15 +0800 | [diff] [blame] | 86 | kfree_skb(cmd->skb); |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 87 | kfree(cmd); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | static int hif_usb_send_regout(struct hif_device_usb *hif_dev, |
| 91 | struct sk_buff *skb) |
| 92 | { |
| 93 | struct urb *urb; |
| 94 | struct cmd_buf *cmd; |
| 95 | int ret = 0; |
| 96 | |
| 97 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 98 | if (urb == NULL) |
| 99 | return -ENOMEM; |
| 100 | |
| 101 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
| 102 | if (cmd == NULL) { |
| 103 | usb_free_urb(urb); |
| 104 | return -ENOMEM; |
| 105 | } |
| 106 | |
| 107 | cmd->skb = skb; |
| 108 | cmd->hif_dev = hif_dev; |
| 109 | |
Rajkumar Manoharan | 4a0e8ecc | 2010-09-14 14:35:55 +0530 | [diff] [blame] | 110 | usb_fill_bulk_urb(urb, hif_dev->udev, |
| 111 | usb_sndbulkpipe(hif_dev->udev, USB_REG_OUT_PIPE), |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 112 | skb->data, skb->len, |
Rajkumar Manoharan | 4a0e8ecc | 2010-09-14 14:35:55 +0530 | [diff] [blame] | 113 | hif_usb_regout_cb, cmd); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 114 | |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 115 | usb_anchor_urb(urb, &hif_dev->regout_submitted); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 116 | ret = usb_submit_urb(urb, GFP_KERNEL); |
| 117 | if (ret) { |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 118 | usb_unanchor_urb(urb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 119 | kfree(cmd); |
| 120 | } |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 121 | usb_free_urb(urb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 122 | |
| 123 | return ret; |
| 124 | } |
| 125 | |
Sujith | eac8e38 | 2010-04-16 11:54:00 +0530 | [diff] [blame] | 126 | static inline void ath9k_skb_queue_purge(struct hif_device_usb *hif_dev, |
| 127 | struct sk_buff_head *list) |
Ming Lei | f8e1d08 | 2010-04-13 00:29:27 +0800 | [diff] [blame] | 128 | { |
| 129 | struct sk_buff *skb; |
Sujith | eac8e38 | 2010-04-16 11:54:00 +0530 | [diff] [blame] | 130 | |
| 131 | while ((skb = __skb_dequeue(list)) != NULL) { |
Ming Lei | f8e1d08 | 2010-04-13 00:29:27 +0800 | [diff] [blame] | 132 | dev_kfree_skb_any(skb); |
Sujith | eac8e38 | 2010-04-16 11:54:00 +0530 | [diff] [blame] | 133 | TX_STAT_INC(skb_dropped); |
| 134 | } |
Ming Lei | f8e1d08 | 2010-04-13 00:29:27 +0800 | [diff] [blame] | 135 | } |
| 136 | |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 137 | static void hif_usb_tx_cb(struct urb *urb) |
| 138 | { |
| 139 | struct tx_buf *tx_buf = (struct tx_buf *) urb->context; |
Dan Carpenter | 690e781 | 2010-05-14 16:50:56 +0200 | [diff] [blame] | 140 | struct hif_device_usb *hif_dev; |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 141 | struct sk_buff *skb; |
| 142 | |
Dan Carpenter | 690e781 | 2010-05-14 16:50:56 +0200 | [diff] [blame] | 143 | if (!tx_buf || !tx_buf->hif_dev) |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 144 | return; |
| 145 | |
Dan Carpenter | 690e781 | 2010-05-14 16:50:56 +0200 | [diff] [blame] | 146 | hif_dev = tx_buf->hif_dev; |
| 147 | |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 148 | switch (urb->status) { |
| 149 | case 0: |
| 150 | break; |
| 151 | case -ENOENT: |
| 152 | case -ECONNRESET: |
| 153 | case -ENODEV: |
| 154 | case -ESHUTDOWN: |
| 155 | /* |
| 156 | * The URB has been killed, free the SKBs |
| 157 | * and return. |
| 158 | */ |
| 159 | ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue); |
| 160 | return; |
| 161 | default: |
| 162 | break; |
| 163 | } |
| 164 | |
| 165 | /* Check if TX has been stopped */ |
| 166 | spin_lock(&hif_dev->tx.tx_lock); |
| 167 | if (hif_dev->tx.flags & HIF_USB_TX_STOP) { |
| 168 | spin_unlock(&hif_dev->tx.tx_lock); |
| 169 | ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue); |
| 170 | goto add_free; |
| 171 | } |
| 172 | spin_unlock(&hif_dev->tx.tx_lock); |
| 173 | |
| 174 | /* Complete the queued SKBs. */ |
| 175 | while ((skb = __skb_dequeue(&tx_buf->skb_queue)) != NULL) { |
| 176 | ath9k_htc_txcompletion_cb(hif_dev->htc_handle, |
| 177 | skb, 1); |
| 178 | TX_STAT_INC(skb_completed); |
| 179 | } |
| 180 | |
| 181 | add_free: |
| 182 | /* Re-initialize the SKB queue */ |
| 183 | tx_buf->len = tx_buf->offset = 0; |
| 184 | __skb_queue_head_init(&tx_buf->skb_queue); |
| 185 | |
| 186 | /* Add this TX buffer to the free list */ |
| 187 | spin_lock(&hif_dev->tx.tx_lock); |
| 188 | list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf); |
| 189 | hif_dev->tx.tx_buf_cnt++; |
| 190 | if (!(hif_dev->tx.flags & HIF_USB_TX_STOP)) |
| 191 | __hif_usb_tx(hif_dev); /* Check for pending SKBs */ |
| 192 | TX_STAT_INC(buf_completed); |
| 193 | spin_unlock(&hif_dev->tx.tx_lock); |
| 194 | } |
| 195 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 196 | /* TX lock has to be taken */ |
| 197 | static int __hif_usb_tx(struct hif_device_usb *hif_dev) |
| 198 | { |
| 199 | struct tx_buf *tx_buf = NULL; |
| 200 | struct sk_buff *nskb = NULL; |
| 201 | int ret = 0, i; |
| 202 | u16 *hdr, tx_skb_cnt = 0; |
| 203 | u8 *buf; |
| 204 | |
| 205 | if (hif_dev->tx.tx_skb_cnt == 0) |
| 206 | return 0; |
| 207 | |
| 208 | /* Check if a free TX buffer is available */ |
| 209 | if (list_empty(&hif_dev->tx.tx_buf)) |
| 210 | return 0; |
| 211 | |
| 212 | tx_buf = list_first_entry(&hif_dev->tx.tx_buf, struct tx_buf, list); |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 213 | list_move_tail(&tx_buf->list, &hif_dev->tx.tx_pending); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 214 | hif_dev->tx.tx_buf_cnt--; |
| 215 | |
| 216 | tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM); |
| 217 | |
| 218 | for (i = 0; i < tx_skb_cnt; i++) { |
| 219 | nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue); |
| 220 | |
| 221 | /* Should never be NULL */ |
| 222 | BUG_ON(!nskb); |
| 223 | |
| 224 | hif_dev->tx.tx_skb_cnt--; |
| 225 | |
| 226 | buf = tx_buf->buf; |
| 227 | buf += tx_buf->offset; |
| 228 | hdr = (u16 *)buf; |
| 229 | *hdr++ = nskb->len; |
| 230 | *hdr++ = ATH_USB_TX_STREAM_MODE_TAG; |
| 231 | buf += 4; |
| 232 | memcpy(buf, nskb->data, nskb->len); |
| 233 | tx_buf->len = nskb->len + 4; |
| 234 | |
| 235 | if (i < (tx_skb_cnt - 1)) |
| 236 | tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4; |
| 237 | |
| 238 | if (i == (tx_skb_cnt - 1)) |
| 239 | tx_buf->len += tx_buf->offset; |
| 240 | |
| 241 | __skb_queue_tail(&tx_buf->skb_queue, nskb); |
| 242 | TX_STAT_INC(skb_queued); |
| 243 | } |
| 244 | |
| 245 | usb_fill_bulk_urb(tx_buf->urb, hif_dev->udev, |
| 246 | usb_sndbulkpipe(hif_dev->udev, USB_WLAN_TX_PIPE), |
| 247 | tx_buf->buf, tx_buf->len, |
| 248 | hif_usb_tx_cb, tx_buf); |
| 249 | |
| 250 | ret = usb_submit_urb(tx_buf->urb, GFP_ATOMIC); |
| 251 | if (ret) { |
| 252 | tx_buf->len = tx_buf->offset = 0; |
Sujith | eac8e38 | 2010-04-16 11:54:00 +0530 | [diff] [blame] | 253 | ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 254 | __skb_queue_head_init(&tx_buf->skb_queue); |
| 255 | list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf); |
| 256 | hif_dev->tx.tx_buf_cnt++; |
| 257 | } |
| 258 | |
| 259 | if (!ret) |
| 260 | TX_STAT_INC(buf_queued); |
| 261 | |
| 262 | return ret; |
| 263 | } |
| 264 | |
| 265 | static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb, |
| 266 | struct ath9k_htc_tx_ctl *tx_ctl) |
| 267 | { |
| 268 | unsigned long flags; |
| 269 | |
| 270 | spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); |
| 271 | |
| 272 | if (hif_dev->tx.flags & HIF_USB_TX_STOP) { |
| 273 | spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); |
| 274 | return -ENODEV; |
| 275 | } |
| 276 | |
| 277 | /* Check if the max queue count has been reached */ |
| 278 | if (hif_dev->tx.tx_skb_cnt > MAX_TX_BUF_NUM) { |
| 279 | spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); |
| 280 | return -ENOMEM; |
| 281 | } |
| 282 | |
| 283 | __skb_queue_tail(&hif_dev->tx.tx_skb_queue, skb); |
| 284 | hif_dev->tx.tx_skb_cnt++; |
| 285 | |
| 286 | /* Send normal frames immediately */ |
| 287 | if (!tx_ctl || (tx_ctl && (tx_ctl->type == ATH9K_HTC_NORMAL))) |
| 288 | __hif_usb_tx(hif_dev); |
| 289 | |
| 290 | /* Check if AMPDUs have to be sent immediately */ |
| 291 | if (tx_ctl && (tx_ctl->type == ATH9K_HTC_AMPDU) && |
| 292 | (hif_dev->tx.tx_buf_cnt == MAX_TX_URB_NUM) && |
| 293 | (hif_dev->tx.tx_skb_cnt < 2)) { |
| 294 | __hif_usb_tx(hif_dev); |
| 295 | } |
| 296 | |
| 297 | spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); |
| 298 | |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static void hif_usb_start(void *hif_handle, u8 pipe_id) |
| 303 | { |
| 304 | struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; |
| 305 | unsigned long flags; |
| 306 | |
| 307 | hif_dev->flags |= HIF_USB_START; |
| 308 | |
| 309 | spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); |
| 310 | hif_dev->tx.flags &= ~HIF_USB_TX_STOP; |
| 311 | spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); |
| 312 | } |
| 313 | |
| 314 | static void hif_usb_stop(void *hif_handle, u8 pipe_id) |
| 315 | { |
| 316 | struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; |
| 317 | unsigned long flags; |
| 318 | |
| 319 | spin_lock_irqsave(&hif_dev->tx.tx_lock, flags); |
Sujith | eac8e38 | 2010-04-16 11:54:00 +0530 | [diff] [blame] | 320 | ath9k_skb_queue_purge(hif_dev, &hif_dev->tx.tx_skb_queue); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 321 | hif_dev->tx.tx_skb_cnt = 0; |
| 322 | hif_dev->tx.flags |= HIF_USB_TX_STOP; |
| 323 | spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags); |
| 324 | } |
| 325 | |
| 326 | static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb, |
| 327 | struct ath9k_htc_tx_ctl *tx_ctl) |
| 328 | { |
| 329 | struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; |
| 330 | int ret = 0; |
| 331 | |
| 332 | switch (pipe_id) { |
| 333 | case USB_WLAN_TX_PIPE: |
| 334 | ret = hif_usb_send_tx(hif_dev, skb, tx_ctl); |
| 335 | break; |
| 336 | case USB_REG_OUT_PIPE: |
| 337 | ret = hif_usb_send_regout(hif_dev, skb); |
| 338 | break; |
| 339 | default: |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 340 | dev_err(&hif_dev->udev->dev, |
| 341 | "ath9k_htc: Invalid TX pipe: %d\n", pipe_id); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 342 | ret = -EINVAL; |
| 343 | break; |
| 344 | } |
| 345 | |
| 346 | return ret; |
| 347 | } |
| 348 | |
| 349 | static struct ath9k_htc_hif hif_usb = { |
| 350 | .transport = ATH9K_HIF_USB, |
| 351 | .name = "ath9k_hif_usb", |
| 352 | |
| 353 | .control_ul_pipe = USB_REG_OUT_PIPE, |
| 354 | .control_dl_pipe = USB_REG_IN_PIPE, |
| 355 | |
| 356 | .start = hif_usb_start, |
| 357 | .stop = hif_usb_stop, |
| 358 | .send = hif_usb_send, |
| 359 | }; |
| 360 | |
| 361 | static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, |
| 362 | struct sk_buff *skb) |
| 363 | { |
Sujith | c503269 | 2010-04-06 15:28:15 +0530 | [diff] [blame] | 364 | struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER]; |
Joe Perches | 44b23b4 | 2010-11-30 12:19:11 -0800 | [diff] [blame] | 365 | int index = 0, i = 0, len = skb->len; |
| 366 | int rx_remain_len, rx_pkt_len; |
| 367 | u16 pool_index = 0; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 368 | u8 *ptr; |
| 369 | |
Sujith | 46baa1a | 2010-04-06 15:28:11 +0530 | [diff] [blame] | 370 | spin_lock(&hif_dev->rx_lock); |
| 371 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 372 | rx_remain_len = hif_dev->rx_remain_len; |
| 373 | rx_pkt_len = hif_dev->rx_transfer_len; |
| 374 | |
| 375 | if (rx_remain_len != 0) { |
| 376 | struct sk_buff *remain_skb = hif_dev->remain_skb; |
| 377 | |
| 378 | if (remain_skb) { |
| 379 | ptr = (u8 *) remain_skb->data; |
| 380 | |
| 381 | index = rx_remain_len; |
| 382 | rx_remain_len -= hif_dev->rx_pad_len; |
| 383 | ptr += rx_pkt_len; |
| 384 | |
| 385 | memcpy(ptr, skb->data, rx_remain_len); |
| 386 | |
| 387 | rx_pkt_len += rx_remain_len; |
| 388 | hif_dev->rx_remain_len = 0; |
| 389 | skb_put(remain_skb, rx_pkt_len); |
| 390 | |
| 391 | skb_pool[pool_index++] = remain_skb; |
| 392 | |
| 393 | } else { |
| 394 | index = rx_remain_len; |
| 395 | } |
| 396 | } |
| 397 | |
Sujith | 46baa1a | 2010-04-06 15:28:11 +0530 | [diff] [blame] | 398 | spin_unlock(&hif_dev->rx_lock); |
| 399 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 400 | while (index < len) { |
Joe Perches | 44b23b4 | 2010-11-30 12:19:11 -0800 | [diff] [blame] | 401 | u16 pkt_len; |
| 402 | u16 pkt_tag; |
| 403 | u16 pad_len; |
| 404 | int chk_idx; |
| 405 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 406 | ptr = (u8 *) skb->data; |
| 407 | |
| 408 | pkt_len = ptr[index] + (ptr[index+1] << 8); |
| 409 | pkt_tag = ptr[index+2] + (ptr[index+3] << 8); |
| 410 | |
Joe Perches | 44b23b4 | 2010-11-30 12:19:11 -0800 | [diff] [blame] | 411 | if (pkt_tag != ATH_USB_RX_STREAM_MODE_TAG) { |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 412 | RX_STAT_INC(skb_dropped); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 413 | return; |
| 414 | } |
Joe Perches | 44b23b4 | 2010-11-30 12:19:11 -0800 | [diff] [blame] | 415 | |
| 416 | pad_len = 4 - (pkt_len & 0x3); |
| 417 | if (pad_len == 4) |
| 418 | pad_len = 0; |
| 419 | |
| 420 | chk_idx = index; |
| 421 | index = index + 4 + pkt_len + pad_len; |
| 422 | |
| 423 | if (index > MAX_RX_BUF_SIZE) { |
| 424 | spin_lock(&hif_dev->rx_lock); |
| 425 | hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE; |
| 426 | hif_dev->rx_transfer_len = |
| 427 | MAX_RX_BUF_SIZE - chk_idx - 4; |
| 428 | hif_dev->rx_pad_len = pad_len; |
| 429 | |
| 430 | nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC); |
| 431 | if (!nskb) { |
| 432 | dev_err(&hif_dev->udev->dev, |
| 433 | "ath9k_htc: RX memory allocation error\n"); |
| 434 | spin_unlock(&hif_dev->rx_lock); |
| 435 | goto err; |
| 436 | } |
| 437 | skb_reserve(nskb, 32); |
| 438 | RX_STAT_INC(skb_allocated); |
| 439 | |
| 440 | memcpy(nskb->data, &(skb->data[chk_idx+4]), |
| 441 | hif_dev->rx_transfer_len); |
| 442 | |
| 443 | /* Record the buffer pointer */ |
| 444 | hif_dev->remain_skb = nskb; |
| 445 | spin_unlock(&hif_dev->rx_lock); |
| 446 | } else { |
| 447 | nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC); |
| 448 | if (!nskb) { |
| 449 | dev_err(&hif_dev->udev->dev, |
| 450 | "ath9k_htc: RX memory allocation error\n"); |
| 451 | goto err; |
| 452 | } |
| 453 | skb_reserve(nskb, 32); |
| 454 | RX_STAT_INC(skb_allocated); |
| 455 | |
| 456 | memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len); |
| 457 | skb_put(nskb, pkt_len); |
| 458 | skb_pool[pool_index++] = nskb; |
| 459 | } |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | err: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 463 | for (i = 0; i < pool_index; i++) { |
| 464 | ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i], |
| 465 | skb_pool[i]->len, USB_WLAN_RX_PIPE); |
| 466 | RX_STAT_INC(skb_completed); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | static void ath9k_hif_usb_rx_cb(struct urb *urb) |
| 471 | { |
| 472 | struct sk_buff *skb = (struct sk_buff *) urb->context; |
Joe Perches | b276736 | 2010-11-30 13:42:08 -0800 | [diff] [blame] | 473 | struct hif_device_usb *hif_dev = |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 474 | usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); |
| 475 | int ret; |
| 476 | |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 477 | if (!skb) |
| 478 | return; |
| 479 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 480 | if (!hif_dev) |
| 481 | goto free; |
| 482 | |
| 483 | switch (urb->status) { |
| 484 | case 0: |
| 485 | break; |
| 486 | case -ENOENT: |
| 487 | case -ECONNRESET: |
| 488 | case -ENODEV: |
| 489 | case -ESHUTDOWN: |
| 490 | goto free; |
| 491 | default: |
| 492 | goto resubmit; |
| 493 | } |
| 494 | |
| 495 | if (likely(urb->actual_length != 0)) { |
| 496 | skb_put(skb, urb->actual_length); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 497 | ath9k_hif_usb_rx_stream(hif_dev, skb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | resubmit: |
| 501 | skb_reset_tail_pointer(skb); |
| 502 | skb_trim(skb, 0); |
| 503 | |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 504 | usb_anchor_urb(urb, &hif_dev->rx_submitted); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 505 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 506 | if (ret) { |
| 507 | usb_unanchor_urb(urb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 508 | goto free; |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 509 | } |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 510 | |
| 511 | return; |
| 512 | free: |
Ming Lei | f28a7b3 | 2010-04-13 00:28:53 +0800 | [diff] [blame] | 513 | kfree_skb(skb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | static void ath9k_hif_usb_reg_in_cb(struct urb *urb) |
| 517 | { |
| 518 | struct sk_buff *skb = (struct sk_buff *) urb->context; |
| 519 | struct sk_buff *nskb; |
Joe Perches | b276736 | 2010-11-30 13:42:08 -0800 | [diff] [blame] | 520 | struct hif_device_usb *hif_dev = |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 521 | usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0)); |
| 522 | int ret; |
| 523 | |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 524 | if (!skb) |
| 525 | return; |
| 526 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 527 | if (!hif_dev) |
| 528 | goto free; |
| 529 | |
| 530 | switch (urb->status) { |
| 531 | case 0: |
| 532 | break; |
| 533 | case -ENOENT: |
| 534 | case -ECONNRESET: |
| 535 | case -ENODEV: |
| 536 | case -ESHUTDOWN: |
| 537 | goto free; |
| 538 | default: |
| 539 | goto resubmit; |
| 540 | } |
| 541 | |
| 542 | if (likely(urb->actual_length != 0)) { |
| 543 | skb_put(skb, urb->actual_length); |
| 544 | |
Sujith | 5ab0af3 | 2010-04-23 10:28:17 +0530 | [diff] [blame] | 545 | /* Process the command first */ |
| 546 | ath9k_htc_rx_msg(hif_dev->htc_handle, skb, |
| 547 | skb->len, USB_REG_IN_PIPE); |
| 548 | |
| 549 | |
Ming Lei | e6c6d33 | 2010-04-13 00:29:05 +0800 | [diff] [blame] | 550 | nskb = alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_ATOMIC); |
Sujith | 5ab0af3 | 2010-04-23 10:28:17 +0530 | [diff] [blame] | 551 | if (!nskb) { |
| 552 | dev_err(&hif_dev->udev->dev, |
| 553 | "ath9k_htc: REG_IN memory allocation failure\n"); |
| 554 | urb->context = NULL; |
| 555 | return; |
| 556 | } |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 557 | |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 558 | usb_fill_bulk_urb(urb, hif_dev->udev, |
Rajkumar Manoharan | 0f529e9 | 2010-09-16 19:56:55 +0530 | [diff] [blame] | 559 | usb_rcvbulkpipe(hif_dev->udev, |
| 560 | USB_REG_IN_PIPE), |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 561 | nskb->data, MAX_REG_IN_BUF_SIZE, |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 562 | ath9k_hif_usb_reg_in_cb, nskb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 563 | |
| 564 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
| 565 | if (ret) { |
Ming Lei | e6c6d33 | 2010-04-13 00:29:05 +0800 | [diff] [blame] | 566 | kfree_skb(nskb); |
Sujith | 5ab0af3 | 2010-04-23 10:28:17 +0530 | [diff] [blame] | 567 | urb->context = NULL; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 568 | } |
| 569 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 570 | return; |
| 571 | } |
| 572 | |
| 573 | resubmit: |
| 574 | skb_reset_tail_pointer(skb); |
| 575 | skb_trim(skb, 0); |
| 576 | |
| 577 | ret = usb_submit_urb(urb, GFP_ATOMIC); |
| 578 | if (ret) |
| 579 | goto free; |
| 580 | |
| 581 | return; |
| 582 | free: |
Ming Lei | e6c6d33 | 2010-04-13 00:29:05 +0800 | [diff] [blame] | 583 | kfree_skb(skb); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 584 | urb->context = NULL; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev) |
| 588 | { |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 589 | struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL; |
| 590 | |
Sujith | c11d8f8 | 2010-04-23 10:28:09 +0530 | [diff] [blame] | 591 | list_for_each_entry_safe(tx_buf, tx_buf_tmp, |
| 592 | &hif_dev->tx.tx_buf, list) { |
| 593 | usb_kill_urb(tx_buf->urb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 594 | list_del(&tx_buf->list); |
| 595 | usb_free_urb(tx_buf->urb); |
| 596 | kfree(tx_buf->buf); |
| 597 | kfree(tx_buf); |
| 598 | } |
| 599 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 600 | list_for_each_entry_safe(tx_buf, tx_buf_tmp, |
| 601 | &hif_dev->tx.tx_pending, list) { |
| 602 | usb_kill_urb(tx_buf->urb); |
| 603 | list_del(&tx_buf->list); |
| 604 | usb_free_urb(tx_buf->urb); |
| 605 | kfree(tx_buf->buf); |
| 606 | kfree(tx_buf); |
| 607 | } |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev) |
| 611 | { |
| 612 | struct tx_buf *tx_buf; |
| 613 | int i; |
| 614 | |
| 615 | INIT_LIST_HEAD(&hif_dev->tx.tx_buf); |
| 616 | INIT_LIST_HEAD(&hif_dev->tx.tx_pending); |
| 617 | spin_lock_init(&hif_dev->tx.tx_lock); |
| 618 | __skb_queue_head_init(&hif_dev->tx.tx_skb_queue); |
| 619 | |
| 620 | for (i = 0; i < MAX_TX_URB_NUM; i++) { |
| 621 | tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL); |
| 622 | if (!tx_buf) |
| 623 | goto err; |
| 624 | |
| 625 | tx_buf->buf = kzalloc(MAX_TX_BUF_SIZE, GFP_KERNEL); |
| 626 | if (!tx_buf->buf) |
| 627 | goto err; |
| 628 | |
| 629 | tx_buf->urb = usb_alloc_urb(0, GFP_KERNEL); |
| 630 | if (!tx_buf->urb) |
| 631 | goto err; |
| 632 | |
| 633 | tx_buf->hif_dev = hif_dev; |
| 634 | __skb_queue_head_init(&tx_buf->skb_queue); |
| 635 | |
| 636 | list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf); |
| 637 | } |
| 638 | |
| 639 | hif_dev->tx.tx_buf_cnt = MAX_TX_URB_NUM; |
| 640 | |
| 641 | return 0; |
| 642 | err: |
Dan Carpenter | 7606688 | 2010-05-14 16:52:37 +0200 | [diff] [blame] | 643 | if (tx_buf) { |
| 644 | kfree(tx_buf->buf); |
| 645 | kfree(tx_buf); |
| 646 | } |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 647 | ath9k_hif_usb_dealloc_tx_urbs(hif_dev); |
| 648 | return -ENOMEM; |
| 649 | } |
| 650 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 651 | static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev) |
| 652 | { |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 653 | usb_kill_anchored_urbs(&hif_dev->rx_submitted); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev) |
| 657 | { |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 658 | struct urb *urb = NULL; |
| 659 | struct sk_buff *skb = NULL; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 660 | int i, ret; |
| 661 | |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 662 | init_usb_anchor(&hif_dev->rx_submitted); |
Sujith | 46baa1a | 2010-04-06 15:28:11 +0530 | [diff] [blame] | 663 | spin_lock_init(&hif_dev->rx_lock); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 664 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 665 | for (i = 0; i < MAX_RX_URB_NUM; i++) { |
| 666 | |
| 667 | /* Allocate URB */ |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 668 | urb = usb_alloc_urb(0, GFP_KERNEL); |
| 669 | if (urb == NULL) { |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 670 | ret = -ENOMEM; |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 671 | goto err_urb; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | /* Allocate buffer */ |
Ming Lei | f28a7b3 | 2010-04-13 00:28:53 +0800 | [diff] [blame] | 675 | skb = alloc_skb(MAX_RX_BUF_SIZE, GFP_KERNEL); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 676 | if (!skb) { |
| 677 | ret = -ENOMEM; |
| 678 | goto err_skb; |
| 679 | } |
| 680 | |
| 681 | usb_fill_bulk_urb(urb, hif_dev->udev, |
| 682 | usb_rcvbulkpipe(hif_dev->udev, |
| 683 | USB_WLAN_RX_PIPE), |
| 684 | skb->data, MAX_RX_BUF_SIZE, |
| 685 | ath9k_hif_usb_rx_cb, skb); |
| 686 | |
| 687 | /* Anchor URB */ |
| 688 | usb_anchor_urb(urb, &hif_dev->rx_submitted); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 689 | |
| 690 | /* Submit URB */ |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 691 | ret = usb_submit_urb(urb, GFP_KERNEL); |
| 692 | if (ret) { |
| 693 | usb_unanchor_urb(urb); |
| 694 | goto err_submit; |
| 695 | } |
Sujith | 66b10e3 | 2010-04-06 15:28:13 +0530 | [diff] [blame] | 696 | |
| 697 | /* |
| 698 | * Drop reference count. |
| 699 | * This ensures that the URB is freed when killing them. |
| 700 | */ |
| 701 | usb_free_urb(urb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | return 0; |
| 705 | |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 706 | err_submit: |
Ming Lei | f28a7b3 | 2010-04-13 00:28:53 +0800 | [diff] [blame] | 707 | kfree_skb(skb); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 708 | err_skb: |
| 709 | usb_free_urb(urb); |
| 710 | err_urb: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 711 | ath9k_hif_usb_dealloc_rx_urbs(hif_dev); |
| 712 | return ret; |
| 713 | } |
| 714 | |
| 715 | static void ath9k_hif_usb_dealloc_reg_in_urb(struct hif_device_usb *hif_dev) |
| 716 | { |
| 717 | if (hif_dev->reg_in_urb) { |
| 718 | usb_kill_urb(hif_dev->reg_in_urb); |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 719 | if (hif_dev->reg_in_urb->context) |
Ming Lei | e6c6d33 | 2010-04-13 00:29:05 +0800 | [diff] [blame] | 720 | kfree_skb((void *)hif_dev->reg_in_urb->context); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 721 | usb_free_urb(hif_dev->reg_in_urb); |
| 722 | hif_dev->reg_in_urb = NULL; |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | static int ath9k_hif_usb_alloc_reg_in_urb(struct hif_device_usb *hif_dev) |
| 727 | { |
| 728 | struct sk_buff *skb; |
| 729 | |
| 730 | hif_dev->reg_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 731 | if (hif_dev->reg_in_urb == NULL) |
| 732 | return -ENOMEM; |
| 733 | |
Ming Lei | e6c6d33 | 2010-04-13 00:29:05 +0800 | [diff] [blame] | 734 | skb = alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_KERNEL); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 735 | if (!skb) |
| 736 | goto err; |
| 737 | |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 738 | usb_fill_bulk_urb(hif_dev->reg_in_urb, hif_dev->udev, |
Rajkumar Manoharan | 0f529e9 | 2010-09-16 19:56:55 +0530 | [diff] [blame] | 739 | usb_rcvbulkpipe(hif_dev->udev, |
| 740 | USB_REG_IN_PIPE), |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 741 | skb->data, MAX_REG_IN_BUF_SIZE, |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 742 | ath9k_hif_usb_reg_in_cb, skb); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 743 | |
| 744 | if (usb_submit_urb(hif_dev->reg_in_urb, GFP_KERNEL) != 0) |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 745 | goto err; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 746 | |
| 747 | return 0; |
| 748 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 749 | err: |
| 750 | ath9k_hif_usb_dealloc_reg_in_urb(hif_dev); |
| 751 | return -ENOMEM; |
| 752 | } |
| 753 | |
| 754 | static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev) |
| 755 | { |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 756 | /* Register Write */ |
| 757 | init_usb_anchor(&hif_dev->regout_submitted); |
| 758 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 759 | /* TX */ |
| 760 | if (ath9k_hif_usb_alloc_tx_urbs(hif_dev) < 0) |
| 761 | goto err; |
| 762 | |
| 763 | /* RX */ |
| 764 | if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0) |
Rajkumar Manoharan | f803696 | 2010-07-07 15:19:18 +0530 | [diff] [blame] | 765 | goto err_rx; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 766 | |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 767 | /* Register Read */ |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 768 | if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0) |
Rajkumar Manoharan | f803696 | 2010-07-07 15:19:18 +0530 | [diff] [blame] | 769 | goto err_reg; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 770 | |
| 771 | return 0; |
Rajkumar Manoharan | f803696 | 2010-07-07 15:19:18 +0530 | [diff] [blame] | 772 | err_reg: |
| 773 | ath9k_hif_usb_dealloc_rx_urbs(hif_dev); |
| 774 | err_rx: |
| 775 | ath9k_hif_usb_dealloc_tx_urbs(hif_dev); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 776 | err: |
| 777 | return -ENOMEM; |
| 778 | } |
| 779 | |
Sujith.Manoharan@atheros.com | 1d8af8c | 2010-05-11 16:24:40 +0530 | [diff] [blame] | 780 | static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev) |
| 781 | { |
| 782 | usb_kill_anchored_urbs(&hif_dev->regout_submitted); |
| 783 | ath9k_hif_usb_dealloc_reg_in_urb(hif_dev); |
| 784 | ath9k_hif_usb_dealloc_tx_urbs(hif_dev); |
| 785 | ath9k_hif_usb_dealloc_rx_urbs(hif_dev); |
| 786 | } |
| 787 | |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 788 | static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev, |
| 789 | u32 drv_info) |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 790 | { |
| 791 | int transfer, err; |
| 792 | const void *data = hif_dev->firmware->data; |
| 793 | size_t len = hif_dev->firmware->size; |
| 794 | u32 addr = AR9271_FIRMWARE; |
| 795 | u8 *buf = kzalloc(4096, GFP_KERNEL); |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 796 | u32 firm_offset; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 797 | |
| 798 | if (!buf) |
| 799 | return -ENOMEM; |
| 800 | |
| 801 | while (len) { |
| 802 | transfer = min_t(int, len, 4096); |
| 803 | memcpy(buf, data, transfer); |
| 804 | |
| 805 | err = usb_control_msg(hif_dev->udev, |
| 806 | usb_sndctrlpipe(hif_dev->udev, 0), |
| 807 | FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT, |
| 808 | addr >> 8, 0, buf, transfer, HZ); |
| 809 | if (err < 0) { |
| 810 | kfree(buf); |
| 811 | return err; |
| 812 | } |
| 813 | |
| 814 | len -= transfer; |
| 815 | data += transfer; |
| 816 | addr += transfer; |
| 817 | } |
| 818 | kfree(buf); |
| 819 | |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 820 | if (IS_AR7010_DEVICE(drv_info)) |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 821 | firm_offset = AR7010_FIRMWARE_TEXT; |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 822 | else |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 823 | firm_offset = AR9271_FIRMWARE_TEXT; |
| 824 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 825 | /* |
| 826 | * Issue FW download complete command to firmware. |
| 827 | */ |
| 828 | err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0), |
| 829 | FIRMWARE_DOWNLOAD_COMP, |
| 830 | 0x40 | USB_DIR_OUT, |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 831 | firm_offset >> 8, 0, NULL, 0, HZ); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 832 | if (err) |
| 833 | return -EIO; |
| 834 | |
| 835 | dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n", |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 836 | hif_dev->fw_name, (unsigned long) hif_dev->firmware->size); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 837 | |
| 838 | return 0; |
| 839 | } |
| 840 | |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 841 | static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, u32 drv_info) |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 842 | { |
Rajkumar Manoharan | 4a0e8ecc | 2010-09-14 14:35:55 +0530 | [diff] [blame] | 843 | int ret, idx; |
| 844 | struct usb_host_interface *alt = &hif_dev->interface->altsetting[0]; |
| 845 | struct usb_endpoint_descriptor *endp; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 846 | |
| 847 | /* Request firmware */ |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 848 | ret = request_firmware(&hif_dev->firmware, hif_dev->fw_name, |
| 849 | &hif_dev->udev->dev); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 850 | if (ret) { |
| 851 | dev_err(&hif_dev->udev->dev, |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 852 | "ath9k_htc: Firmware - %s not found\n", hif_dev->fw_name); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 853 | goto err_fw_req; |
| 854 | } |
| 855 | |
Sujith.Manoharan@atheros.com | 1d8af8c | 2010-05-11 16:24:40 +0530 | [diff] [blame] | 856 | /* Download firmware */ |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 857 | ret = ath9k_hif_usb_download_fw(hif_dev, drv_info); |
Sujith.Manoharan@atheros.com | 1d8af8c | 2010-05-11 16:24:40 +0530 | [diff] [blame] | 858 | if (ret) { |
| 859 | dev_err(&hif_dev->udev->dev, |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 860 | "ath9k_htc: Firmware - %s download failed\n", |
| 861 | hif_dev->fw_name); |
Sujith.Manoharan@atheros.com | 1d8af8c | 2010-05-11 16:24:40 +0530 | [diff] [blame] | 862 | goto err_fw_download; |
| 863 | } |
| 864 | |
Rajkumar Manoharan | 4a0e8ecc | 2010-09-14 14:35:55 +0530 | [diff] [blame] | 865 | /* On downloading the firmware to the target, the USB descriptor of EP4 |
| 866 | * is 'patched' to change the type of the endpoint to Bulk. This will |
| 867 | * bring down CPU usage during the scan period. |
| 868 | */ |
| 869 | for (idx = 0; idx < alt->desc.bNumEndpoints; idx++) { |
| 870 | endp = &alt->endpoint[idx].desc; |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 871 | if ((endp->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) |
| 872 | == USB_ENDPOINT_XFER_INT) { |
Rajkumar Manoharan | 4a0e8ecc | 2010-09-14 14:35:55 +0530 | [diff] [blame] | 873 | endp->bmAttributes &= ~USB_ENDPOINT_XFERTYPE_MASK; |
| 874 | endp->bmAttributes |= USB_ENDPOINT_XFER_BULK; |
| 875 | endp->bInterval = 0; |
| 876 | } |
| 877 | } |
| 878 | |
Rajkumar Manoharan | 490b3f4 | 2010-11-08 12:49:12 +0530 | [diff] [blame] | 879 | /* Alloc URBs */ |
| 880 | ret = ath9k_hif_usb_alloc_urbs(hif_dev); |
| 881 | if (ret) { |
| 882 | dev_err(&hif_dev->udev->dev, |
| 883 | "ath9k_htc: Unable to allocate URBs\n"); |
| 884 | goto err_urb; |
| 885 | } |
| 886 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 887 | return 0; |
| 888 | |
Sujith.Manoharan@atheros.com | 1d8af8c | 2010-05-11 16:24:40 +0530 | [diff] [blame] | 889 | err_urb: |
Sujith Manoharan | caa0a99 | 2010-12-07 16:32:02 +0530 | [diff] [blame] | 890 | ath9k_hif_usb_dealloc_urbs(hif_dev); |
| 891 | err_fw_download: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 892 | release_firmware(hif_dev->firmware); |
| 893 | err_fw_req: |
| 894 | hif_dev->firmware = NULL; |
| 895 | return ret; |
| 896 | } |
| 897 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 898 | static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev) |
| 899 | { |
| 900 | ath9k_hif_usb_dealloc_urbs(hif_dev); |
| 901 | if (hif_dev->firmware) |
| 902 | release_firmware(hif_dev->firmware); |
| 903 | } |
| 904 | |
| 905 | static int ath9k_hif_usb_probe(struct usb_interface *interface, |
| 906 | const struct usb_device_id *id) |
| 907 | { |
| 908 | struct usb_device *udev = interface_to_usbdev(interface); |
| 909 | struct hif_device_usb *hif_dev; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 910 | int ret = 0; |
| 911 | |
| 912 | hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL); |
| 913 | if (!hif_dev) { |
| 914 | ret = -ENOMEM; |
| 915 | goto err_alloc; |
| 916 | } |
| 917 | |
| 918 | usb_get_dev(udev); |
| 919 | hif_dev->udev = udev; |
| 920 | hif_dev->interface = interface; |
| 921 | hif_dev->device_id = id->idProduct; |
| 922 | #ifdef CONFIG_PM |
| 923 | udev->reset_resume = 1; |
| 924 | #endif |
| 925 | usb_set_intfdata(interface, hif_dev); |
| 926 | |
Sujith.Manoharan@atheros.com | 47fce02 | 2010-05-11 16:24:41 +0530 | [diff] [blame] | 927 | hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb, |
| 928 | &hif_dev->udev->dev); |
| 929 | if (hif_dev->htc_handle == NULL) { |
| 930 | ret = -ENOMEM; |
| 931 | goto err_htc_hw_alloc; |
| 932 | } |
| 933 | |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 934 | /* Find out which firmware to load */ |
| 935 | |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 936 | if (IS_AR7010_DEVICE(id->driver_info)) |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 937 | if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202) |
John W. Linville | d0ee0eb | 2010-06-23 14:20:45 -0400 | [diff] [blame] | 938 | hif_dev->fw_name = FIRMWARE_AR7010_1_1; |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 939 | else |
John W. Linville | d0ee0eb | 2010-06-23 14:20:45 -0400 | [diff] [blame] | 940 | hif_dev->fw_name = FIRMWARE_AR7010; |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 941 | else |
John W. Linville | d0ee0eb | 2010-06-23 14:20:45 -0400 | [diff] [blame] | 942 | hif_dev->fw_name = FIRMWARE_AR9271; |
Sujith | ce43cee | 2010-06-02 15:53:30 +0530 | [diff] [blame] | 943 | |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 944 | ret = ath9k_hif_usb_dev_init(hif_dev, id->driver_info); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 945 | if (ret) { |
| 946 | ret = -EINVAL; |
| 947 | goto err_hif_init_usb; |
| 948 | } |
| 949 | |
Sujith.Manoharan@atheros.com | 47fce02 | 2010-05-11 16:24:41 +0530 | [diff] [blame] | 950 | ret = ath9k_htc_hw_init(hif_dev->htc_handle, |
Vivek Natarajan | 21cb987 | 2010-08-18 19:57:49 +0530 | [diff] [blame] | 951 | &hif_dev->udev->dev, hif_dev->device_id, |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 952 | hif_dev->udev->product, id->driver_info); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 953 | if (ret) { |
| 954 | ret = -EINVAL; |
| 955 | goto err_htc_hw_init; |
| 956 | } |
| 957 | |
| 958 | dev_info(&hif_dev->udev->dev, "ath9k_htc: USB layer initialized\n"); |
| 959 | |
| 960 | return 0; |
| 961 | |
| 962 | err_htc_hw_init: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 963 | ath9k_hif_usb_dev_deinit(hif_dev); |
| 964 | err_hif_init_usb: |
Sujith.Manoharan@atheros.com | 47fce02 | 2010-05-11 16:24:41 +0530 | [diff] [blame] | 965 | ath9k_htc_hw_free(hif_dev->htc_handle); |
| 966 | err_htc_hw_alloc: |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 967 | usb_set_intfdata(interface, NULL); |
| 968 | kfree(hif_dev); |
| 969 | usb_put_dev(udev); |
| 970 | err_alloc: |
| 971 | return ret; |
| 972 | } |
| 973 | |
Sujith | 62e4716 | 2010-04-23 10:28:16 +0530 | [diff] [blame] | 974 | static void ath9k_hif_usb_reboot(struct usb_device *udev) |
| 975 | { |
| 976 | u32 reboot_cmd = 0xffffffff; |
| 977 | void *buf; |
| 978 | int ret; |
| 979 | |
Julia Lawall | a465a2c | 2010-05-15 23:17:19 +0200 | [diff] [blame] | 980 | buf = kmemdup(&reboot_cmd, 4, GFP_KERNEL); |
Sujith | 62e4716 | 2010-04-23 10:28:16 +0530 | [diff] [blame] | 981 | if (!buf) |
| 982 | return; |
| 983 | |
Sujith | 62e4716 | 2010-04-23 10:28:16 +0530 | [diff] [blame] | 984 | ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE), |
| 985 | buf, 4, NULL, HZ); |
| 986 | if (ret) |
| 987 | dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n"); |
| 988 | |
| 989 | kfree(buf); |
| 990 | } |
| 991 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 992 | static void ath9k_hif_usb_disconnect(struct usb_interface *interface) |
| 993 | { |
| 994 | struct usb_device *udev = interface_to_usbdev(interface); |
Joe Perches | b276736 | 2010-11-30 13:42:08 -0800 | [diff] [blame] | 995 | struct hif_device_usb *hif_dev = usb_get_intfdata(interface); |
Sujith Manoharan | 97dcec5 | 2010-12-20 08:02:42 +0530 | [diff] [blame^] | 996 | bool unplugged = (udev->state == USB_STATE_NOTATTACHED) ? true : false; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 997 | |
| 998 | if (hif_dev) { |
Sujith Manoharan | 97dcec5 | 2010-12-20 08:02:42 +0530 | [diff] [blame^] | 999 | ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1000 | ath9k_htc_hw_free(hif_dev->htc_handle); |
| 1001 | ath9k_hif_usb_dev_deinit(hif_dev); |
| 1002 | usb_set_intfdata(interface, NULL); |
| 1003 | } |
| 1004 | |
Sujith Manoharan | 97dcec5 | 2010-12-20 08:02:42 +0530 | [diff] [blame^] | 1005 | if (!unplugged && (hif_dev->flags & HIF_USB_START)) |
Sujith | 62e4716 | 2010-04-23 10:28:16 +0530 | [diff] [blame] | 1006 | ath9k_hif_usb_reboot(udev); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1007 | |
| 1008 | kfree(hif_dev); |
| 1009 | dev_info(&udev->dev, "ath9k_htc: USB layer deinitialized\n"); |
| 1010 | usb_put_dev(udev); |
| 1011 | } |
| 1012 | |
| 1013 | #ifdef CONFIG_PM |
| 1014 | static int ath9k_hif_usb_suspend(struct usb_interface *interface, |
| 1015 | pm_message_t message) |
| 1016 | { |
Joe Perches | b276736 | 2010-11-30 13:42:08 -0800 | [diff] [blame] | 1017 | struct hif_device_usb *hif_dev = usb_get_intfdata(interface); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1018 | |
Sujith Manoharan | f933ebe | 2010-12-01 12:30:27 +0530 | [diff] [blame] | 1019 | /* |
| 1020 | * The device has to be set to FULLSLEEP mode in case no |
| 1021 | * interface is up. |
| 1022 | */ |
| 1023 | if (!(hif_dev->flags & HIF_USB_START)) |
| 1024 | ath9k_htc_suspend(hif_dev->htc_handle); |
| 1025 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1026 | ath9k_hif_usb_dealloc_urbs(hif_dev); |
| 1027 | |
| 1028 | return 0; |
| 1029 | } |
| 1030 | |
| 1031 | static int ath9k_hif_usb_resume(struct usb_interface *interface) |
| 1032 | { |
Joe Perches | b276736 | 2010-11-30 13:42:08 -0800 | [diff] [blame] | 1033 | struct hif_device_usb *hif_dev = usb_get_intfdata(interface); |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 1034 | struct htc_target *htc_handle = hif_dev->htc_handle; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1035 | int ret; |
| 1036 | |
| 1037 | ret = ath9k_hif_usb_alloc_urbs(hif_dev); |
| 1038 | if (ret) |
| 1039 | return ret; |
| 1040 | |
| 1041 | if (hif_dev->firmware) { |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 1042 | ret = ath9k_hif_usb_download_fw(hif_dev, |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 1043 | htc_handle->drv_priv->ah->hw_version.usbdev); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1044 | if (ret) |
| 1045 | goto fail_resume; |
| 1046 | } else { |
| 1047 | ath9k_hif_usb_dealloc_urbs(hif_dev); |
| 1048 | return -EIO; |
| 1049 | } |
| 1050 | |
| 1051 | mdelay(100); |
| 1052 | |
Rajkumar Manoharan | fa6e15e | 2010-11-19 16:53:22 +0530 | [diff] [blame] | 1053 | ret = ath9k_htc_resume(htc_handle); |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1054 | |
| 1055 | if (ret) |
| 1056 | goto fail_resume; |
| 1057 | |
| 1058 | return 0; |
| 1059 | |
| 1060 | fail_resume: |
| 1061 | ath9k_hif_usb_dealloc_urbs(hif_dev); |
| 1062 | |
| 1063 | return ret; |
| 1064 | } |
| 1065 | #endif |
| 1066 | |
| 1067 | static struct usb_driver ath9k_hif_usb_driver = { |
| 1068 | .name = "ath9k_hif_usb", |
| 1069 | .probe = ath9k_hif_usb_probe, |
| 1070 | .disconnect = ath9k_hif_usb_disconnect, |
| 1071 | #ifdef CONFIG_PM |
| 1072 | .suspend = ath9k_hif_usb_suspend, |
| 1073 | .resume = ath9k_hif_usb_resume, |
| 1074 | .reset_resume = ath9k_hif_usb_resume, |
| 1075 | #endif |
| 1076 | .id_table = ath9k_hif_usb_ids, |
| 1077 | .soft_unbind = 1, |
| 1078 | }; |
| 1079 | |
| 1080 | int ath9k_hif_usb_init(void) |
| 1081 | { |
| 1082 | return usb_register(&ath9k_hif_usb_driver); |
| 1083 | } |
| 1084 | |
| 1085 | void ath9k_hif_usb_exit(void) |
| 1086 | { |
| 1087 | usb_deregister(&ath9k_hif_usb_driver); |
| 1088 | } |