Bluetooth: btbcm: Stop using upper nibble of rev to chose between uart/USB paths

btbcm_setup_patchram() was using the upper nibble of the revision code to
determine if we are dealing with an uart or USB connected bcm-bt device,
but just as btbcm_initialize() has started accepting 1 and 2 as uart
connected devices, I've now encountered an USB connected device (0a5c:216c)
which has 0 in the upper nibble. So it seems that the upper nibble is not
really a reliable indicator of the bus type.

Instead check hdev->bus which does give us a reliable indication. This
fixes the patchram code trying to load the patchram by the fallback BCM.hcd
filename, now it correctly requests BCM43142A0-0a5c-216c.hcd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Hans de Goede 2018-04-20 14:44:02 +02:00 коммит произвёл Marcel Holtmann
Родитель 05ba533c5c
Коммит 1b2525c05b
1 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -465,9 +465,11 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
if (err) if (err)
return err; return err;
switch ((rev & 0xf000) >> 12) { /* Upper nibble of rev should be between 0 and 3? */
case 0: if (((rev & 0xf000) >> 12) > 3)
case 3: return 0;
if (hdev->bus != HCI_USB) {
for (i = 0; bcm_uart_subver_table[i].name; i++) { for (i = 0; bcm_uart_subver_table[i].name; i++) {
if (subver == bcm_uart_subver_table[i].subver) { if (subver == bcm_uart_subver_table[i].subver) {
hw_name = bcm_uart_subver_table[i].name; hw_name = bcm_uart_subver_table[i].name;
@ -477,9 +479,7 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
snprintf(fw_name, sizeof(fw_name), "brcm/%s.hcd", snprintf(fw_name, sizeof(fw_name), "brcm/%s.hcd",
hw_name ? : "BCM"); hw_name ? : "BCM");
break; } else {
case 1:
case 2:
/* Read USB Product Info */ /* Read USB Product Info */
skb = btbcm_read_usb_product(hdev); skb = btbcm_read_usb_product(hdev);
if (IS_ERR(skb)) if (IS_ERR(skb))
@ -498,9 +498,6 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
snprintf(fw_name, sizeof(fw_name), "brcm/%s-%4.4x-%4.4x.hcd", snprintf(fw_name, sizeof(fw_name), "brcm/%s-%4.4x-%4.4x.hcd",
hw_name ? : "BCM", vid, pid); hw_name ? : "BCM", vid, pid);
break;
default:
return 0;
} }
bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u", bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",