Merge tag 'io_uring-5.13-2021-05-07' of git://git.kernel.dk/linux-block
[linux-block.git] / drivers / bluetooth / btusb.c
index 5cbfbd948f676492bc501bff02a40c9b738d10e9..5d603ef39bad93a17ddb14e78ce644a8962e60dd 100644 (file)
@@ -399,7 +399,9 @@ static const struct usb_device_id blacklist_table[] = {
 
        /* MediaTek Bluetooth devices */
        { USB_VENDOR_AND_INTERFACE_INFO(0x0e8d, 0xe0, 0x01, 0x01),
-         .driver_info = BTUSB_MEDIATEK },
+         .driver_info = BTUSB_MEDIATEK |
+                        BTUSB_WIDEBAND_SPEECH |
+                        BTUSB_VALID_LE_STATES },
 
        /* Additional MediaTek MT7615E Bluetooth devices */
        { USB_DEVICE(0x13d3, 0x3560), .driver_info = BTUSB_MEDIATEK},
@@ -455,6 +457,8 @@ static const struct usb_device_id blacklist_table[] = {
                                                     BTUSB_WIDEBAND_SPEECH },
        { USB_DEVICE(0x0bda, 0xc123), .driver_info = BTUSB_REALTEK |
                                                     BTUSB_WIDEBAND_SPEECH },
+       { USB_DEVICE(0x0cb5, 0xc547), .driver_info = BTUSB_REALTEK |
+                                                    BTUSB_WIDEBAND_SPEECH },
 
        /* Silicon Wave based devices */
        { USB_DEVICE(0x0c10, 0x0000), .driver_info = BTUSB_SWAVE },
@@ -2400,7 +2404,7 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
        return -EILSEQ;
 }
 
-static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver,
+static int btusb_setup_intel_new_get_fw_name(struct intel_version *ver,
                                             struct intel_boot_params *params,
                                             char *fw_name, size_t len,
                                             const char *suffix)
@@ -2424,9 +2428,10 @@ static bool btusb_setup_intel_new_get_fw_name(struct intel_version *ver,
                        suffix);
                break;
        default:
-               return false;
+               return -EINVAL;
        }
-       return true;
+
+       return 0;
 }
 
 static void btusb_setup_intel_newgen_get_fw_name(const struct intel_version_tlv *ver_tlv,
@@ -2444,6 +2449,44 @@ static void btusb_setup_intel_newgen_get_fw_name(const struct intel_version_tlv
                 suffix);
 }
 
+static int btusb_download_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
+{
+       struct btusb_data *data = hci_get_drvdata(hdev);
+       ktime_t delta, rettime;
+       unsigned long long duration;
+       int err;
+
+       set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+
+       bt_dev_info(hdev, "Waiting for firmware download to complete");
+
+       err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
+                                 TASK_INTERRUPTIBLE,
+                                 msecs_to_jiffies(msec));
+       if (err == -EINTR) {
+               bt_dev_err(hdev, "Firmware loading interrupted");
+               return err;
+       }
+
+       if (err) {
+               bt_dev_err(hdev, "Firmware loading timeout");
+               return -ETIMEDOUT;
+       }
+
+       if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) {
+               bt_dev_err(hdev, "Firmware loading failed");
+               return -ENOEXEC;
+       }
+
+       rettime = ktime_get();
+       delta = ktime_sub(rettime, calltime);
+       duration = (unsigned long long)ktime_to_ns(delta) >> 10;
+
+       bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
+
+       return 0;
+}
+
 static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
                                                struct intel_version_tlv *ver,
                                                u32 *boot_param)
@@ -2452,19 +2495,11 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
        char fwname[64];
        int err;
        struct btusb_data *data = hci_get_drvdata(hdev);
+       ktime_t calltime;
 
        if (!ver || !boot_param)
                return -EINVAL;
 
