include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / if_usb.c
index 396ce67..fcea574 100644 (file)
@@ -5,8 +5,13 @@
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
+#ifdef CONFIG_OLPC
+#include <asm/olpc.h>
+#endif
+
 #define DRV_NAME "usb8xxx"
 
 #include "host.h"
@@ -24,6 +29,8 @@
 static char *lbs_fw_name = "usb8388.bin";
 module_param_named(fw_name, lbs_fw_name, charp, 0644);
 
+MODULE_FIRMWARE("usb8388.bin");
+
 static struct usb_device_id if_usb_table[] = {
        /* Enter the device signature inside */
        { USB_DEVICE(0x1286, 0x2001) },
@@ -35,17 +42,70 @@ MODULE_DEVICE_TABLE(usb, if_usb_table);
 
 static void if_usb_receive(struct urb *urb);
 static void if_usb_receive_fwload(struct urb *urb);
-static int if_usb_prog_firmware(struct if_usb_card *cardp);
+static int __if_usb_prog_firmware(struct if_usb_card *cardp,
+                                       const char *fwname, int cmd);
+static int if_usb_prog_firmware(struct if_usb_card *cardp,
+                                       const char *fwname, int cmd);
 static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type,
                               uint8_t *payload, uint16_t nb);
-static int if_usb_get_int_status(struct lbs_private *priv, uint8_t *);
-static int if_usb_read_event_cause(struct lbs_private *);
 static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload,
                        uint16_t nb);
 static void if_usb_free(struct if_usb_card *cardp);
 static int if_usb_submit_rx_urb(struct if_usb_card *cardp);
 static int if_usb_reset_device(struct if_usb_card *cardp);
 
+/* sysfs hooks */
+
+/**
+ *  Set function to write firmware to device's persistent memory
+ */
+static ssize_t if_usb_firmware_set(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct lbs_private *priv = to_net_dev(dev)->ml_priv;
+       struct if_usb_card *cardp = priv->card;
+       int ret;
+
+       ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_FW);
+       if (ret == 0)
+               return count;
+
+       return ret;
+}
+
+/**
+ * lbs_flash_fw attribute to be exported per ethX interface through sysfs
+ * (/sys/class/net/ethX/lbs_flash_fw).  Use this like so to write firmware to
+ * the device's persistent memory:
+ * echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_fw
+ */
+static DEVICE_ATTR(lbs_flash_fw, 0200, NULL, if_usb_firmware_set);
+
+/**
+ *  Set function to write firmware to device's persistent memory
+ */
+static ssize_t if_usb_boot2_set(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct lbs_private *priv = to_net_dev(dev)->ml_priv;
+       struct if_usb_card *cardp = priv->card;
+       int ret;
+
+       ret = if_usb_prog_firmware(cardp, buf, BOOT_CMD_UPDATE_BOOT2);
+       if (ret == 0)
+               return count;
+
+       return ret;
+}
+
+/**
+ * lbs_flash_boot2 attribute to be exported per ethX interface through sysfs
+ * (/sys/class/net/ethX/lbs_flash_boot2).  Use this like so to write firmware
+ * to the device's persistent memory:
+ * echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_boot2
+ */
+static DEVICE_ATTR(lbs_flash_boot2, 0200, NULL, if_usb_boot2_set);
+
 /**
  *  @brief  call back function to handle the status of the URB
  *  @param urb                 pointer to urb structure
@@ -64,10 +124,10 @@ static void if_usb_write_bulk_callback(struct urb *urb)
                lbs_deb_usb2(&urb->dev->dev, "Actual length transmitted %d\n",
                             urb->actual_length);
 
-               /* Used for both firmware TX and regular TX.  priv isn't
-                * valid at firmware load time.
+               /* Boot commands such as UPDATE_FW and UPDATE_BOOT2 are not
+                * passed up to the lbs level.
                 */
-               if (priv)
+               if (priv && priv->dnld_sent != DNLD_BOOTCMD_SENT)
                        lbs_host_to_card_done(priv);
        } else {
                /* print the failure status number for debug */
@@ -102,15 +162,39 @@ static void if_usb_free(struct if_usb_card *cardp)
        lbs_deb_leave(LBS_DEB_USB);
 }
 
-static void if_usb_set_boot2_ver(struct lbs_private *priv)
+static void if_usb_setup_firmware(struct lbs_private *priv)
 {
+       struct if_usb_card *cardp = priv->card;
        struct cmd_ds_set_boot2_ver b2_cmd;
+       struct cmd_ds_802_11_fw_wake_method wake_method;
 
+       b2_cmd.hdr.size = cpu_to_le16(sizeof(b2_cmd));
        b2_cmd.action = 0;
-       b2_cmd.version = priv->boot2_version;
+       b2_cmd.version = cardp->boot2_version;
 
-       if (lbs_cmd(priv, CMD_SET_BOOT2_VER, &b2_cmd, NULL, 0))
+       if (lbs_cmd_with_response(priv, CMD_SET_BOOT2_VER, &b2_cmd))
                lbs_deb_usb("Setting boot2 version failed\n");
+
+       priv->wol_gpio = 2; /* Wake via GPIO2... */
+       priv->wol_gap = 20; /* ... after 20ms    */
+       lbs_host_sleep_cfg(priv, EHS_WAKE_ON_UNICAST_DATA,
+                       (struct wol_config *) NULL);
+
+       wake_method.hdr.size = cpu_to_le16(sizeof(wake_method));
+       wake_method.action = cpu_to_le16(CMD_ACT_GET);
+       if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) {
+               lbs_pr_info("Firmware does not seem to support PS mode\n");
+               priv->fwcapinfo &= ~FW_CAPINFO_PS;
+       } else {
+               if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) {
+                       lbs_deb_usb("Firmware seems to support PS with wake-via-command\n");
+               } else {
+                       /* The versions which boot up this way don't seem to
+                          work even if we set it to the command interrupt */
+                       priv->fwcapinfo &= ~FW_CAPINFO_PS;
+                       lbs_pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n");
+               }
+       }
 }
 
 static void if_usb_fw_timeo(unsigned long priv)
@@ -126,6 +210,14 @@ static void if_usb_fw_timeo(unsigned long priv)
        wake_up(&cardp->fw_wq);
 }
 
+#ifdef CONFIG_OLPC
+static void if_usb_reset_olpc_card(struct lbs_private *priv)
+{
+       printk(KERN_CRIT "Resetting OLPC wireless via EC...\n");
+       olpc_ec_cmd(0x25, NULL, 0, NULL, 0);
+}
+#endif
+
 /**
  *  @brief sets the configuration values
  *  @param ifnum       interface number
@@ -199,7 +291,7 @@ static int if_usb_probe(struct usb_interface *intf,
        }
 
        /* Upload firmware */
-       if (if_usb_prog_firmware(cardp)) {
+       if (__if_usb_prog_firmware(cardp, lbs_fw_name, BOOT_CMD_FW_BY_USB)) {
                lbs_deb_usbd(&udev->dev, "FW upload failed\n");
                goto err_prog_firmware;
        }
@@ -211,24 +303,32 @@ static int if_usb_probe(struct usb_interface *intf,
        cardp->priv->fw_ready = 1;
 
        priv->hw_host_to_card = if_usb_host_to_card;
-       priv->hw_get_int_status = if_usb_get_int_status;
-       priv->hw_read_event_cause = if_usb_read_event_cause;
-       priv->boot2_version = udev->descriptor.bcdDevice;
+       priv->enter_deep_sleep = NULL;
+       priv->exit_deep_sleep = NULL;
+       priv->reset_deep_sleep_wakeup = NULL;
+#ifdef CONFIG_OLPC
+       if (machine_is_olpc())
+               priv->reset_card = if_usb_reset_olpc_card;
+#endif
+
+       cardp->boot2_version = udev->descriptor.bcdDevice;
 
        if_usb_submit_rx_urb(cardp);
 
        if (lbs_start_card(priv))
                goto err_start_card;
 
-       if_usb_set_boot2_ver(priv);
-
-       priv->wol_gpio = 2; /* Wake via GPIO2... */
-       priv->wol_gap = 20; /* ... after 20ms    */
-       lbs_host_sleep_cfg(priv, EHS_WAKE_ON_UNICAST_DATA);
+       if_usb_setup_firmware(priv);
 
        usb_get_dev(udev);
        usb_set_intfdata(intf, cardp);
 
+       if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_fw))
+               lbs_pr_err("cannot register lbs_flash_fw attribute\n");
+
+       if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2))
+               lbs_pr_err("cannot register lbs_flash_boot2 attribute\n");
+
        return 0;
 
 err_start_card:
