2 * This file contains functions used in USB interface module.
4 #include <linux/delay.h>
5 #include <linux/firmware.h>
6 #include <linux/netdevice.h>
16 #define MESSAGE_HEADER_LEN 4
18 static const char usbdriver_name[] = "usb8xxx";
20 static struct usb_device_id if_usb_table[] = {
21 /* Enter the device signature inside */
23 USB_DEVICE(USB8388_VID_1, USB8388_PID_1),
26 USB_DEVICE(USB8388_VID_2, USB8388_PID_2),
28 {} /* Terminating entry */
31 MODULE_DEVICE_TABLE(usb, if_usb_table);
33 static void if_usb_receive(struct urb *urb);
34 static void if_usb_receive_fwload(struct urb *urb);
37 * @brief call back function to handle the status of the URB
38 * @param urb pointer to urb structure
41 static void if_usb_write_bulk_callback(struct urb *urb)
43 wlan_private *priv = (wlan_private *) (urb->context);
44 wlan_adapter *adapter = priv->adapter;
45 struct net_device *dev = priv->wlan_dev.netdev;
47 /* handle the transmission complete validations */
49 if (urb->status != 0) {
50 /* print the failure status number for debug */
51 lbs_pr_info("URB in failure status\n");
53 lbs_dev_dbg(2, &urb->dev->dev, "URB status is successfull\n");
54 lbs_dev_dbg(2, &urb->dev->dev, "Actual length transmitted %d\n",
56 priv->wlan_dev.dnld_sent = DNLD_RES_RECEIVED;
57 /* Wake main thread if commands are pending */
58 if (!adapter->cur_cmd)
59 wake_up_interruptible(&priv->mainthread.waitq);
60 if ((adapter->connect_status == libertas_connected))
61 netif_wake_queue(dev);
68 * @brief free tx/rx urb, skb and rx buffer
69 * @param cardp pointer usb_card_rec
72 void if_usb_free(struct usb_card_rec *cardp)
76 /* Unlink tx & rx urb */
77 usb_kill_urb(cardp->tx_urb);
78 usb_kill_urb(cardp->rx_urb);
80 usb_free_urb(cardp->tx_urb);
83 usb_free_urb(cardp->rx_urb);
86 kfree(cardp->bulk_out_buffer);
87 cardp->bulk_out_buffer = NULL;
94 * @brief sets the configuration values
95 * @param ifnum interface number
96 * @param id pointer to usb_device_id
97 * @return 0 on success, error code on failure
99 static int if_usb_probe(struct usb_interface *intf,
100 const struct usb_device_id *id)
102 struct usb_device *udev;
103 struct usb_host_interface *iface_desc;
104 struct usb_endpoint_descriptor *endpoint;
105 wlan_private *pwlanpriv;
106 struct usb_card_rec *usb_cardp;
109 udev = interface_to_usbdev(intf);
111 usb_cardp = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL);
113 lbs_pr_err("Out of memory allocating private data.\n");
117 usb_cardp->udev = udev;
118 iface_desc = intf->cur_altsetting;
120 lbs_dev_dbg(1, &udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X"
121 " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X\n",
122 udev->descriptor.bcdUSB,
123 udev->descriptor.bDeviceClass,
124 udev->descriptor.bDeviceSubClass,
125 udev->descriptor.bDeviceProtocol);
127 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
128 endpoint = &iface_desc->endpoint[i].desc;
129 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
130 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
131 USB_ENDPOINT_XFER_BULK)) {
132 /* we found a bulk in endpoint */
133 lbs_dev_dbg(1, &udev->dev, "Bulk in size is %d\n",
134 endpoint->wMaxPacketSize);
137 usb_alloc_urb(0, GFP_KERNEL))) {
138 lbs_dev_dbg(1, &udev->dev,
139 "Rx URB allocation failed\n");
142 usb_cardp->rx_urb_recall = 0;
144 usb_cardp->bulk_in_size =
145 endpoint->wMaxPacketSize;
146 usb_cardp->bulk_in_endpointAddr =
148 bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
149 lbs_dev_dbg(1, &udev->dev, "in_endpoint = %d\n",
150 endpoint->bEndpointAddress);
154 bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
156 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
157 USB_ENDPOINT_XFER_BULK)) {
158 /* We found bulk out endpoint */
161 usb_alloc_urb(0, GFP_KERNEL))) {
162 lbs_dev_dbg(1,&udev->dev,
163 "Tx URB allocation failed\n");
167 usb_cardp->bulk_out_size =
168 endpoint->wMaxPacketSize;
169 lbs_dev_dbg(1, &udev->dev,
170 "Bulk out size is %d\n",
171 endpoint->wMaxPacketSize);
172 usb_cardp->bulk_out_endpointAddr =
173 endpoint->bEndpointAddress;
174 lbs_dev_dbg(1, &udev->dev, "out_endpoint = %d\n",
175 endpoint->bEndpointAddress);
176 usb_cardp->bulk_out_buffer =
177 kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE,
180 if (!usb_cardp->bulk_out_buffer) {
181 lbs_dev_dbg(1, &udev->dev,
182 "Could not allocate buffer\n");
189 /* At this point wlan_add_card() will be called. Don't worry
190 * about keeping pwlanpriv around since it will be set on our
191 * usb device data in -> add() -> libertas_sbi_register_dev().
193 if (!(pwlanpriv = wlan_add_card(usb_cardp)))
197 usb_set_intfdata(intf, usb_cardp);
200 * return card structure, which can be got back in the
201 * diconnect function as the ptr
207 if_usb_free(usb_cardp);
214 * @brief free resource and cleanup
215 * @param udev pointer to usb_device
216 * @param ptr pointer to usb_cardp
219 static void if_usb_disconnect(struct usb_interface *intf)
221 struct usb_card_rec *cardp = usb_get_intfdata(intf);
222 wlan_private *priv = (wlan_private *) cardp->priv;
223 wlan_adapter *adapter = NULL;
225 adapter = priv->adapter;
228 * Update Surprise removed to TRUE
230 adapter->surpriseremoved = 1;
232 /* card is removed and we can call wlan_remove_card */
233 lbs_dev_dbg(1, &cardp->udev->dev, "call remove card\n");
234 wlan_remove_card(cardp);
236 /* Unlink and free urb */
239 usb_set_intfdata(intf, NULL);
240 usb_put_dev(interface_to_usbdev(intf));
246 * @brief This function download FW
247 * @param priv pointer to wlan_private
250 static int if_prog_firmware(wlan_private * priv)
252 struct usb_card_rec *cardp = priv->wlan_dev.card;
253 struct FWData *fwdata;
254 struct fwheader *fwheader;
255 u8 *firmware = priv->firmware->data;
257 fwdata = kmalloc(sizeof(struct FWData), GFP_ATOMIC);
262 fwheader = &fwdata->fwheader;
264 if (!cardp->CRC_OK) {
265 cardp->totalbytes = cardp->fwlastblksent;
266 cardp->fwseqnum = cardp->lastseqnum - 1;
269 lbs_dev_dbg(2, &cardp->udev->dev, "totalbytes = %d\n",
272 memcpy(fwheader, &firmware[cardp->totalbytes],
273 sizeof(struct fwheader));
275 cardp->fwlastblksent = cardp->totalbytes;
276 cardp->totalbytes += sizeof(struct fwheader);
278 lbs_dev_dbg(2, &cardp->udev->dev,"Copy Data\n");
279 memcpy(fwdata->data, &firmware[cardp->totalbytes],
280 fwdata->fwheader.datalength);
282 lbs_dev_dbg(2, &cardp->udev->dev,
283 "Data length = %d\n", fwdata->fwheader.datalength);
285 cardp->fwseqnum = cardp->fwseqnum + 1;
287 fwdata->seqnum = cardp->fwseqnum;
288 cardp->lastseqnum = fwdata->seqnum;
289 cardp->totalbytes += fwdata->fwheader.datalength;
291 if (fwheader->dnldcmd == FW_HAS_DATA_TO_RECV) {
292 lbs_dev_dbg(2, &cardp->udev->dev, "There is data to follow\n");
293 lbs_dev_dbg(2, &cardp->udev->dev,
294 "seqnum = %d totalbytes = %d\n", cardp->fwseqnum,
296 memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE);
297 usb_tx_block(priv, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE);
299 } else if (fwdata->fwheader.dnldcmd == FW_HAS_LAST_BLOCK) {
300 lbs_dev_dbg(2, &cardp->udev->dev,
301 "Host has finished FW downloading\n");
302 lbs_dev_dbg(2, &cardp->udev->dev,
303 "Donwloading FW JUMP BLOCK\n");
304 memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE);
305 usb_tx_block(priv, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE);
306 cardp->fwfinalblk = 1;
309 lbs_dev_dbg(2, &cardp->udev->dev,
310 "The firmware download is done size is %d\n",
318 static int libertas_do_reset(wlan_private *priv)
321 struct usb_card_rec *cardp = priv->wlan_dev.card;
323 ret = usb_reset_device(cardp->udev);
333 * @brief This function transfer the data to the device.
334 * @param priv pointer to wlan_private
335 * @param payload pointer to payload data
336 * @param nb data length
339 int usb_tx_block(wlan_private * priv, u8 * payload, u16 nb)
341 /* pointer to card structure */
342 struct usb_card_rec *cardp = priv->wlan_dev.card;
345 /* check if device is removed */
346 if (priv->adapter->surpriseremoved) {
347 lbs_dev_dbg(1, &cardp->udev->dev, "Device removed\n");
351 usb_fill_bulk_urb(cardp->tx_urb, cardp->udev,
352 usb_sndbulkpipe(cardp->udev,
353 cardp->bulk_out_endpointAddr),
354 payload, nb, if_usb_write_bulk_callback, priv);
356 cardp->tx_urb->transfer_flags |= URB_ZERO_PACKET;
358 if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) {
359 /* transfer failed */
360 lbs_dev_dbg(1, &cardp->udev->dev, "usb_submit_urb failed\n");
363 lbs_dev_dbg(2, &cardp->udev->dev, "usb_submit_urb success\n");
371 static int __if_usb_submit_rx_urb(wlan_private * priv,
375 struct usb_card_rec *cardp = priv->wlan_dev.card;
377 struct read_cb_info *rinfo = &cardp->rinfo;
380 if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) {
381 lbs_pr_err("No free skb\n");
387 /* Fill the receive configuration URB and initialise the Rx call back */
388 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
389 usb_rcvbulkpipe(cardp->udev,
390 cardp->bulk_in_endpointAddr),
391 (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET),
392 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn,
395 cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
397 lbs_dev_dbg(2, &cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb);
398 if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) {
399 /* handle failure conditions */
400 lbs_dev_dbg(1, &cardp->udev->dev, "Submit Rx URB failed\n");
403 lbs_dev_dbg(2, &cardp->udev->dev, "Submit Rx URB success\n");
411 static inline int if_usb_submit_rx_urb_fwload(wlan_private * priv)
413 return __if_usb_submit_rx_urb(priv, &if_usb_receive_fwload);
416 static inline int if_usb_submit_rx_urb(wlan_private * priv)
418 return __if_usb_submit_rx_urb(priv, &if_usb_receive);
421 static void if_usb_receive_fwload(struct urb *urb)
423 struct read_cb_info *rinfo = (struct read_cb_info *)urb->context;
424 wlan_private *priv = rinfo->priv;
425 struct sk_buff *skb = rinfo->skb;
426 struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card;
427 struct fwsyncheader *syncfwheader;
428 struct bootcmdrespStr bootcmdresp;
431 lbs_dev_dbg(1, &cardp->udev->dev,
432 "URB status is failed during fw load\n");
437 if (cardp->bootcmdresp == 0) {
438 memcpy (&bootcmdresp, skb->data + IPFIELD_ALIGN_OFFSET,
439 sizeof(bootcmdresp));
440 if (cardp->udev->descriptor.bcdDevice < 0x3106) {
442 if_usb_submit_rx_urb_fwload(priv);
443 cardp->bootcmdresp = 1;
444 lbs_dev_dbg(1, &cardp->udev->dev,
445 "Received valid boot command response\n");
448 if (bootcmdresp.u32magicnumber != BOOT_CMD_MAGIC_NUMBER) {
450 "boot cmd response wrong magic number (0x%x)\n",
451 bootcmdresp.u32magicnumber);
452 } else if (bootcmdresp.u8cmd_tag != BOOT_CMD_FW_BY_USB) {
454 "boot cmd response cmd_tag error (%d)\n",
455 bootcmdresp.u8cmd_tag);
456 } else if (bootcmdresp.u8result != BOOT_CMD_RESP_OK) {
458 "boot cmd response result error (%d)\n",
459 bootcmdresp.u8result);
461 cardp->bootcmdresp = 1;
462 lbs_dev_dbg(1, &cardp->udev->dev,
463 "Received valid boot command response\n");
466 if_usb_submit_rx_urb_fwload(priv);
470 syncfwheader = kmalloc(sizeof(struct fwsyncheader), GFP_ATOMIC);
472 lbs_dev_dbg(1, &cardp->udev->dev, "Failure to allocate syncfwheader\n");
477 memcpy(syncfwheader, skb->data + IPFIELD_ALIGN_OFFSET,
478 sizeof(struct fwsyncheader));
480 if (!syncfwheader->cmd) {
481 lbs_dev_dbg(2, &cardp->udev->dev,
482 "FW received Blk with correct CRC\n");
483 lbs_dev_dbg(2, &cardp->udev->dev,
484 "FW received Blk seqnum = %d\n",
485 syncfwheader->seqnum);
488 lbs_dev_dbg(1, &cardp->udev->dev,
489 "FW received Blk with CRC error\n");
495 if (cardp->fwfinalblk) {
496 cardp->fwdnldover = 1;
500 if_prog_firmware(priv);
502 if_usb_submit_rx_urb_fwload(priv);
510 #define MRVDRV_MIN_PKT_LEN 30
512 static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb,
513 struct usb_card_rec *cardp,
516 if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE +
517 MESSAGE_HEADER_LEN || recvlength < MRVDRV_MIN_PKT_LEN) {
518 lbs_dev_dbg(1, &cardp->udev->dev,
519 "Packet length is Invalid\n");
524 skb_reserve(skb, IPFIELD_ALIGN_OFFSET);
525 skb_put(skb, recvlength);
526 skb_pull(skb, MESSAGE_HEADER_LEN);
527 libertas_process_rxed_packet(priv, skb);
528 priv->wlan_dev.upld_len = (recvlength - MESSAGE_HEADER_LEN);
531 static inline void process_cmdrequest(int recvlength, u8 *recvbuff,
533 struct usb_card_rec *cardp,
537 if (recvlength > MRVDRV_SIZE_OF_CMD_BUFFER) {
538 lbs_dev_dbg(1, &cardp->udev->dev,
539 "The receive buffer is too large\n");
547 spin_lock(&priv->adapter->driver_lock);
548 /* take care of cur_cmd = NULL case by reading the
549 * data to clear the interrupt */
550 if (!priv->adapter->cur_cmd) {
551 cmdbuf = priv->wlan_dev.upld_buf;
552 priv->adapter->hisregcpy &= ~his_cmdupldrdy;
554 cmdbuf = priv->adapter->cur_cmd->bufvirtualaddr;
556 cardp->usb_int_cause |= his_cmdupldrdy;
557 priv->wlan_dev.upld_len = (recvlength - MESSAGE_HEADER_LEN);
558 memcpy(cmdbuf, recvbuff + MESSAGE_HEADER_LEN,
559 priv->wlan_dev.upld_len);
562 libertas_interrupt(priv->wlan_dev.netdev);
563 spin_unlock(&priv->adapter->driver_lock);
565 lbs_dev_dbg(1, &cardp->udev->dev,
566 "Wake up main thread to handle cmd response\n");
572 * @brief This function reads of the packet into the upload buff,
573 * wake up the main thread and initialise the Rx callack.
575 * @param urb pointer to struct urb
578 static void if_usb_receive(struct urb *urb)
580 struct read_cb_info *rinfo = (struct read_cb_info *)urb->context;
581 wlan_private *priv = rinfo->priv;
582 struct sk_buff *skb = rinfo->skb;
583 struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card;
585 int recvlength = urb->actual_length;
593 lbs_dev_dbg(1, &cardp->udev->dev,
594 "URB status is failed\n");
599 recvbuff = skb->data + IPFIELD_ALIGN_OFFSET;
600 memcpy(&recvtype, recvbuff, sizeof(u32));
601 lbs_dev_dbg(1, &cardp->udev->dev,
602 "Recv length = 0x%x\n", recvlength);
603 lbs_dev_dbg(1, &cardp->udev->dev,
604 "Receive type = 0x%X\n", recvtype);
605 recvtype = le32_to_cpu(recvtype);
606 lbs_dev_dbg(1, &cardp->udev->dev,
607 "Receive type after = 0x%X\n", recvtype);
608 } else if (urb->status)
614 process_cmdtypedata(recvlength, skb, cardp, priv);
617 case CMD_TYPE_REQUEST:
618 process_cmdrequest(recvlength, recvbuff, skb, cardp, priv);
621 case CMD_TYPE_INDICATION:
622 /* Event cause handling */
623 spin_lock(&priv->adapter->driver_lock);
624 cardp->usb_event_cause = *(u32 *) (recvbuff + MESSAGE_HEADER_LEN);
625 lbs_dev_dbg(1, &cardp->udev->dev,"**EVENT** 0x%X\n",
626 cardp->usb_event_cause);
627 if (cardp->usb_event_cause & 0xffff0000) {
628 libertas_send_tx_feedback(priv);
629 spin_unlock(&priv->adapter->driver_lock);
632 cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3;
633 cardp->usb_int_cause |= his_cardevent;
635 libertas_interrupt(priv->wlan_dev.netdev);
636 spin_unlock(&priv->adapter->driver_lock);
644 if_usb_submit_rx_urb(priv);
651 * @brief This function downloads data to FW
652 * @param priv pointer to wlan_private structure
653 * @param type type of data
654 * @param buf pointer to data buffer
655 * @param len number of bytes
658 int libertas_sbi_host_to_card(wlan_private * priv, u8 type, u8 * payload, u16 nb)
662 struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card;
664 lbs_dev_dbg(1, &cardp->udev->dev,"*** type = %u\n", type);
665 lbs_dev_dbg(1, &cardp->udev->dev,"size after = %d\n", nb);
667 if (type == MVMS_CMD) {
668 tmp = cpu_to_le32(CMD_TYPE_REQUEST);
669 priv->wlan_dev.dnld_sent = DNLD_CMD_SENT;
670 memcpy(cardp->bulk_out_buffer, (u8 *) & tmp,
674 tmp = cpu_to_le32(CMD_TYPE_DATA);
675 priv->wlan_dev.dnld_sent = DNLD_DATA_SENT;
676 memcpy(cardp->bulk_out_buffer, (u8 *) & tmp,
680 memcpy((cardp->bulk_out_buffer + MESSAGE_HEADER_LEN), payload, nb);
683 usb_tx_block(priv, cardp->bulk_out_buffer, nb + MESSAGE_HEADER_LEN);
688 /* called with adapter->driver_lock held */
689 int libertas_sbi_get_int_status(wlan_private * priv, u8 * ireg)
691 struct usb_card_rec *cardp = priv->wlan_dev.card;
693 *ireg = cardp->usb_int_cause;
694 cardp->usb_int_cause = 0;
696 lbs_dev_dbg(1, &cardp->udev->dev,"Int cause is 0x%X\n", *ireg);
701 int libertas_sbi_read_event_cause(wlan_private * priv)
703 struct usb_card_rec *cardp = priv->wlan_dev.card;
704 priv->adapter->eventcause = cardp->usb_event_cause;
705 /* Re-submit rx urb here to avoid event lost issue */
706 if_usb_submit_rx_urb(priv);
710 int reset_device(wlan_private *priv)
714 ret = libertas_prepare_and_send_command(priv, cmd_802_11_reset,
715 cmd_act_halt, 0, 0, NULL);
716 msleep_interruptible(10);
721 int libertas_sbi_unregister_dev(wlan_private * priv)
725 /* Need to send a Reset command to device before USB resources freed
726 * and wlan_remove_card() called, then device can handle FW download
737 * @brief This function register usb device and initialize parameter
738 * @param priv pointer to wlan_private
741 int libertas_sbi_register_dev(wlan_private * priv)
744 struct usb_card_rec *cardp = (struct usb_card_rec *)priv->wlan_dev.card;
748 cardp->eth_dev = priv->wlan_dev.netdev;
749 priv->hotplug_device = &(cardp->udev->dev);
751 SET_NETDEV_DEV(cardp->eth_dev, &(cardp->udev->dev));
753 lbs_dev_dbg(1, &cardp->udev->dev, "udev pointer is at %p\n",
762 int libertas_sbi_prog_firmware(wlan_private * priv)
764 struct usb_card_rec *cardp = priv->wlan_dev.card;
766 static int reset_count = 10;
770 cardp->rinfo.priv = priv;
773 if (if_usb_submit_rx_urb_fwload(priv) < 0) {
774 lbs_dev_dbg(1, &cardp->udev->dev, "URB submission is failed\n");
779 cardp->bootcmdresp = 0;
783 /* Issue Boot command = 1, Boot from Download-FW */
784 if_usb_issue_boot_command(priv, BOOT_CMD_FW_BY_USB);
785 /* wait for command response */
788 msleep_interruptible(100);
789 } while (cardp->bootcmdresp == 0 && j < 10);
790 } while (cardp->bootcmdresp == 0 && i < 5);
792 if (cardp->bootcmdresp == 0) {
793 if (--reset_count >= 0) {
794 libertas_do_reset(priv);
801 priv->adapter->fw_ready = 0;
803 cardp->totalbytes = 0;
804 cardp->fwlastblksent = 0;
806 cardp->fwdnldover = 0;
807 cardp->fwseqnum = -1;
808 cardp->totalbytes = 0;
809 cardp->fwfinalblk = 0;
811 if_prog_firmware(priv);
814 lbs_dev_dbg(1, &cardp->udev->dev,"Wlan sched timeout\n");
816 msleep_interruptible(100);
817 if (priv->adapter->surpriseremoved || i >= 20)
819 } while (!cardp->fwdnldover);
821 if (!cardp->fwdnldover) {
822 lbs_pr_info("failed to load fw, resetting device!\n");
823 if (--reset_count >= 0) {
824 libertas_do_reset(priv);
828 lbs_pr_info("FW download failure, time = %d ms\n", i * 100);
833 if_usb_submit_rx_urb(priv);
835 /* Delay 200 ms to waiting for the FW ready */
836 msleep_interruptible(200);
838 priv->adapter->fw_ready = 1;
845 * @brief Given a usb_card_rec return its wlan_private
846 * @param card pointer to a usb_card_rec
847 * @return pointer to wlan_private
849 wlan_private *libertas_sbi_get_priv(void *card)
851 struct usb_card_rec *cardp = card;
856 int libertas_sbi_suspend(wlan_private * priv)
861 int libertas_sbi_resume(wlan_private * priv)
868 static int if_usb_suspend(struct usb_interface *intf, pm_message_t message)
870 struct usb_card_rec *cardp = usb_get_intfdata(intf);
871 wlan_private *priv = cardp->priv;
875 if (priv->adapter->psstate != PS_STATE_FULL_POWER)
878 netif_device_detach(cardp->eth_dev);
880 /* Unlink tx & rx urb */
881 usb_kill_urb(cardp->tx_urb);
882 usb_kill_urb(cardp->rx_urb);
884 cardp->rx_urb_recall = 1;
890 static int if_usb_resume(struct usb_interface *intf)
892 struct usb_card_rec *cardp = usb_get_intfdata(intf);
896 cardp->rx_urb_recall = 0;
898 if_usb_submit_rx_urb(cardp->priv);
900 netif_device_attach(cardp->eth_dev);
906 #define if_usb_suspend NULL
907 #define if_usb_resume NULL
910 static struct usb_driver if_usb_driver = {
912 .name = usbdriver_name,
913 /* probe function name */
914 .probe = if_usb_probe,
915 /* disconnect function name */
916 .disconnect = if_usb_disconnect,
917 /* device signature table */
918 .id_table = if_usb_table,
919 .suspend = if_usb_suspend,
920 .resume = if_usb_resume,
924 * @brief This function registers driver.
925 * @param add pointer to add_card callback function
926 * @param remove pointer to remove card callback function
927 * @param arg pointer to call back function parameter
928 * @return dummy success variable
930 int libertas_sbi_register(void)
933 * API registers the Marvell USB driver
936 usb_register(&if_usb_driver);
938 /* Return success to wlan layer */
943 * @brief This function removes usb driver.
946 void libertas_sbi_unregister(void)
948 /* API unregisters the driver from USB subsystem */
949 usb_deregister(&if_usb_driver);