-       /* The hardware platform number has a fixed value of 0x37 and
-        * for now only accept this single value.
-        */
-       if (INTEL_HW_PLATFORM(ver->cnvi_bt) != 0x37) {
-               bt_dev_err(hdev, "Unsupported Intel hardware platform (0x%2x)",
-                          INTEL_HW_PLATFORM(ver->cnvi_bt));
-               return -EINVAL;
-       }
-
        /* The firmware variant determines if the device is in bootloader
         * mode or is running operational firmware. The value 0x03 identifies
         * the bootloader and the value 0x23 identifies the operational
@@ -2481,50 +2516,6 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
        if (ver->img_type == 0x03) {
                clear_bit(BTUSB_BOOTLOADER, &data->flags);
                btintel_check_bdaddr(hdev);
-               return 0;
-       }
-
-       /* Check for supported iBT hardware variants of this firmware
-        * loading method.
-        *
-        * This check has been put in place to ensure correct forward
-        * compatibility options when newer hardware variants come along.
-        */
-       switch (INTEL_HW_VARIANT(ver->cnvi_bt)) {
-       case 0x17:      /* TyP */
-       case 0x18:      /* Slr */
-       case 0x19:      /* Slr-F */
-               break;
-       default:
-               bt_dev_err(hdev, "Unsupported Intel hardware variant (0x%x)",
-                          INTEL_HW_VARIANT(ver->cnvi_bt));
-               return -EINVAL;
-       }
-
-       /* If the device is not in bootloader mode, then the only possible
-        * choice is to return an error and abort the device initialization.
-        */
-       if (ver->img_type != 0x01) {
-               bt_dev_err(hdev, "Unsupported Intel firmware variant (0x%x)",
-                          ver->img_type);
-               return -ENODEV;
-       }
-
-       /* It is required that every single firmware fragment is acknowledged
-        * with a command complete event. If the boot parameters indicate
-        * that this bootloader does not send them, then abort the setup.
-        */
-       if (ver->limited_cce != 0x00) {
-               bt_dev_err(hdev, "Unsupported Intel firmware loading method (0x%x)",
-                          ver->limited_cce);
-               return -EINVAL;
-       }
-
-       /* Secure boot engine type should be either 1 (ECDSA) or 0 (RSA) */
-       if (ver->sbe_type > 0x01) {
-               bt_dev_err(hdev, "Unsupported Intel secure boot engine type (0x%x)",
-                          ver->sbe_type);
-               return -EINVAL;
        }
 
        /* If the OTP has no valid Bluetooth device address, then there will
@@ -2538,7 +2529,8 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
        btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), "sfi");
        err = request_firmware(&fw, fwname, &hdev->dev);
        if (err < 0) {
-               bt_dev_err(hdev, "Failed to load Intel firmware file (%d)", err);
+               bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
+                          fwname, err);
                return err;
        }
 
@@ -2551,22 +2543,28 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
                goto done;
        }
 
+       calltime = ktime_get();
+
        set_bit(BTUSB_DOWNLOADING, &data->flags);
 
        /* Start firmware downloading and get boot parameter */
-       err = btintel_download_firmware_newgen(hdev, fw, boot_param,
+       err = btintel_download_firmware_newgen(hdev, ver, fw, boot_param,
                                               INTEL_HW_VARIANT(ver->cnvi_bt),
                                               ver->sbe_type);
        if (err < 0) {
+               if (err == -EALREADY) {
+                       /* Firmware has already been loaded */
+                       set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+                       err = 0;
+                       goto done;
+               }
+
                /* When FW download fails, send Intel Reset to retry
                 * FW download.
                 */
                btintel_reset_to_bootloader(hdev);
                goto done;
        }
-       set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
-
-       bt_dev_info(hdev, "Waiting for firmware download to complete");
 
        /* Before switching the device into operational mode and with that
         * booting the loaded firmware, wait for the bootloader notification
@@ -2579,26 +2577,9 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
         * and thus just timeout if that happens and fail the setup
         * of this device.
         */
-       err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
-                                 TASK_INTERRUPTIBLE,
-                                 msecs_to_jiffies(5000));
-       if (err == -EINTR) {
-               bt_dev_err(hdev, "Firmware loading interrupted");
-               goto done;
-       }
-
-       if (err) {
-               bt_dev_err(hdev, "Firmware loading timeout");
-               err = -ETIMEDOUT;
+       err = btusb_download_wait(hdev, calltime, 5000);
+       if (err == -ETIMEDOUT)
                btintel_reset_to_bootloader(hdev);
-               goto done;
-       }
-
-       if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) {
-               bt_dev_err(hdev, "Firmware loading failed");
-               err = -ENOEXEC;
-               goto done;
-       }
 
 done:
        release_firmware(fw);
@@ -2614,41 +2595,11 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
        char fwname[64];
        int err;
        struct btusb_data *data = hci_get_drvdata(hdev);
+       ktime_t calltime;
 
        if (!ver || !params)
                return -EINVAL;
 
-       /* The hardware platform number has a fixed value of 0x37 and
-        * for now only accept this single value.
-        */
-       if (ver->hw_platform != 0x37) {
-               bt_dev_err(hdev, "Unsupported Intel hardware platform (%u)",
-                          ver->hw_platform);
-               return -EINVAL;
-       }
-
-       /* Check for supported iBT hardware variants of this firmware
-        * loading method.
-        *
-        * This check has been put in place to ensure correct forward
-        * compatibility options when newer hardware variants come along.
-        */
-       switch (ver->hw_variant) {
-       case 0x0b:      /* SfP */
-       case 0x0c:      /* WsP */
-       case 0x11:      /* JfP */
-       case 0x12:      /* ThP */
-       case 0x13:      /* HrP */
-       case 0x14:      /* CcP */
-               break;
-       default:
-               bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
-                          ver->hw_variant);
-               return -EINVAL;
-       }
-
-       btintel_version_info(hdev, ver);
-
        /* The firmware variant determines if the device is in bootloader
         * mode or is running operational firmware. The value 0x06 identifies
         * the bootloader and the value 0x23 identifies the operational
@@ -2665,16 +2616,18 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
        if (ver->fw_variant == 0x23) {
                clear_bit(BTUSB_BOOTLOADER, &data->flags);
                btintel_check_bdaddr(hdev);
-               return 0;
-       }
 
-       /* If the device is not in bootloader mode, then the only possible
-        * choice is to return an error and abort the device initialization.
-        */
-       if (ver->fw_variant != 0x06) {
-               bt_dev_err(hdev, "Unsupported Intel firmware variant (%u)",
-                          ver->fw_variant);
-               return -ENODEV;
+               /* SfP and WsP don't seem to update the firmware version on file
+                * so version checking is currently possible.
+                */
+               switch (ver->hw_variant) {
+               case 0x0b:      /* SfP */
+               case 0x0c:      /* WsP */
+                       return 0;
+               }
+
+               /* Proceed to download to check if the version matches */
+               goto download;
        }
 
        /* Read the secure boot parameters to identify the operating
@@ -2702,6 +2655,7 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
                set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
        }
 
+download:
        /* With this Intel bootloader only the hardware variant and device
         * revision information are used to select the right firmware for SfP
         * and WsP.
@@ -2725,14 +2679,15 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
         */
        err = btusb_setup_intel_new_get_fw_name(ver, params, fwname,
                                                sizeof(fwname), "sfi");
-       if (!err) {
+       if (err < 0) {
                bt_dev_err(hdev, "Unsupported Intel firmware naming");
                return -EINVAL;
        }
 
        err = request_firmware(&fw, fwname, &hdev->dev);
        if (err < 0) {
-               bt_dev_err(hdev, "Failed to load Intel firmware file (%d)", err);
+               bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
+                          fwname, err);
                return err;
        }
 
@@ -2745,20 +2700,26 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
                goto done;
        }
 
+       calltime = ktime_get();
+
        set_bit(BTUSB_DOWNLOADING, &data->flags);
 
        /* Start firmware downloading and get boot parameter */
-       err = btintel_download_firmware(hdev, fw, boot_param);
+       err = btintel_download_firmware(hdev, ver, fw, boot_param);
        if (err < 0) {
+               if (err == -EALREADY) {
+                       /* Firmware has already been loaded */
+                       set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+                       err = 0;
+                       goto done;
+               }
+
                /* When FW download fails, send Intel Reset to retry
                 * FW download.
                 */
                btintel_reset_to_bootloader(hdev);
                goto done;
        }
-       set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
-
-       bt_dev_info(hdev, "Waiting for firmware download to complete");
 
        /* Before switching the device into operational mode and with that
         * booting the loaded firmware, wait for the bootloader notification
@@ -2771,29 +2732,74 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
         * and thus just timeout if that happens and fail the setup
         * of this device.
         */