@@ -254,6 +354,9 @@ static void if_usb_disconnect(struct usb_interface *intf)
 
        lbs_deb_enter(LBS_DEB_MAIN);
 
+       device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2);
+       device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_fw);
+
        cardp->surprise_removed = 1;
 
        if (priv) {
@@ -279,7 +382,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
 static int if_usb_send_fw_pkt(struct if_usb_card *cardp)
 {
        struct fwdata *fwdata = cardp->ep_out_buf;
-       uint8_t *firmware = cardp->fw->data;
+       const uint8_t *firmware = cardp->fw->data;
 
        /* If we got a CRC failure on the last block, back
           up and retry it */
@@ -340,16 +443,20 @@ static int if_usb_reset_device(struct if_usb_card *cardp)
        *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST);
 
        cmd->command = cpu_to_le16(CMD_802_11_RESET);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN);
+       cmd->size = cpu_to_le16(sizeof(struct cmd_header));
        cmd->result = cpu_to_le16(0);
        cmd->seqnum = cpu_to_le16(0x5a5a);
-       cmd->params.reset.action = cpu_to_le16(CMD_ACT_HALT);
-       usb_tx_block(cardp, cardp->ep_out_buf, 4 + S_DS_GEN + sizeof(struct cmd_ds_802_11_reset));
+       usb_tx_block(cardp, cardp->ep_out_buf, 4 + sizeof(struct cmd_header));
 
        msleep(100);
        ret = usb_reset_device(cardp->udev);
        msleep(100);
 
+#ifdef CONFIG_OLPC
+       if (ret && machine_is_olpc())
+               if_usb_reset_olpc_card(NULL);
+#endif
+
        lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret);
 
        return ret;
@@ -407,7 +514,7 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
        /* Fill the receive configuration URB and initialise the Rx call back */
        usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
                          usb_rcvbulkpipe(cardp->udev, cardp->ep_in),
-                         (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET),
+                         skb->data + IPFIELD_ALIGN_OFFSET,
                          MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn,
                          cardp);
 
@@ -474,7 +581,7 @@ static void if_usb_receive_fwload(struct urb *urb)
                if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) {
                        kfree_skb(skb);
                        if_usb_submit_rx_urb_fwload(cardp);
-                       cardp->bootcmdresp = 1;
+                       cardp->bootcmdresp = BOOT_CMD_RESP_OK;
                        lbs_deb_usbd(&cardp->udev->dev,
                                     "Received valid boot command response\n");
                        return;
@@ -490,7 +597,9 @@ static void if_usb_receive_fwload(struct urb *urb)
                                lbs_pr_info("boot cmd response wrong magic number (0x%x)\n",
                                            le32_to_cpu(bootcmdresp.magic));
                        }
