diff options
| author | Kim, Ben Young Tae <ytkim@qca.qualcomm.com> | 2015-03-10 19:34:58 -0400 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2015-03-10 22:57:01 -0400 |
| commit | bf906b3db3c2b4f5d4db1db5f35796629c531ac4 (patch) | |
| tree | e3b5773f6bb1f864aa0c8cdcd7bcab1ab8f47df9 | |
| parent | 55e76b38986a61259f3079afd0f9a865651a34fe (diff) | |
Bluetooth: btusb: Fix incorrect type in qca_device_info
While qca_device_info is not coming from outside communication,
no reason to use specific endian type inside and fix the wrong
version comparison on big-endian platform.
Signed-off-by: Ben Young Tae Kim <ytkim@qca.qualcomm.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
| -rw-r--r-- | drivers/bluetooth/btusb.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 08330548f7fe..c34a875aaf60 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
| @@ -2667,10 +2667,10 @@ struct qca_rampatch_version { | |||
| 2667 | } __packed; | 2667 | } __packed; |
| 2668 | 2668 | ||
| 2669 | struct qca_device_info { | 2669 | struct qca_device_info { |
| 2670 | __le32 rom_version; | 2670 | u32 rom_version; |
| 2671 | __u8 rampatch_hdr; /* length of header in rampatch */ | 2671 | u8 rampatch_hdr; /* length of header in rampatch */ |
| 2672 | __u8 nvm_hdr; /* length of header in NVM */ | 2672 | u8 nvm_hdr; /* length of header in NVM */ |
| 2673 | __u8 ver_offset; /* offset of version structure in rampatch */ | 2673 | u8 ver_offset; /* offset of version structure in rampatch */ |
| 2674 | }; | 2674 | }; |
| 2675 | 2675 | ||
| 2676 | static const struct qca_device_info qca_devices_table[] = { | 2676 | static const struct qca_device_info qca_devices_table[] = { |
| @@ -2782,11 +2782,15 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, | |||
| 2782 | { | 2782 | { |
| 2783 | struct qca_rampatch_version *rver; | 2783 | struct qca_rampatch_version *rver; |
| 2784 | const struct firmware *fw; | 2784 | const struct firmware *fw; |
| 2785 | u32 ver_rom, ver_patch; | ||
| 2786 | u16 rver_rom, rver_patch; | ||
| 2785 | char fwname[64]; | 2787 | char fwname[64]; |
| 2786 | int err; | 2788 | int err; |
| 2787 | 2789 | ||
| 2788 | snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", | 2790 | ver_rom = le32_to_cpu(ver->rom_version); |
| 2789 | le32_to_cpu(ver->rom_version)); | 2791 | ver_patch = le32_to_cpu(ver->patch_version); |
| 2792 | |||
| 2793 | snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", ver_rom); | ||
| 2790 | 2794 | ||
| 2791 | err = request_firmware(&fw, fwname, &hdev->dev); | 2795 | err = request_firmware(&fw, fwname, &hdev->dev); |
| 2792 | if (err) { | 2796 | if (err) { |
| @@ -2796,14 +2800,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, | |||
| 2796 | } | 2800 | } |
| 2797 | 2801 | ||
| 2798 | BT_INFO("%s: using rampatch file: %s", hdev->name, fwname); | 2802 | BT_INFO("%s: using rampatch file: %s", hdev->name, fwname); |
| 2803 | |||
| 2799 | rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); | 2804 | rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); |
| 2805 | rver_rom = le16_to_cpu(rver->rom_version); | ||
| 2806 | rver_patch = le16_to_cpu(rver->patch_version); | ||
| 2807 | |||
| 2800 | BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x " | 2808 | BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x " |
| 2801 | "build 0x%x", hdev->name, le16_to_cpu(rver->rom_version), | 2809 | "build 0x%x", hdev->name, rver_rom, rver_patch, ver_rom, |
| 2802 | le16_to_cpu(rver->patch_version), le32_to_cpu(ver->rom_version), | 2810 | ver_patch); |
| 2803 | le32_to_cpu(ver->patch_version)); | ||
| 2804 | 2811 | ||
| 2805 | if (rver->rom_version != ver->rom_version || | 2812 | if (rver_rom != ver_rom || rver_patch <= ver_patch) { |
| 2806 | rver->patch_version <= ver->patch_version) { | ||
| 2807 | BT_ERR("%s: rampatch file version did not match with firmware", | 2813 | BT_ERR("%s: rampatch file version did not match with firmware", |
| 2808 | hdev->name); | 2814 | hdev->name); |
| 2809 | err = -EINVAL; | 2815 | err = -EINVAL; |
| @@ -2849,6 +2855,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) | |||
| 2849 | { | 2855 | { |
| 2850 | const struct qca_device_info *info = NULL; | 2856 | const struct qca_device_info *info = NULL; |
| 2851 | struct qca_version ver; | 2857 | struct qca_version ver; |
| 2858 | u32 ver_rom; | ||
| 2852 | u8 status; | 2859 | u8 status; |
| 2853 | int i, err; | 2860 | int i, err; |
| 2854 | 2861 | ||
| @@ -2857,13 +2864,14 @@ static int btusb_setup_qca(struct hci_dev *hdev) | |||
| 2857 | if (err < 0) | 2864 | if (err < 0) |
| 2858 | return err; | 2865 | return err; |
| 2859 | 2866 | ||
| 2867 | ver_rom = le32_to_cpu(ver.rom_version); | ||
| 2860 | for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { | 2868 | for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { |
| 2861 | if (ver.rom_version == qca_devices_table[i].rom_version) | 2869 | if (ver_rom == qca_devices_table[i].rom_version) |
| 2862 | info = &qca_devices_table[i]; | 2870 | info = &qca_devices_table[i]; |
| 2863 | } | 2871 | } |
| 2864 | if (!info) { | 2872 | if (!info) { |
| 2865 | BT_ERR("%s: don't support firmware rome 0x%x", hdev->name, | 2873 | BT_ERR("%s: don't support firmware rome 0x%x", hdev->name, |
| 2866 | le32_to_cpu(ver.rom_version)); | 2874 | ver_rom); |
| 2867 | return -ENODEV; | 2875 | return -ENODEV; |
| 2868 | } | 2876 | } |
| 2869 | 2877 | ||