-       err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
+       err = btusb_download_wait(hdev, calltime, 5000);
+       if (err == -ETIMEDOUT)
+               btintel_reset_to_bootloader(hdev);
+
+done:
+       release_firmware(fw);
+       return err;
+}
+
+static int btusb_boot_wait(struct hci_dev *hdev, ktime_t calltime, int msec)
+{
+       struct btusb_data *data = hci_get_drvdata(hdev);
+       ktime_t delta, rettime;
+       unsigned long long duration;
+       int err;
+
+       bt_dev_info(hdev, "Waiting for device to boot");
+
+       err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
                                  TASK_INTERRUPTIBLE,
-                                 msecs_to_jiffies(5000));
+                                 msecs_to_jiffies(msec));
        if (err == -EINTR) {
-               bt_dev_err(hdev, "Firmware loading interrupted");
-               goto done;
+               bt_dev_err(hdev, "Device boot interrupted");
+               return -EINTR;
        }
 
        if (err) {
-               bt_dev_err(hdev, "Firmware loading timeout");
-               err = -ETIMEDOUT;
-               btintel_reset_to_bootloader(hdev);
-               goto done;
+               bt_dev_err(hdev, "Device boot timeout");
+               return -ETIMEDOUT;
        }
 
-       if (test_bit(BTUSB_FIRMWARE_FAILED, &data->flags)) {
-               bt_dev_err(hdev, "Firmware loading failed");
-               err = -ENOEXEC;
-               goto done;
+       rettime = ktime_get();
+       delta = ktime_sub(rettime, calltime);
+       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+
+       bt_dev_info(hdev, "Device booted in %llu usecs", duration);
+
+       return 0;
+}
+
+static int btusb_intel_boot(struct hci_dev *hdev, u32 boot_addr)
+{
+       struct btusb_data *data = hci_get_drvdata(hdev);
+       ktime_t calltime;
+       int err;
+
+       calltime = ktime_get();
+
+       set_bit(BTUSB_BOOTING, &data->flags);
+
+       err = btintel_send_intel_reset(hdev, boot_addr);
+       if (err) {
+               bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err);
+               btintel_reset_to_bootloader(hdev);
+               return err;
        }
 
-done:
-       release_firmware(fw);
+       /* The bootloader will not indicate when the device is ready. This
+        * is done by the operational firmware sending bootup notification.
+        *
+        * Booting into operational firmware should not take longer than
+        * 1 second. However if that happens, then just fail the setup
+        * since something went wrong.
+        */
+       err = btusb_boot_wait(hdev, calltime, 1000);
+       if (err == -ETIMEDOUT)
+               btintel_reset_to_bootloader(hdev);
+
        return err;
 }
 
@@ -2804,8 +2810,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
        struct intel_boot_params params;
        u32 boot_param;
        char ddcname[64];
-       ktime_t calltime, delta, rettime;
-       unsigned long long duration;
        int err;
        struct intel_debug_features features;
 
@@ -2817,8 +2821,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
         */
        boot_param = 0x00000000;
 
-       calltime = ktime_get();
-
        /* Read the Intel version information to determine if the device
         * is in bootloader mode or if it already has operational firmware
         * loaded.
@@ -2830,6 +2832,10 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
                return err;
        }
 
+       err = btintel_version_info(hdev, &ver);
+       if (err)
+               return err;
+
        err = btusb_intel_download_firmware(hdev, &ver, &params, &boot_param);
        if (err)
                return err;
@@ -2838,59 +2844,16 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
        if (ver.fw_variant == 0x23)
                goto finish;
 
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-
-       bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
-
-       calltime = ktime_get();
-
-       set_bit(BTUSB_BOOTING, &data->flags);
-
-       err = btintel_send_intel_reset(hdev, boot_param);
-       if (err) {
-               bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err);
-               btintel_reset_to_bootloader(hdev);
+       err = btusb_intel_boot(hdev, boot_param);
+       if (err)
                return err;
-       }
-
-       /* The bootloader will not indicate when the device is ready. This
-        * is done by the operational firmware sending bootup notification.
-        *
-        * Booting into operational firmware should not take longer than
-        * 1 second. However if that happens, then just fail the setup
-        * since something went wrong.
-        */
-       bt_dev_info(hdev, "Waiting for device to boot");
-
-       err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
-                                 TASK_INTERRUPTIBLE,
-                                 msecs_to_jiffies(1000));
-
-       if (err == -EINTR) {
-               bt_dev_err(hdev, "Device boot interrupted");
-               return -EINTR;
-       }
-
-       if (err) {
-               bt_dev_err(hdev, "Device boot timeout");
-               btintel_reset_to_bootloader(hdev);
-               return -ETIMEDOUT;
-       }
-
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-
-       bt_dev_info(hdev, "Device booted in %llu usecs", duration);
 
        clear_bit(BTUSB_BOOTLOADER, &data->flags);
 
        err = btusb_setup_intel_new_get_fw_name(&ver, &params, ddcname,
                                                sizeof(ddcname), "ddc");
 