-               } else if (bootcmdresp.cmd != BOOT_CMD_FW_BY_USB) {
+               } else if ((bootcmdresp.cmd != BOOT_CMD_FW_BY_USB) &&
+                          (bootcmdresp.cmd != BOOT_CMD_UPDATE_FW) &&
+                          (bootcmdresp.cmd != BOOT_CMD_UPDATE_BOOT2)) {
                        lbs_pr_info("boot cmd response cmd_tag error (%d)\n",
                                    bootcmdresp.cmd);
                } else if (bootcmdresp.result != BOOT_CMD_RESP_OK) {
@@ -528,8 +637,8 @@ static void if_usb_receive_fwload(struct urb *urb)
 
        kfree_skb(skb);
 
-       /* reschedule timer for 200ms hence */
-       mod_timer(&cardp->fw_timeout, jiffies + (HZ/5));
+       /* Give device 5s to either write firmware to its RAM or eeprom */
+       mod_timer(&cardp->fw_timeout, jiffies + (HZ*5));
 
        if (cardp->fwfinalblk) {
                cardp->fwdnldover = 1;
@@ -564,7 +673,6 @@ static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb,
        skb_pull(skb, MESSAGE_HEADER_LEN);
 
        lbs_process_rxed_packet(priv, skb);
-       priv->upld_len = (recvlength - MESSAGE_HEADER_LEN);
 }
 
 static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
@@ -572,7 +680,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
                                      struct if_usb_card *cardp,
                                      struct lbs_private *priv)
 {
-       uint8_t *cmdbuf;
+       u8 i;
 
        if (recvlength > LBS_CMD_BUFFER_SIZE) {
                lbs_deb_usbd(&cardp->udev->dev,
@@ -581,26 +689,18 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
                return;
        }
 
-       if (!in_interrupt())
-               BUG();
+       BUG_ON(!in_interrupt());
 
        spin_lock(&priv->driver_lock);
-       /* take care of cur_cmd = NULL case by reading the
-        * data to clear the interrupt */
-       if (!priv->cur_cmd) {
-               lbs_deb_hex(LBS_DEB_HOST, "Unsolicited CMD_RESP",
-                           (void *) recvbuff + MESSAGE_HEADER_LEN, priv->upld_len);
-               cmdbuf = priv->upld_buf;
-               priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY;
-       } else
-               cmdbuf = (uint8_t *) priv->cur_cmd->cmdbuf;
-
-       cardp->usb_int_cause |= MRVDRV_CMD_UPLD_RDY;
-       priv->upld_len = (recvlength - MESSAGE_HEADER_LEN);
-       memcpy(cmdbuf, recvbuff + MESSAGE_HEADER_LEN, priv->upld_len);
 
+       i = (priv->resp_idx == 0) ? 1 : 0;
+       BUG_ON(priv->resp_len[i]);
+       priv->resp_len[i] = (recvlength - MESSAGE_HEADER_LEN);
+       memcpy(priv->resp_buf[i], recvbuff + MESSAGE_HEADER_LEN,
+               priv->resp_len[i]);
        kfree_skb(skb);
-       lbs_interrupt(priv);
+       lbs_notify_command_response(priv, i);
+
        spin_unlock(&priv->driver_lock);
 
        lbs_deb_usbd(&cardp->udev->dev,
@@ -623,6 +723,7 @@ static void if_usb_receive(struct urb *urb)
        uint8_t *recvbuff = NULL;
        uint32_t recvtype = 0;
        __le32 *pkt = (__le32 *)(skb->data + IPFIELD_ALIGN_OFFSET);
+       uint32_t event;
 
        lbs_deb_enter(LBS_DEB_USB);
 
@@ -654,26 +755,20 @@ static void if_usb_receive(struct urb *urb)
                break;
 
        case CMD_TYPE_INDICATION:
-               /* Event cause handling */
-               spin_lock(&priv->driver_lock);
+               /* Event handling */
+               event = le32_to_cpu(pkt[1]);
+               lbs_deb_usbd(&cardp->udev->dev, "**EVENT** 0x%X\n", event);
+               kfree_skb(skb);
 
-               cardp->usb_event_cause = le32_to_cpu(pkt[1]);
+               /* Icky undocumented magic special case */
+               if (event & 0xffff0000) {
+                       u32 trycount = (event & 0xffff0000) >> 16;
 
-               lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n",
-                            cardp->usb_event_cause);
+                       lbs_send_tx_feedback(priv, trycount);
+               } else
+                       lbs_queue_event(priv, event & 0xFF);
+               break;
 
-               /* Icky undocumented magic special case */
-               if (cardp->usb_event_cause & 0xffff0000) {
-                       lbs_send_tx_feedback(priv);
-                       spin_unlock(&priv->driver_lock);
-                       break;
-               }
-               cardp->usb_event_cause <<= 3;
-               cardp->usb_int_cause |= MRVDRV_CARDEVENT;
-               kfree_skb(skb);
-               lbs_interrupt(priv);
-               spin_unlock(&priv->driver_lock);
-               goto rx_exit;
        default:
                lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n",
                             recvtype);
@@ -716,30 +811,6 @@ static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type,
        return usb_tx_block(cardp, cardp->ep_out_buf, nb + MESSAGE_HEADER_LEN);
 }
 
