Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: USB specific handling |
| 3 | * |
| 4 | * Copyright (C) 2012, Marvell International Ltd. |
| 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 17 | * this warranty disclaimer. |
| 18 | */ |
| 19 | |
| 20 | #include "main.h" |
| 21 | #include "usb.h" |
| 22 | |
| 23 | #define USB_VERSION "1.0" |
| 24 | |
| 25 | static const char usbdriver_name[] = "usb8797"; |
| 26 | |
| 27 | static u8 user_rmmod; |
| 28 | static struct mwifiex_if_ops usb_ops; |
| 29 | static struct semaphore add_remove_card_sem; |
| 30 | |
| 31 | static struct usb_device_id mwifiex_usb_table[] = { |
| 32 | {USB_DEVICE(USB8797_VID, USB8797_PID_1)}, |
| 33 | {USB_DEVICE_AND_INTERFACE_INFO(USB8797_VID, USB8797_PID_2, |
| 34 | USB_CLASS_VENDOR_SPEC, |
| 35 | USB_SUBCLASS_VENDOR_SPEC, 0xff)}, |
| 36 | { } /* Terminating entry */ |
| 37 | }; |
| 38 | |
| 39 | MODULE_DEVICE_TABLE(usb, mwifiex_usb_table); |
| 40 | |
| 41 | static int mwifiex_usb_submit_rx_urb(struct urb_context *ctx, int size); |
| 42 | |
| 43 | /* This function handles received packet. Necessary action is taken based on |
| 44 | * cmd/event/data. |
| 45 | */ |
| 46 | static int mwifiex_usb_recv(struct mwifiex_adapter *adapter, |
| 47 | struct sk_buff *skb, u8 ep) |
| 48 | { |
| 49 | struct device *dev = adapter->dev; |
| 50 | u32 recv_type; |
| 51 | __le32 tmp; |
| 52 | |
| 53 | if (adapter->hs_activated) |
| 54 | mwifiex_process_hs_config(adapter); |
| 55 | |
| 56 | if (skb->len < INTF_HEADER_LEN) { |
| 57 | dev_err(dev, "%s: invalid skb->len\n", __func__); |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | switch (ep) { |
| 62 | case MWIFIEX_USB_EP_CMD_EVENT: |
| 63 | dev_dbg(dev, "%s: EP_CMD_EVENT\n", __func__); |
| 64 | skb_copy_from_linear_data(skb, &tmp, INTF_HEADER_LEN); |
| 65 | recv_type = le32_to_cpu(tmp); |
| 66 | skb_pull(skb, INTF_HEADER_LEN); |
| 67 | |
| 68 | switch (recv_type) { |
| 69 | case MWIFIEX_USB_TYPE_CMD: |
| 70 | if (skb->len > MWIFIEX_SIZE_OF_CMD_BUFFER) { |
| 71 | dev_err(dev, "CMD: skb->len too large\n"); |
| 72 | return -1; |
| 73 | } else if (!adapter->curr_cmd) { |
| 74 | dev_dbg(dev, "CMD: no curr_cmd\n"); |
| 75 | if (adapter->ps_state == PS_STATE_SLEEP_CFM) { |
| 76 | mwifiex_process_sleep_confirm_resp( |
| 77 | adapter, skb->data, |
| 78 | skb->len); |
| 79 | return 0; |
| 80 | } |
| 81 | return -1; |
| 82 | } |
| 83 | |
| 84 | adapter->curr_cmd->resp_skb = skb; |
| 85 | adapter->cmd_resp_received = true; |
| 86 | break; |
| 87 | case MWIFIEX_USB_TYPE_EVENT: |
| 88 | if (skb->len < sizeof(u32)) { |
| 89 | dev_err(dev, "EVENT: skb->len too small\n"); |
| 90 | return -1; |
| 91 | } |
| 92 | skb_copy_from_linear_data(skb, &tmp, sizeof(u32)); |
| 93 | adapter->event_cause = le32_to_cpu(tmp); |
| 94 | skb_pull(skb, sizeof(u32)); |
| 95 | dev_dbg(dev, "event_cause %#x\n", adapter->event_cause); |
| 96 | |
| 97 | if (skb->len > MAX_EVENT_SIZE) { |
| 98 | dev_err(dev, "EVENT: event body too large\n"); |
| 99 | return -1; |
| 100 | } |
| 101 | |
| 102 | skb_copy_from_linear_data(skb, adapter->event_body, |
| 103 | skb->len); |
| 104 | adapter->event_received = true; |
| 105 | adapter->event_skb = skb; |
| 106 | break; |
| 107 | default: |
| 108 | dev_err(dev, "unknown recv_type %#x\n", recv_type); |
| 109 | return -1; |
| 110 | } |
| 111 | break; |
| 112 | case MWIFIEX_USB_EP_DATA: |
| 113 | dev_dbg(dev, "%s: EP_DATA\n", __func__); |
| 114 | if (skb->len > MWIFIEX_RX_DATA_BUF_SIZE) { |
| 115 | dev_err(dev, "DATA: skb->len too large\n"); |
| 116 | return -1; |
| 117 | } |
| 118 | skb_queue_tail(&adapter->usb_rx_data_q, skb); |
| 119 | adapter->data_received = true; |
| 120 | break; |
| 121 | default: |
| 122 | dev_err(dev, "%s: unknown endport %#x\n", __func__, ep); |
| 123 | return -1; |
| 124 | } |
| 125 | |
| 126 | return -EINPROGRESS; |
| 127 | } |
| 128 | |
| 129 | static void mwifiex_usb_rx_complete(struct urb *urb) |
| 130 | { |
| 131 | struct urb_context *context = (struct urb_context *)urb->context; |
| 132 | struct mwifiex_adapter *adapter = context->adapter; |
| 133 | struct sk_buff *skb = context->skb; |
| 134 | struct usb_card_rec *card; |
| 135 | int recv_length = urb->actual_length; |
| 136 | int size, status; |
| 137 | |
| 138 | if (!adapter || !adapter->card) { |
| 139 | pr_err("mwifiex adapter or card structure is not valid\n"); |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | card = (struct usb_card_rec *)adapter->card; |
| 144 | if (card->rx_cmd_ep == context->ep) |
| 145 | atomic_dec(&card->rx_cmd_urb_pending); |
| 146 | else |
| 147 | atomic_dec(&card->rx_data_urb_pending); |
| 148 | |
| 149 | if (recv_length) { |
| 150 | if (urb->status || (adapter->surprise_removed)) { |
| 151 | dev_err(adapter->dev, |
| 152 | "URB status is failed: %d\n", urb->status); |
| 153 | /* Do not free skb in case of command ep */ |
| 154 | if (card->rx_cmd_ep != context->ep) |
| 155 | dev_kfree_skb_any(skb); |
| 156 | goto setup_for_next; |
| 157 | } |
| 158 | if (skb->len > recv_length) |
| 159 | skb_trim(skb, recv_length); |
| 160 | else |
| 161 | skb_put(skb, recv_length - skb->len); |
| 162 | |
| 163 | atomic_inc(&adapter->rx_pending); |
| 164 | status = mwifiex_usb_recv(adapter, skb, context->ep); |
| 165 | |
| 166 | dev_dbg(adapter->dev, "info: recv_length=%d, status=%d\n", |
| 167 | recv_length, status); |
| 168 | if (status == -EINPROGRESS) { |
| 169 | queue_work(adapter->workqueue, &adapter->main_work); |
| 170 | |
| 171 | /* urb for data_ep is re-submitted now; |
| 172 | * urb for cmd_ep will be re-submitted in callback |
| 173 | * mwifiex_usb_recv_complete |
| 174 | */ |
| 175 | if (card->rx_cmd_ep == context->ep) |
| 176 | return; |
| 177 | } else { |
| 178 | atomic_dec(&adapter->rx_pending); |
| 179 | if (status == -1) |
| 180 | dev_err(adapter->dev, |
| 181 | "received data processing failed!\n"); |
| 182 | |
| 183 | /* Do not free skb in case of command ep */ |
| 184 | if (card->rx_cmd_ep != context->ep) |
| 185 | dev_kfree_skb_any(skb); |
| 186 | } |
| 187 | } else if (urb->status) { |
| 188 | if (!adapter->is_suspended) { |
| 189 | dev_warn(adapter->dev, |
| 190 | "Card is removed: %d\n", urb->status); |
| 191 | adapter->surprise_removed = true; |
| 192 | } |
| 193 | dev_kfree_skb_any(skb); |
| 194 | return; |
| 195 | } else { |
| 196 | /* Do not free skb in case of command ep */ |
| 197 | if (card->rx_cmd_ep != context->ep) |
| 198 | dev_kfree_skb_any(skb); |
| 199 | |
| 200 | /* fall through setup_for_next */ |
| 201 | } |
| 202 | |
| 203 | setup_for_next: |
| 204 | if (card->rx_cmd_ep == context->ep) |
| 205 | size = MWIFIEX_RX_CMD_BUF_SIZE; |
| 206 | else |
| 207 | size = MWIFIEX_RX_DATA_BUF_SIZE; |
| 208 | |
| 209 | mwifiex_usb_submit_rx_urb(context, size); |
| 210 | |
| 211 | return; |
| 212 | } |
| 213 | |
| 214 | static void mwifiex_usb_tx_complete(struct urb *urb) |
| 215 | { |
| 216 | struct urb_context *context = (struct urb_context *)(urb->context); |
| 217 | struct mwifiex_adapter *adapter = context->adapter; |
| 218 | struct usb_card_rec *card = adapter->card; |
| 219 | |
| 220 | dev_dbg(adapter->dev, "%s: status: %d\n", __func__, urb->status); |
| 221 | |
| 222 | if (context->ep == card->tx_cmd_ep) { |
| 223 | dev_dbg(adapter->dev, "%s: CMD\n", __func__); |
| 224 | atomic_dec(&card->tx_cmd_urb_pending); |
| 225 | adapter->cmd_sent = false; |
| 226 | } else { |
| 227 | dev_dbg(adapter->dev, "%s: DATA\n", __func__); |
| 228 | atomic_dec(&card->tx_data_urb_pending); |
| 229 | mwifiex_write_data_complete(adapter, context->skb, |
| 230 | urb->status ? -1 : 0); |
| 231 | } |
| 232 | |
| 233 | queue_work(adapter->workqueue, &adapter->main_work); |
| 234 | |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | static int mwifiex_usb_submit_rx_urb(struct urb_context *ctx, int size) |
| 239 | { |
| 240 | struct mwifiex_adapter *adapter = ctx->adapter; |
| 241 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 242 | |
| 243 | if (card->rx_cmd_ep != ctx->ep) { |
| 244 | ctx->skb = dev_alloc_skb(size); |
| 245 | if (!ctx->skb) { |
| 246 | dev_err(adapter->dev, |
| 247 | "%s: dev_alloc_skb failed\n", __func__); |
| 248 | return -ENOMEM; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | usb_fill_bulk_urb(ctx->urb, card->udev, |
| 253 | usb_rcvbulkpipe(card->udev, ctx->ep), ctx->skb->data, |
| 254 | size, mwifiex_usb_rx_complete, (void *)ctx); |
| 255 | |
| 256 | if (card->rx_cmd_ep == ctx->ep) |
| 257 | atomic_inc(&card->rx_cmd_urb_pending); |
| 258 | else |
| 259 | atomic_inc(&card->rx_data_urb_pending); |
| 260 | |
| 261 | if (usb_submit_urb(ctx->urb, GFP_ATOMIC)) { |
| 262 | dev_err(adapter->dev, "usb_submit_urb failed\n"); |
| 263 | dev_kfree_skb_any(ctx->skb); |
| 264 | ctx->skb = NULL; |
| 265 | |
| 266 | if (card->rx_cmd_ep == ctx->ep) |
| 267 | atomic_dec(&card->rx_cmd_urb_pending); |
| 268 | else |
| 269 | atomic_dec(&card->rx_data_urb_pending); |
| 270 | |
| 271 | return -1; |
| 272 | } |
| 273 | |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | static void mwifiex_usb_free(struct usb_card_rec *card) |
| 278 | { |
| 279 | int i; |
| 280 | |
| 281 | if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb) |
| 282 | usb_kill_urb(card->rx_cmd.urb); |
| 283 | |
| 284 | usb_free_urb(card->rx_cmd.urb); |
| 285 | card->rx_cmd.urb = NULL; |
| 286 | |
| 287 | if (atomic_read(&card->rx_data_urb_pending)) |
| 288 | for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) |
| 289 | if (card->rx_data_list[i].urb) |
| 290 | usb_kill_urb(card->rx_data_list[i].urb); |
| 291 | |
| 292 | for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) { |
| 293 | usb_free_urb(card->rx_data_list[i].urb); |
| 294 | card->rx_data_list[i].urb = NULL; |
| 295 | } |
| 296 | |
| 297 | for (i = 0; i < MWIFIEX_TX_DATA_URB; i++) { |
| 298 | usb_free_urb(card->tx_data_list[i].urb); |
| 299 | card->tx_data_list[i].urb = NULL; |
| 300 | } |
| 301 | |
| 302 | usb_free_urb(card->tx_cmd.urb); |
| 303 | card->tx_cmd.urb = NULL; |
| 304 | |
| 305 | return; |
| 306 | } |
| 307 | |
| 308 | /* This function probes an mwifiex device and registers it. It allocates |
| 309 | * the card structure, initiates the device registration and initialization |
| 310 | * procedure by adding a logical interface. |
| 311 | */ |
| 312 | static int mwifiex_usb_probe(struct usb_interface *intf, |
| 313 | const struct usb_device_id *id) |
| 314 | { |
| 315 | struct usb_device *udev = interface_to_usbdev(intf); |
| 316 | struct usb_host_interface *iface_desc = intf->cur_altsetting; |
| 317 | struct usb_endpoint_descriptor *epd; |
| 318 | int ret, i; |
| 319 | struct usb_card_rec *card; |
| 320 | u16 id_vendor, id_product, bcd_device, bcd_usb; |
| 321 | |
| 322 | card = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); |
| 323 | if (!card) |
| 324 | return -ENOMEM; |
| 325 | |
| 326 | id_vendor = le16_to_cpu(udev->descriptor.idVendor); |
| 327 | id_product = le16_to_cpu(udev->descriptor.idProduct); |
| 328 | bcd_device = le16_to_cpu(udev->descriptor.bcdDevice); |
| 329 | bcd_usb = le16_to_cpu(udev->descriptor.bcdUSB); |
| 330 | pr_debug("info: VID/PID = %X/%X, Boot2 version = %X\n", |
| 331 | id_vendor, id_product, bcd_device); |
| 332 | |
| 333 | /* PID_1 is used for firmware downloading only */ |
| 334 | if (id_product == USB8797_PID_1) |
| 335 | card->usb_boot_state = USB8797_FW_DNLD; |
| 336 | else |
| 337 | card->usb_boot_state = USB8797_FW_READY; |
| 338 | |
| 339 | card->udev = udev; |
| 340 | card->intf = intf; |
| 341 | |
| 342 | pr_debug("info: bcdUSB=%#x Device Class=%#x SubClass=%#x Protocl=%#x\n", |
| 343 | udev->descriptor.bcdUSB, udev->descriptor.bDeviceClass, |
| 344 | udev->descriptor.bDeviceSubClass, |
| 345 | udev->descriptor.bDeviceProtocol); |
| 346 | |
| 347 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
| 348 | epd = &iface_desc->endpoint[i].desc; |
| 349 | if (usb_endpoint_dir_in(epd) && |
| 350 | usb_endpoint_num(epd) == MWIFIEX_USB_EP_CMD_EVENT && |
| 351 | usb_endpoint_xfer_bulk(epd)) { |
| 352 | pr_debug("info: bulk IN: max pkt size: %d, addr: %d\n", |
| 353 | le16_to_cpu(epd->wMaxPacketSize), |
| 354 | epd->bEndpointAddress); |
| 355 | card->rx_cmd_ep = usb_endpoint_num(epd); |
| 356 | atomic_set(&card->rx_cmd_urb_pending, 0); |
| 357 | } |
| 358 | if (usb_endpoint_dir_in(epd) && |
| 359 | usb_endpoint_num(epd) == MWIFIEX_USB_EP_DATA && |
| 360 | usb_endpoint_xfer_bulk(epd)) { |
| 361 | pr_debug("info: bulk IN: max pkt size: %d, addr: %d\n", |
| 362 | le16_to_cpu(epd->wMaxPacketSize), |
| 363 | epd->bEndpointAddress); |
| 364 | card->rx_data_ep = usb_endpoint_num(epd); |
| 365 | atomic_set(&card->rx_data_urb_pending, 0); |
| 366 | } |
| 367 | if (usb_endpoint_dir_out(epd) && |
| 368 | usb_endpoint_num(epd) == MWIFIEX_USB_EP_DATA && |
| 369 | usb_endpoint_xfer_bulk(epd)) { |
| 370 | pr_debug("info: bulk OUT: max pkt size: %d, addr: %d\n", |
| 371 | le16_to_cpu(epd->wMaxPacketSize), |
| 372 | epd->bEndpointAddress); |
| 373 | card->tx_data_ep = usb_endpoint_num(epd); |
| 374 | atomic_set(&card->tx_data_urb_pending, 0); |
| 375 | } |
| 376 | if (usb_endpoint_dir_out(epd) && |
| 377 | usb_endpoint_num(epd) == MWIFIEX_USB_EP_CMD_EVENT && |
| 378 | usb_endpoint_xfer_bulk(epd)) { |
| 379 | pr_debug("info: bulk OUT: max pkt size: %d, addr: %d\n", |
| 380 | le16_to_cpu(epd->wMaxPacketSize), |
| 381 | epd->bEndpointAddress); |
| 382 | card->tx_cmd_ep = usb_endpoint_num(epd); |
| 383 | atomic_set(&card->tx_cmd_urb_pending, 0); |
| 384 | card->bulk_out_maxpktsize = |
| 385 | le16_to_cpu(epd->wMaxPacketSize); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | usb_set_intfdata(intf, card); |
| 390 | |
| 391 | ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops, |
| 392 | MWIFIEX_USB); |
| 393 | if (ret) { |
| 394 | pr_err("%s: mwifiex_add_card failed: %d\n", __func__, ret); |
| 395 | usb_reset_device(udev); |
| 396 | kfree(card); |
| 397 | return ret; |
| 398 | } |
| 399 | |
| 400 | usb_get_dev(udev); |
| 401 | |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | /* Kernel needs to suspend all functions separately. Therefore all |
| 406 | * registered functions must have drivers with suspend and resume |
| 407 | * methods. Failing that the kernel simply removes the whole card. |
| 408 | * |
| 409 | * If already not suspended, this function allocates and sends a |
| 410 | * 'host sleep activate' request to the firmware and turns off the traffic. |
| 411 | */ |
| 412 | static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message) |
| 413 | { |
| 414 | struct usb_card_rec *card = usb_get_intfdata(intf); |
| 415 | struct mwifiex_adapter *adapter; |
| 416 | int i; |
| 417 | |
| 418 | if (!card || !card->adapter) { |
| 419 | pr_err("%s: card or card->adapter is NULL\n", __func__); |
| 420 | return 0; |
| 421 | } |
| 422 | adapter = card->adapter; |
| 423 | |
| 424 | if (unlikely(adapter->is_suspended)) |
| 425 | dev_warn(adapter->dev, "Device already suspended\n"); |
| 426 | |
| 427 | mwifiex_enable_hs(adapter); |
| 428 | |
| 429 | /* 'is_suspended' flag indicates device is suspended. |
| 430 | * It must be set here before the usb_kill_urb() calls. Reason |
| 431 | * is in the complete handlers, urb->status(= -ENOENT) and |
| 432 | * this flag is used in combination to distinguish between a |
| 433 | * 'suspended' state and a 'disconnect' one. |
| 434 | */ |
| 435 | adapter->is_suspended = true; |
| 436 | |
| 437 | for (i = 0; i < adapter->priv_num; i++) |
| 438 | netif_carrier_off(adapter->priv[i]->netdev); |
| 439 | |
| 440 | if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb) |
| 441 | usb_kill_urb(card->rx_cmd.urb); |
| 442 | |
| 443 | if (atomic_read(&card->rx_data_urb_pending)) |
| 444 | for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) |
| 445 | if (card->rx_data_list[i].urb) |
| 446 | usb_kill_urb(card->rx_data_list[i].urb); |
| 447 | |
| 448 | for (i = 0; i < MWIFIEX_TX_DATA_URB; i++) |
| 449 | if (card->tx_data_list[i].urb) |
| 450 | usb_kill_urb(card->tx_data_list[i].urb); |
| 451 | |
| 452 | if (card->tx_cmd.urb) |
| 453 | usb_kill_urb(card->tx_cmd.urb); |
| 454 | |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | /* Kernel needs to suspend all functions separately. Therefore all |
| 459 | * registered functions must have drivers with suspend and resume |
| 460 | * methods. Failing that the kernel simply removes the whole card. |
| 461 | * |
| 462 | * If already not resumed, this function turns on the traffic and |
| 463 | * sends a 'host sleep cancel' request to the firmware. |
| 464 | */ |
| 465 | static int mwifiex_usb_resume(struct usb_interface *intf) |
| 466 | { |
| 467 | struct usb_card_rec *card = usb_get_intfdata(intf); |
| 468 | struct mwifiex_adapter *adapter; |
| 469 | int i; |
| 470 | |
| 471 | if (!card || !card->adapter) { |
| 472 | pr_err("%s: card or card->adapter is NULL\n", __func__); |
| 473 | return 0; |
| 474 | } |
| 475 | adapter = card->adapter; |
| 476 | |
| 477 | if (unlikely(!adapter->is_suspended)) { |
| 478 | dev_warn(adapter->dev, "Device already resumed\n"); |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | /* Indicate device resumed. The netdev queue will be resumed only |
| 483 | * after the urbs have been re-submitted |
| 484 | */ |
| 485 | adapter->is_suspended = false; |
| 486 | |
| 487 | if (!atomic_read(&card->rx_data_urb_pending)) |
| 488 | for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) |
| 489 | mwifiex_usb_submit_rx_urb(&card->rx_data_list[i], |
| 490 | MWIFIEX_RX_DATA_BUF_SIZE); |
| 491 | |
| 492 | if (!atomic_read(&card->rx_cmd_urb_pending)) { |
| 493 | card->rx_cmd.skb = dev_alloc_skb(MWIFIEX_RX_CMD_BUF_SIZE); |
| 494 | if (card->rx_cmd.skb) |
| 495 | mwifiex_usb_submit_rx_urb(&card->rx_cmd, |
| 496 | MWIFIEX_RX_CMD_BUF_SIZE); |
| 497 | } |
| 498 | |
| 499 | for (i = 0; i < adapter->priv_num; i++) |
| 500 | if (adapter->priv[i]->media_connected) |
| 501 | netif_carrier_on(adapter->priv[i]->netdev); |
| 502 | |
| 503 | /* Disable Host Sleep */ |
| 504 | if (adapter->hs_activated) |
| 505 | mwifiex_cancel_hs(mwifiex_get_priv(adapter, |
| 506 | MWIFIEX_BSS_ROLE_ANY), |
| 507 | MWIFIEX_ASYNC_CMD); |
| 508 | |
| 509 | #ifdef CONFIG_PM |
| 510 | /* Resume handler may be called due to remote wakeup, |
| 511 | * force to exit suspend anyway |
| 512 | */ |
| 513 | usb_disable_autosuspend(card->udev); |
| 514 | #endif /* CONFIG_PM */ |
| 515 | |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | static void mwifiex_usb_disconnect(struct usb_interface *intf) |
| 520 | { |
| 521 | struct usb_card_rec *card = usb_get_intfdata(intf); |
| 522 | struct mwifiex_adapter *adapter; |
| 523 | int i; |
| 524 | |
| 525 | if (!card || !card->adapter) { |
| 526 | pr_err("%s: card or card->adapter is NULL\n", __func__); |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | adapter = card->adapter; |
| 531 | if (!adapter->priv_num) |
| 532 | return; |
| 533 | |
| 534 | /* In case driver is removed when asynchronous FW downloading is |
| 535 | * in progress |
| 536 | */ |
| 537 | wait_for_completion(&adapter->fw_load); |
| 538 | |
| 539 | if (user_rmmod) { |
| 540 | #ifdef CONFIG_PM |
| 541 | if (adapter->is_suspended) |
| 542 | mwifiex_usb_resume(intf); |
| 543 | #endif |
| 544 | for (i = 0; i < adapter->priv_num; i++) |
| 545 | if ((GET_BSS_ROLE(adapter->priv[i]) == |
| 546 | MWIFIEX_BSS_ROLE_STA) && |
| 547 | adapter->priv[i]->media_connected) |
| 548 | mwifiex_deauthenticate(adapter->priv[i], NULL); |
| 549 | |
| 550 | mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, |
| 551 | MWIFIEX_BSS_ROLE_ANY), |
| 552 | MWIFIEX_FUNC_SHUTDOWN); |
| 553 | } |
| 554 | |
| 555 | mwifiex_usb_free(card); |
| 556 | |
| 557 | dev_dbg(adapter->dev, "%s: removing card\n", __func__); |
| 558 | mwifiex_remove_card(adapter, &add_remove_card_sem); |
| 559 | |
| 560 | usb_set_intfdata(intf, NULL); |
| 561 | usb_put_dev(interface_to_usbdev(intf)); |
| 562 | kfree(card); |
| 563 | |
| 564 | return; |
| 565 | } |
| 566 | |
| 567 | static struct usb_driver mwifiex_usb_driver = { |
| 568 | .name = usbdriver_name, |
| 569 | .probe = mwifiex_usb_probe, |
| 570 | .disconnect = mwifiex_usb_disconnect, |
| 571 | .id_table = mwifiex_usb_table, |
| 572 | .suspend = mwifiex_usb_suspend, |
| 573 | .resume = mwifiex_usb_resume, |
| 574 | .supports_autosuspend = 1, |
| 575 | }; |
| 576 | |
| 577 | static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter) |
| 578 | { |
| 579 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 580 | int i; |
| 581 | |
| 582 | card->tx_cmd.adapter = adapter; |
| 583 | card->tx_cmd.ep = card->tx_cmd_ep; |
| 584 | |
| 585 | card->tx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL); |
| 586 | if (!card->tx_cmd.urb) { |
| 587 | dev_err(adapter->dev, "tx_cmd.urb allocation failed\n"); |
| 588 | return -ENOMEM; |
| 589 | } |
| 590 | |
| 591 | card->tx_data_ix = 0; |
| 592 | |
| 593 | for (i = 0; i < MWIFIEX_TX_DATA_URB; i++) { |
| 594 | card->tx_data_list[i].adapter = adapter; |
| 595 | card->tx_data_list[i].ep = card->tx_data_ep; |
| 596 | |
| 597 | card->tx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL); |
| 598 | if (!card->tx_data_list[i].urb) { |
| 599 | dev_err(adapter->dev, |
| 600 | "tx_data_list[] urb allocation failed\n"); |
| 601 | return -ENOMEM; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | return 0; |
| 606 | } |
| 607 | |
| 608 | static int mwifiex_usb_rx_init(struct mwifiex_adapter *adapter) |
| 609 | { |
| 610 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 611 | int i; |
| 612 | |
| 613 | card->rx_cmd.adapter = adapter; |
| 614 | card->rx_cmd.ep = card->rx_cmd_ep; |
| 615 | |
| 616 | card->rx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL); |
| 617 | if (!card->rx_cmd.urb) { |
| 618 | dev_err(adapter->dev, "rx_cmd.urb allocation failed\n"); |
| 619 | return -ENOMEM; |
| 620 | } |
| 621 | |
| 622 | card->rx_cmd.skb = dev_alloc_skb(MWIFIEX_RX_CMD_BUF_SIZE); |
| 623 | if (!card->rx_cmd.skb) { |
| 624 | dev_err(adapter->dev, "rx_cmd.skb allocation failed\n"); |
| 625 | return -ENOMEM; |
| 626 | } |
| 627 | |
| 628 | if (mwifiex_usb_submit_rx_urb(&card->rx_cmd, MWIFIEX_RX_CMD_BUF_SIZE)) |
| 629 | return -1; |
| 630 | |
| 631 | for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) { |
| 632 | card->rx_data_list[i].adapter = adapter; |
| 633 | card->rx_data_list[i].ep = card->rx_data_ep; |
| 634 | |
| 635 | card->rx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL); |
| 636 | if (!card->rx_data_list[i].urb) { |
| 637 | dev_err(adapter->dev, |
| 638 | "rx_data_list[] urb allocation failed\n"); |
| 639 | return -1; |
| 640 | } |
| 641 | if (mwifiex_usb_submit_rx_urb(&card->rx_data_list[i], |
| 642 | MWIFIEX_RX_DATA_BUF_SIZE)) |
| 643 | return -1; |
| 644 | } |
| 645 | |
| 646 | return 0; |
| 647 | } |
| 648 | |
| 649 | static int mwifiex_write_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf, |
| 650 | u32 *len, u8 ep, u32 timeout) |
| 651 | { |
| 652 | struct usb_card_rec *card = adapter->card; |
| 653 | int actual_length, ret; |
| 654 | |
| 655 | if (!(*len % card->bulk_out_maxpktsize)) |
| 656 | (*len)++; |
| 657 | |
| 658 | /* Send the data block */ |
| 659 | ret = usb_bulk_msg(card->udev, usb_sndbulkpipe(card->udev, ep), pbuf, |
| 660 | *len, &actual_length, timeout); |
| 661 | if (ret) { |
| 662 | dev_err(adapter->dev, "usb_bulk_msg for tx failed: %d\n", ret); |
| 663 | ret = -1; |
| 664 | } |
| 665 | |
| 666 | *len = actual_length; |
| 667 | |
| 668 | return ret; |
| 669 | } |
| 670 | |
| 671 | static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf, |
| 672 | u32 *len, u8 ep, u32 timeout) |
| 673 | { |
| 674 | struct usb_card_rec *card = adapter->card; |
| 675 | int actual_length, ret; |
| 676 | |
| 677 | /* Receive the data response */ |
| 678 | ret = usb_bulk_msg(card->udev, usb_rcvbulkpipe(card->udev, ep), pbuf, |
| 679 | *len, &actual_length, timeout); |
| 680 | if (ret) { |
| 681 | dev_err(adapter->dev, "usb_bulk_msg for rx failed: %d\n", ret); |
| 682 | ret = -1; |
| 683 | } |
| 684 | |
| 685 | *len = actual_length; |
| 686 | |
| 687 | return ret; |
| 688 | } |
| 689 | |
| 690 | /* This function write a command/data packet to card. */ |
| 691 | static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep, |
| 692 | struct sk_buff *skb, |
| 693 | struct mwifiex_tx_param *tx_param) |
| 694 | { |
| 695 | struct usb_card_rec *card = adapter->card; |
| 696 | struct urb_context *context; |
| 697 | u8 *data = (u8 *)skb->data; |
| 698 | struct urb *tx_urb; |
| 699 | |
| 700 | if (adapter->is_suspended) { |
| 701 | dev_err(adapter->dev, |
| 702 | "%s: not allowed while suspended\n", __func__); |
| 703 | return -1; |
| 704 | } |
| 705 | |
| 706 | if (adapter->surprise_removed) { |
| 707 | dev_err(adapter->dev, "%s: device removed\n", __func__); |
| 708 | return -1; |
| 709 | } |
| 710 | |
| 711 | if (ep == card->tx_data_ep && |
| 712 | atomic_read(&card->tx_data_urb_pending) >= MWIFIEX_TX_DATA_URB) { |
| 713 | return -EBUSY; |
| 714 | } |
| 715 | |
| 716 | dev_dbg(adapter->dev, "%s: ep=%d\n", __func__, ep); |
| 717 | |
| 718 | if (ep == card->tx_cmd_ep) { |
| 719 | context = &card->tx_cmd; |
| 720 | } else { |
| 721 | if (card->tx_data_ix >= MWIFIEX_TX_DATA_URB) |
| 722 | card->tx_data_ix = 0; |
| 723 | context = &card->tx_data_list[card->tx_data_ix++]; |
| 724 | } |
| 725 | |
| 726 | context->adapter = adapter; |
| 727 | context->ep = ep; |
| 728 | context->skb = skb; |
| 729 | tx_urb = context->urb; |
| 730 | |
| 731 | usb_fill_bulk_urb(tx_urb, card->udev, usb_sndbulkpipe(card->udev, ep), |
| 732 | data, skb->len, mwifiex_usb_tx_complete, |
| 733 | (void *)context); |
| 734 | |
| 735 | tx_urb->transfer_flags |= URB_ZERO_PACKET; |
| 736 | |
| 737 | if (ep == card->tx_cmd_ep) |
| 738 | atomic_inc(&card->tx_cmd_urb_pending); |
| 739 | else |
| 740 | atomic_inc(&card->tx_data_urb_pending); |
| 741 | |
| 742 | if (usb_submit_urb(tx_urb, GFP_ATOMIC)) { |
| 743 | dev_err(adapter->dev, "%s: usb_submit_urb failed\n", __func__); |
| 744 | if (ep == card->tx_cmd_ep) { |
| 745 | atomic_dec(&card->tx_cmd_urb_pending); |
| 746 | } else { |
| 747 | atomic_dec(&card->tx_data_urb_pending); |
| 748 | if (card->tx_data_ix) |
| 749 | card->tx_data_ix--; |
| 750 | else |
| 751 | card->tx_data_ix = MWIFIEX_TX_DATA_URB; |
| 752 | } |
| 753 | |
| 754 | return -1; |
| 755 | } else { |
| 756 | if (ep == card->tx_data_ep && |
| 757 | atomic_read(&card->tx_data_urb_pending) == |
| 758 | MWIFIEX_TX_DATA_URB) |
| 759 | return -ENOSR; |
| 760 | } |
| 761 | |
| 762 | return -EINPROGRESS; |
| 763 | } |
| 764 | |
| 765 | /* This function register usb device and initialize parameter. */ |
| 766 | static int mwifiex_register_dev(struct mwifiex_adapter *adapter) |
| 767 | { |
| 768 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 769 | |
| 770 | card->adapter = adapter; |
| 771 | adapter->dev = &card->udev->dev; |
| 772 | strcpy(adapter->fw_name, USB8797_DEFAULT_FW_NAME); |
| 773 | |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | /* This function reads one block of firmware data. */ |
| 778 | static int mwifiex_get_fw_data(struct mwifiex_adapter *adapter, |
| 779 | u32 offset, u32 len, u8 *buf) |
| 780 | { |
| 781 | if (!buf || !len) |
| 782 | return -1; |
| 783 | |
| 784 | if (offset + len > adapter->firmware->size) |
| 785 | return -1; |
| 786 | |
| 787 | memcpy(buf, adapter->firmware->data + offset, len); |
| 788 | |
| 789 | return 0; |
| 790 | } |
| 791 | |
| 792 | static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, |
| 793 | struct mwifiex_fw_image *fw) |
| 794 | { |
| 795 | int ret = 0; |
| 796 | u8 *firmware = fw->fw_buf, *recv_buff; |
| 797 | u32 retries = USB8797_FW_MAX_RETRY, dlen; |
| 798 | u32 fw_seqnum = 0, tlen = 0, dnld_cmd = 0; |
| 799 | struct fw_data *fwdata; |
| 800 | struct fw_sync_header sync_fw; |
| 801 | u8 check_winner = 1; |
| 802 | |
| 803 | if (!firmware) { |
| 804 | dev_err(adapter->dev, |
| 805 | "No firmware image found! Terminating download\n"); |
| 806 | ret = -1; |
| 807 | goto fw_exit; |
| 808 | } |
| 809 | |
| 810 | /* Allocate memory for transmit */ |
| 811 | fwdata = kzalloc(FW_DNLD_TX_BUF_SIZE, GFP_KERNEL); |
| 812 | if (!fwdata) |
| 813 | goto fw_exit; |
| 814 | |
| 815 | /* Allocate memory for receive */ |
| 816 | recv_buff = kzalloc(FW_DNLD_RX_BUF_SIZE, GFP_KERNEL); |
| 817 | if (!recv_buff) |
| 818 | goto cleanup; |
| 819 | |
| 820 | do { |
| 821 | /* Send pseudo data to check winner status first */ |
| 822 | if (check_winner) { |
| 823 | memset(&fwdata->fw_hdr, 0, sizeof(struct fw_header)); |
| 824 | dlen = 0; |
| 825 | } else { |
| 826 | /* copy the header of the fw_data to get the length */ |
| 827 | if (firmware) |
| 828 | memcpy(&fwdata->fw_hdr, &firmware[tlen], |
| 829 | sizeof(struct fw_header)); |
| 830 | else |
| 831 | mwifiex_get_fw_data(adapter, tlen, |
| 832 | sizeof(struct fw_header), |
| 833 | (u8 *)&fwdata->fw_hdr); |
| 834 | |
| 835 | dlen = le32_to_cpu(fwdata->fw_hdr.data_len); |
| 836 | dnld_cmd = le32_to_cpu(fwdata->fw_hdr.dnld_cmd); |
| 837 | tlen += sizeof(struct fw_header); |
| 838 | |
| 839 | if (firmware) |
| 840 | memcpy(fwdata->data, &firmware[tlen], dlen); |
| 841 | else |
| 842 | mwifiex_get_fw_data(adapter, tlen, dlen, |
| 843 | (u8 *)fwdata->data); |
| 844 | |
| 845 | fwdata->seq_num = cpu_to_le32(fw_seqnum); |
| 846 | tlen += dlen; |
| 847 | } |
| 848 | |
| 849 | /* If the send/receive fails or CRC occurs then retry */ |
| 850 | while (retries--) { |
| 851 | u8 *buf = (u8 *)fwdata; |
| 852 | u32 len = FW_DATA_XMIT_SIZE; |
| 853 | |
| 854 | /* send the firmware block */ |
| 855 | ret = mwifiex_write_data_sync(adapter, buf, &len, |
| 856 | MWIFIEX_USB_EP_CMD_EVENT, |
| 857 | MWIFIEX_USB_TIMEOUT); |
| 858 | if (ret) { |
| 859 | dev_err(adapter->dev, |
| 860 | "write_data_sync: failed: %d\n", ret); |
| 861 | continue; |
| 862 | } |
| 863 | |
| 864 | buf = recv_buff; |
| 865 | len = FW_DNLD_RX_BUF_SIZE; |
| 866 | |
| 867 | /* Receive the firmware block response */ |
| 868 | ret = mwifiex_read_data_sync(adapter, buf, &len, |
| 869 | MWIFIEX_USB_EP_CMD_EVENT, |
| 870 | MWIFIEX_USB_TIMEOUT); |
| 871 | if (ret) { |
| 872 | dev_err(adapter->dev, |
| 873 | "read_data_sync: failed: %d\n", ret); |
| 874 | continue; |
| 875 | } |
| 876 | |
| 877 | memcpy(&sync_fw, recv_buff, |
| 878 | sizeof(struct fw_sync_header)); |
| 879 | |
| 880 | /* check 1st firmware block resp for highest bit set */ |
| 881 | if (check_winner) { |
| 882 | if (le32_to_cpu(sync_fw.cmd) & 0x80000000) { |
| 883 | dev_warn(adapter->dev, |
| 884 | "USB is not the winner %#x\n", |
| 885 | sync_fw.cmd); |
| 886 | |
| 887 | /* returning success */ |
| 888 | ret = 0; |
| 889 | goto cleanup; |
| 890 | } |
| 891 | |
| 892 | dev_dbg(adapter->dev, |
| 893 | "USB is the winner, start to download FW\n"); |
| 894 | |
| 895 | check_winner = 0; |
| 896 | break; |
| 897 | } |
| 898 | |
| 899 | /* check the firmware block response for CRC errors */ |
| 900 | if (sync_fw.cmd) { |
| 901 | dev_err(adapter->dev, |
| 902 | "FW received block with CRC %#x\n", |
| 903 | sync_fw.cmd); |
| 904 | ret = -1; |
| 905 | continue; |
| 906 | } |
| 907 | |
| 908 | retries = USB8797_FW_MAX_RETRY; |
| 909 | break; |
| 910 | } |
| 911 | fw_seqnum++; |
| 912 | } while ((dnld_cmd != FW_HAS_LAST_BLOCK) && retries); |
| 913 | |
| 914 | cleanup: |
| 915 | dev_dbg(adapter->dev, "%s: %d bytes downloaded\n", __func__, tlen); |
| 916 | |
| 917 | kfree(recv_buff); |
| 918 | kfree(fwdata); |
| 919 | |
| 920 | if (retries) |
| 921 | ret = 0; |
| 922 | fw_exit: |
| 923 | return ret; |
| 924 | } |
| 925 | |
| 926 | static int mwifiex_usb_dnld_fw(struct mwifiex_adapter *adapter, |
| 927 | struct mwifiex_fw_image *fw) |
| 928 | { |
| 929 | int ret; |
| 930 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 931 | |
| 932 | if (card->usb_boot_state == USB8797_FW_DNLD) { |
| 933 | ret = mwifiex_prog_fw_w_helper(adapter, fw); |
| 934 | if (ret) |
| 935 | return -1; |
| 936 | |
| 937 | /* Boot state changes after successful firmware download */ |
| 938 | if (card->usb_boot_state == USB8797_FW_DNLD) |
| 939 | return -1; |
| 940 | } |
| 941 | |
| 942 | ret = mwifiex_usb_rx_init(adapter); |
| 943 | if (!ret) |
| 944 | ret = mwifiex_usb_tx_init(adapter); |
| 945 | |
| 946 | return ret; |
| 947 | } |
| 948 | |
| 949 | static void mwifiex_submit_rx_urb(struct mwifiex_adapter *adapter, u8 ep) |
| 950 | { |
| 951 | struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; |
| 952 | |
| 953 | skb_push(card->rx_cmd.skb, INTF_HEADER_LEN); |
| 954 | if ((ep == card->rx_cmd_ep) && |
| 955 | (!atomic_read(&card->rx_cmd_urb_pending))) |
| 956 | mwifiex_usb_submit_rx_urb(&card->rx_cmd, |
| 957 | MWIFIEX_RX_CMD_BUF_SIZE); |
| 958 | |
| 959 | return; |
| 960 | } |
| 961 | |
| 962 | static int mwifiex_usb_cmd_event_complete(struct mwifiex_adapter *adapter, |
| 963 | struct sk_buff *skb) |
| 964 | { |
| 965 | atomic_dec(&adapter->rx_pending); |
| 966 | mwifiex_submit_rx_urb(adapter, MWIFIEX_USB_EP_CMD_EVENT); |
| 967 | |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | static int mwifiex_usb_data_complete(struct mwifiex_adapter *adapter, |
| 972 | struct sk_buff *skb) |
| 973 | { |
| 974 | atomic_dec(&adapter->rx_pending); |
| 975 | dev_kfree_skb_any(skb); |
| 976 | |
| 977 | return 0; |
| 978 | } |
| 979 | |
| 980 | /* This function wakes up the card. */ |
| 981 | static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) |
| 982 | { |
| 983 | /* Simulation of HS_AWAKE event */ |
| 984 | adapter->pm_wakeup_fw_try = false; |
| 985 | adapter->pm_wakeup_card_req = false; |
| 986 | adapter->ps_state = PS_STATE_AWAKE; |
| 987 | |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | static struct mwifiex_if_ops usb_ops = { |
| 992 | .register_dev = mwifiex_register_dev, |
| 993 | .wakeup = mwifiex_pm_wakeup_card, |
| 994 | .wakeup_complete = mwifiex_pm_wakeup_card_complete, |
| 995 | |
| 996 | /* USB specific */ |
| 997 | .dnld_fw = mwifiex_usb_dnld_fw, |
| 998 | .cmdrsp_complete = mwifiex_usb_cmd_event_complete, |
| 999 | .event_complete = mwifiex_usb_cmd_event_complete, |
| 1000 | .data_complete = mwifiex_usb_data_complete, |
| 1001 | .host_to_card = mwifiex_usb_host_to_card, |
| 1002 | }; |
| 1003 | |
| 1004 | /* This function initializes the USB driver module. |
| 1005 | * |
| 1006 | * This initiates the semaphore and registers the device with |
| 1007 | * USB bus. |
| 1008 | */ |
| 1009 | static int mwifiex_usb_init_module(void) |
| 1010 | { |
| 1011 | int ret; |
| 1012 | |
| 1013 | pr_debug("Marvell USB8797 Driver\n"); |
| 1014 | |
| 1015 | sema_init(&add_remove_card_sem, 1); |
| 1016 | |
| 1017 | ret = usb_register(&mwifiex_usb_driver); |
| 1018 | if (ret) |
| 1019 | pr_err("Driver register failed!\n"); |
| 1020 | else |
| 1021 | pr_debug("info: Driver registered successfully!\n"); |
| 1022 | |
| 1023 | return ret; |
| 1024 | } |
| 1025 | |
| 1026 | /* This function cleans up the USB driver. |
| 1027 | * |
| 1028 | * The following major steps are followed in .disconnect for cleanup: |
| 1029 | * - Resume the device if its suspended |
| 1030 | * - Disconnect the device if connected |
| 1031 | * - Shutdown the firmware |
| 1032 | * - Unregister the device from USB bus. |
| 1033 | */ |
| 1034 | static void mwifiex_usb_cleanup_module(void) |
| 1035 | { |
| 1036 | if (!down_interruptible(&add_remove_card_sem)) |
| 1037 | up(&add_remove_card_sem); |
| 1038 | |
| 1039 | /* set the flag as user is removing this module */ |
| 1040 | user_rmmod = 1; |
| 1041 | |
| 1042 | usb_deregister(&mwifiex_usb_driver); |
| 1043 | } |
| 1044 | |
| 1045 | module_init(mwifiex_usb_init_module); |
| 1046 | module_exit(mwifiex_usb_cleanup_module); |
| 1047 | |
| 1048 | MODULE_AUTHOR("Marvell International Ltd."); |
| 1049 | MODULE_DESCRIPTION("Marvell WiFi-Ex USB Driver version" USB_VERSION); |
| 1050 | MODULE_VERSION(USB_VERSION); |
| 1051 | MODULE_LICENSE("GPL v2"); |
| 1052 | MODULE_FIRMWARE("mrvl/usb8797_uapsta.bin"); |