-       if (!err) {
+       if (err < 0) {
                bt_dev_err(hdev, "Unsupported Intel firmware naming");
        } else {
                /* Once the device is running in operational mode, it needs to
@@ -2947,8 +2910,6 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev)
        struct btusb_data *data = hci_get_drvdata(hdev);
        u32 boot_param;
        char ddcname[64];
-       ktime_t calltime, delta, rettime;
-       unsigned long long duration;
        int err;
        struct intel_debug_features features;
        struct intel_version_tlv version;
@@ -2961,8 +2922,6 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev)
         */
        boot_param = 0x00000000;
 
-       calltime = ktime_get();
-
        /* Read the Intel version information to determine if the device
         * is in bootloader mode or if it already has operational firmware
         * loaded.
@@ -2974,7 +2933,9 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev)
                return err;
        }
 
-       btintel_version_info_tlv(hdev, &version);
+       err = btintel_version_info_tlv(hdev, &version);
+       if (err)
+               return err;
 
        err = btusb_intel_download_firmware_newgen(hdev, &version, &boot_param);
        if (err)
@@ -2984,52 +2945,9 @@ static int btusb_setup_intel_newgen(struct hci_dev *hdev)
        if (version.img_type == 0x03)
                goto finish;
 
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = (unsigned long long)ktime_to_ns(delta) >> 10;
-
-       bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
-
-       calltime = ktime_get();
-
-       set_bit(BTUSB_BOOTING, &data->flags);
-
-       err = btintel_send_intel_reset(hdev, boot_param);
-       if (err) {
-               bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err);
-               btintel_reset_to_bootloader(hdev);
+       err = btusb_intel_boot(hdev, boot_param);
+       if (err)
                return err;
-       }
-
-       /* The bootloader will not indicate when the device is ready. This
-        * is done by the operational firmware sending bootup notification.
-        *
-        * Booting into operational firmware should not take longer than
-        * 1 second. However if that happens, then just fail the setup
-        * since something went wrong.
-        */
-       bt_dev_info(hdev, "Waiting for device to boot");
-
-       err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
-                                 TASK_INTERRUPTIBLE,
-                                 msecs_to_jiffies(1000));
-
-       if (err == -EINTR) {
-               bt_dev_err(hdev, "Device boot interrupted");
-               return -EINTR;
-       }
-
-       if (err) {
-               bt_dev_err(hdev, "Device boot timeout");
-               btintel_reset_to_bootloader(hdev);
-               return -ETIMEDOUT;
-       }
-
-       rettime = ktime_get();
-       delta = ktime_sub(rettime, calltime);
-       duration = (unsigned long long)ktime_to_ns(delta) >> 10;
-
-       bt_dev_info(hdev, "Device booted in %llu usecs", duration);
 
        clear_bit(BTUSB_BOOTLOADER, &data->flags);
 
@@ -3495,7 +3413,7 @@ static int btusb_mtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwnam
        fw_ptr = fw->data;
        fw_bin_ptr = fw_ptr;
        globaldesc = (struct btmtk_global_desc *)(fw_ptr + MTK_FW_ROM_PATCH_HEADER_SIZE);
-       section_num = globaldesc->section_num;
+       section_num = le32_to_cpu(globaldesc->section_num);
 
        for (i = 0; i < section_num; i++) {
                first_block = 1;
@@ -3503,8 +3421,8 @@ static int btusb_mtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwnam
                sectionmap = (struct btmtk_section_map *)(fw_ptr + MTK_FW_ROM_PATCH_HEADER_SIZE +
                              MTK_FW_ROM_PATCH_GD_SIZE + MTK_FW_ROM_PATCH_SEC_MAP_SIZE * i);
 
-               section_offset = sectionmap->secoffset;
-               dl_size = sectionmap->bin_info_spec.dlsize;
+               section_offset = le32_to_cpu(sectionmap->secoffset);
+               dl_size = le32_to_cpu(sectionmap->bin_info_spec.dlsize);
 
                if (dl_size > 0) {
                        retry = 20;
@@ -3740,7 +3658,7 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
        int err, status;
        u32 dev_id;
        char fw_bin_name[64];
-       u32 fw_version;
+       u32 fw_version = 0;
        u8 param;
 
        calltime = ktime_get();