-/* called with priv->driver_lock held */
-static int if_usb_get_int_status(struct lbs_private *priv, uint8_t *ireg)
-{
-       struct if_usb_card *cardp = priv->card;
-
-       *ireg = cardp->usb_int_cause;
-       cardp->usb_int_cause = 0;
-
-       lbs_deb_usbd(&cardp->udev->dev, "Int cause is 0x%X\n", *ireg);
-
-       return 0;
-}
-
-static int if_usb_read_event_cause(struct lbs_private *priv)
-{
-       struct if_usb_card *cardp = priv->card;
-
-       priv->eventcause = cardp->usb_event_cause;
-       /* Re-submit rx urb here to avoid event lost issue */
-       if_usb_submit_rx_urb(cardp);
-
-       return 0;
-}
-
 /**
  *  @brief This function issues Boot command to the Boot2 code
  *  @param ivalue   1:Boot from FW by USB-Download
@@ -769,7 +840,7 @@ static int if_usb_issue_boot_command(struct if_usb_card *cardp, int ivalue)
  *         len               image length
  *  @return     0 or -1
  */
-static int check_fwfile_format(uint8_t *data, uint32_t totlen)
+static int check_fwfile_format(const uint8_t *data, uint32_t totlen)
 {
        uint32_t bincmd, exit;
        uint32_t blksize, offset, len;
@@ -810,7 +881,54 @@ static int check_fwfile_format(uint8_t *data, uint32_t totlen)
 }
 
 
-static int if_usb_prog_firmware(struct if_usb_card *cardp)
+/**
+*  @brief This function programs the firmware subject to cmd
+*
+*  @param cardp             the if_usb_card descriptor
+*         fwname            firmware or boot2 image file name
+*         cmd               either BOOT_CMD_FW_BY_USB, BOOT_CMD_UPDATE_FW,
+*                           or BOOT_CMD_UPDATE_BOOT2.
+*  @return     0 or error code
+*/
+static int if_usb_prog_firmware(struct if_usb_card *cardp,
+                               const char *fwname, int cmd)
+{
+       struct lbs_private *priv = cardp->priv;
+       unsigned long flags, caps;
+       int ret;
+
+       caps = priv->fwcapinfo;
+       if (((cmd == BOOT_CMD_UPDATE_FW) && !(caps & FW_CAPINFO_FIRMWARE_UPGRADE)) ||
+           ((cmd == BOOT_CMD_UPDATE_BOOT2) && !(caps & FW_CAPINFO_BOOT2_UPGRADE)))
+               return -EOPNOTSUPP;
+
+       /* Ensure main thread is idle. */
+       spin_lock_irqsave(&priv->driver_lock, flags);
+       while (priv->cur_cmd != NULL || priv->dnld_sent != DNLD_RES_RECEIVED) {
+               spin_unlock_irqrestore(&priv->driver_lock, flags);
+               if (wait_event_interruptible(priv->waitq,
+                               (priv->cur_cmd == NULL &&
+                               priv->dnld_sent == DNLD_RES_RECEIVED))) {
+                       return -ERESTARTSYS;
+               }
+               spin_lock_irqsave(&priv->driver_lock, flags);
+       }
+       priv->dnld_sent = DNLD_BOOTCMD_SENT;
+       spin_unlock_irqrestore(&priv->driver_lock, flags);
+
+       ret = __if_usb_prog_firmware(cardp, fwname, cmd);
+
+       spin_lock_irqsave(&priv->driver_lock, flags);
+       priv->dnld_sent = DNLD_RES_RECEIVED;
+       spin_unlock_irqrestore(&priv->driver_lock, flags);
+
+       wake_up_interruptible(&priv->waitq);
+
+       return ret;
+}
+
+static int __if_usb_prog_firmware(struct if_usb_card *cardp,
+                                       const char *fwname, int cmd)
 {
        int i = 0;
        static int reset_count = 10;
@@ -818,20 +936,32 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp)
 
        lbs_deb_enter(LBS_DEB_USB);
 
-       if ((ret = request_firmware(&cardp->fw, lbs_fw_name,
-                                   &cardp->udev->dev)) < 0) {
+       ret = request_firmware(&cardp->fw, fwname, &cardp->udev->dev);
+       if (ret < 0) {
                lbs_pr_err("request_firmware() failed with %#x\n", ret);
-               lbs_pr_err("firmware %s not found\n", lbs_fw_name);
+               lbs_pr_err("firmware %s not found\n", fwname);
                goto done;
        }
 
-       if (check_fwfile_format(cardp->fw->data, cardp->fw->size))
+       if (check_fwfile_format(cardp->fw->data, cardp->fw->size)) {
+               ret = -EINVAL;
                goto release_fw;
+       }
+
+       /* Cancel any pending usb business */
+       usb_kill_urb(cardp->rx_urb);
+       usb_kill_urb(cardp->tx_urb);
+
+       cardp->fwlastblksent = 0;
+       cardp->fwdnldover = 0;
+       cardp->totalbytes = 0;
+       cardp->fwfinalblk = 0;
+       cardp->bootcmdresp = 0;
 
 restart:
        if (if_usb_submit_rx_urb_fwload(cardp) < 0) {
                lbs_deb_usbd(&cardp->udev->dev, "URB submission is failed\n");
-               ret = -1;
+               ret = -EIO;
                goto release_fw;
        }
 
@@ -839,8 +969,7 @@ restart:
        do {
                int j = 0;
                i++;
-               /* Issue Boot command = 1, Boot from Download-FW */
-               if_usb_issue_boot_command(cardp, BOOT_CMD_FW_BY_USB);
+               if_usb_issue_boot_command(cardp, cmd);
                /* wait for command response */
                do {
                        j++;
@@ -848,12 +977,21 @@ restart:
                } while (cardp->bootcmdresp == 0 && j < 10);
        } while (cardp->bootcmdresp == 0 && i < 5);
 
-       if (cardp->bootcmdresp <= 0) {
+       if (cardp->bootcmdresp == BOOT_CMD_RESP_NOT_SUPPORTED) {
+               /* Return to normal operation */
+               ret = -EOPNOTSUPP;
+               usb_kill_urb(cardp->rx_urb);
+               usb_kill_urb(cardp->tx_urb);
+               if (if_usb_submit_rx_urb(cardp) < 0)
+                       ret = -EIO;
+               goto release_fw;
+       } else if (cardp->bootcmdresp <= 0) {
                if (--reset_count >= 0) {
                        if_usb_reset_device(cardp);
                        goto restart;
                }
-               return -1;
+               ret = -EIO;
+               goto release_fw;
        }
 
        i = 0;
@@ -883,7 +1021,7 @@ restart:
                }
 
                lbs_pr_info("FW download failure, time = %d ms\n", i * 100);
-               ret = -1;
+               ret = -EIO;
                goto release_fw;
        }
 
@@ -948,6 +1086,7 @@ static struct usb_driver if_usb_driver = {
        .id_table = if_usb_table,
        .suspend = if_usb_suspend,
        .resume = if_usb_resume,
+       .reset_resume = if_usb_resume,
 };
 
 static int __init if_usb_init_module(void)