Commit 59ce5699 authored by Hans de Goede's avatar Hans de Goede Committed by Marcel Holtmann

Bluetooth: btbcm: Remove duplicate code from btbcm_setup_patchram()

btbcm_setup_patchram() starts with initializing the controller (and
getting the firmware filename) and then after loading the firmware,
does a re-init. This almost entirely duplicates the code in
btbcm_initialize(), use that function instead.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 22ac1916
...@@ -439,68 +439,14 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -439,68 +439,14 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
{ {
char fw_name[64]; char fw_name[64];
const struct firmware *fw; const struct firmware *fw;
u16 subver, rev, pid, vid;
const char *hw_name = NULL;
struct sk_buff *skb; struct sk_buff *skb;
struct hci_rp_read_local_version *ver; int err;
const struct bcm_subver_table *bcm_subver_table;
int i, err;
/* Reset */
err = btbcm_reset(hdev);
if (err)
return err;
/* Read Local Version Info */
skb = btbcm_read_local_version(hdev);
if (IS_ERR(skb))
return PTR_ERR(skb);
ver = (struct hci_rp_read_local_version *)skb->data;
rev = le16_to_cpu(ver->hci_rev);
subver = le16_to_cpu(ver->lmp_subver);
kfree_skb(skb);
/* Read controller information */ /* Initialize */
err = btbcm_read_info(hdev); err = btbcm_initialize(hdev, fw_name, sizeof(fw_name), false);
if (err) if (err)
return err; return err;
/* Upper nibble of rev should be between 0 and 3? */
if (((rev & 0xf000) >> 12) > 3)
return 0;
bcm_subver_table = (hdev->bus == HCI_USB) ? bcm_usb_subver_table :
bcm_uart_subver_table;
for (i = 0; bcm_subver_table[i].name; i++) {
if (subver == bcm_subver_table[i].subver) {
hw_name = bcm_subver_table[i].name;
break;
}
}
if (hdev->bus == HCI_USB) {
/* Read USB Product Info */
skb = btbcm_read_usb_product(hdev);
if (IS_ERR(skb))
return PTR_ERR(skb);
vid = get_unaligned_le16(skb->data + 1);
pid = get_unaligned_le16(skb->data + 3);
kfree_skb(skb);
snprintf(fw_name, sizeof(fw_name), "brcm/%s-%4.4x-%4.4x.hcd",
hw_name ? : "BCM", vid, pid);
} else {
snprintf(fw_name, sizeof(fw_name), "brcm/%s.hcd",
hw_name ? : "BCM");
}
bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
hw_name ? : "BCM", (subver & 0xe000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
err = request_firmware(&fw, fw_name, &hdev->dev); err = request_firmware(&fw, fw_name, &hdev->dev);
if (err < 0) { if (err < 0) {
bt_dev_info(hdev, "BCM: Patch %s not found", fw_name); bt_dev_info(hdev, "BCM: Patch %s not found", fw_name);
...@@ -511,25 +457,11 @@ int btbcm_setup_patchram(struct hci_dev *hdev) ...@@ -511,25 +457,11 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
release_firmware(fw); release_firmware(fw);
/* Reset */ /* Re-initialize */
err = btbcm_reset(hdev); err = btbcm_initialize(hdev, fw_name, sizeof(fw_name), true);
if (err) if (err)
return err; return err;
/* Read Local Version Info */
skb = btbcm_read_local_version(hdev);
if (IS_ERR(skb))
return PTR_ERR(skb);
ver = (struct hci_rp_read_local_version *)skb->data;
rev = le16_to_cpu(ver->hci_rev);
subver = le16_to_cpu(ver->lmp_subver);
kfree_skb(skb);
bt_dev_info(hdev, "%s (%3.3u.%3.3u.%3.3u) build %4.4u",
hw_name ? : "BCM", (subver & 0xe000) >> 13,
(subver & 0x1f00) >> 8, (subver & 0x00ff), rev & 0x0fff);
/* Read Local Name */ /* Read Local Name */
skb = btbcm_read_local_name(hdev); skb = btbcm_read_local_name(hdev);
if (IS_ERR(skb)) if (IS_ERR(skb))
......
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