Commit bf906b3d authored by Kim, Ben Young Tae's avatar Kim, Ben Young Tae Committed by Marcel Holtmann

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: default avatarBen Young Tae Kim <ytkim@qca.qualcomm.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 55e76b38
...@@ -2667,10 +2667,10 @@ struct qca_rampatch_version { ...@@ -2667,10 +2667,10 @@ struct qca_rampatch_version {
} __packed; } __packed;
struct qca_device_info { struct qca_device_info {
__le32 rom_version; u32 rom_version;
__u8 rampatch_hdr; /* length of header in rampatch */ u8 rampatch_hdr; /* length of header in rampatch */
__u8 nvm_hdr; /* length of header in NVM */ u8 nvm_hdr; /* length of header in NVM */
__u8 ver_offset; /* offset of version structure in rampatch */ u8 ver_offset; /* offset of version structure in rampatch */
}; };
static const struct qca_device_info qca_devices_table[] = { 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,11 +2782,15 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
{ {
struct qca_rampatch_version *rver; struct qca_rampatch_version *rver;
const struct firmware *fw; const struct firmware *fw;
u32 ver_rom, ver_patch;
u16 rver_rom, rver_patch;
char fwname[64]; char fwname[64];
int err; int err;
snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", ver_rom = le32_to_cpu(ver->rom_version);
le32_to_cpu(ver->rom_version)); ver_patch = le32_to_cpu(ver->patch_version);
snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin", ver_rom);
err = request_firmware(&fw, fwname, &hdev->dev); err = request_firmware(&fw, fwname, &hdev->dev);
if (err) { if (err) {
...@@ -2796,14 +2800,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev, ...@@ -2796,14 +2800,16 @@ static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
} }
BT_INFO("%s: using rampatch file: %s", hdev->name, fwname); BT_INFO("%s: using rampatch file: %s", hdev->name, fwname);
rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset);
rver_rom = le16_to_cpu(rver->rom_version);
rver_patch = le16_to_cpu(rver->patch_version);
BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x " BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x "
"build 0x%x", hdev->name, le16_to_cpu(rver->rom_version), "build 0x%x", hdev->name, rver_rom, rver_patch, ver_rom,
le16_to_cpu(rver->patch_version), le32_to_cpu(ver->rom_version), ver_patch);
le32_to_cpu(ver->patch_version));
if (rver->rom_version != ver->rom_version || if (rver_rom != ver_rom || rver_patch <= ver_patch) {
rver->patch_version <= ver->patch_version) {
BT_ERR("%s: rampatch file version did not match with firmware", BT_ERR("%s: rampatch file version did not match with firmware",
hdev->name); hdev->name);
err = -EINVAL; err = -EINVAL;
...@@ -2849,6 +2855,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) ...@@ -2849,6 +2855,7 @@ static int btusb_setup_qca(struct hci_dev *hdev)
{ {
const struct qca_device_info *info = NULL; const struct qca_device_info *info = NULL;
struct qca_version ver; struct qca_version ver;
u32 ver_rom;
u8 status; u8 status;
int i, err; int i, err;
...@@ -2857,13 +2864,14 @@ static int btusb_setup_qca(struct hci_dev *hdev) ...@@ -2857,13 +2864,14 @@ static int btusb_setup_qca(struct hci_dev *hdev)
if (err < 0) if (err < 0)
return err; return err;
ver_rom = le32_to_cpu(ver.rom_version);
for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) {
if (ver.rom_version == qca_devices_table[i].rom_version) if (ver_rom == qca_devices_table[i].rom_version)
info = &qca_devices_table[i]; info = &qca_devices_table[i];
} }
if (!info) { if (!info) {
BT_ERR("%s: don't support firmware rome 0x%x", hdev->name, BT_ERR("%s: don't support firmware rome 0x%x", hdev->name,
le32_to_cpu(ver.rom_version)); ver_rom);
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment