]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Bluetooth: btbcm: Consolidate the controller information commands
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 17 Aug 2017 09:02:40 +0000 (11:02 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 17 Aug 2017 09:11:24 +0000 (12:11 +0300)
The commands that read the basic vendor information about the Broadcom
controller are duplicated for UART and USB devices. Combine them into a
single function to reduce the code complexity.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
drivers/bluetooth/btbcm.c

index 9ab6cfbb831d81b8f533b35bd4b27161a6f5ef76..cc4bdefa6648b8776b12c7e3f3587d5ecc46aad0 100644 (file)
@@ -287,6 +287,37 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
        return skb;
 }
 
+static int btbcm_read_info(struct hci_dev *hdev)
+{
+       struct sk_buff *skb;
+
+       /* Read Verbose Config Version Info */
+       skb = btbcm_read_verbose_config(hdev);
+       if (IS_ERR(skb))
+               return PTR_ERR(skb);
+
+       BT_INFO("%s: BCM: chip id %u", hdev->name, skb->data[1]);
+       kfree_skb(skb);
+
+       /* Read Controller Features */
+       skb = btbcm_read_controller_features(hdev);
+       if (IS_ERR(skb))
+               return PTR_ERR(skb);
+
+       BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]);
+       kfree_skb(skb);
+
+       /* Read Local Name */
+       skb = btbcm_read_local_name(hdev);
+       if (IS_ERR(skb))
+               return PTR_ERR(skb);
+
+       BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1));
+       kfree_skb(skb);
+
+       return 0;
+}
+
 static const struct {
        u16 subver;
        const char *name;
@@ -322,13 +353,10 @@ int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len)
        subver = le16_to_cpu(ver->lmp_subver);
        kfree_skb(skb);
 
-       /* Read Verbose Config Version Info */
-       skb = btbcm_read_verbose_config(hdev);
-       if (IS_ERR(skb))
-               return PTR_ERR(skb);
-
-       BT_INFO("%s: BCM: chip id %u", hdev->name, skb->data[1]);
-       kfree_skb(skb);
+       /* Read controller information */
+       err = btbcm_read_info(hdev);
+       if (err)
+               return err;
 
        switch ((rev & 0xf000) >> 12) {
        case 0:
@@ -431,29 +459,10 @@ int btbcm_setup_patchram(struct hci_dev *hdev)
        subver = le16_to_cpu(ver->lmp_subver);
        kfree_skb(skb);
 
-       /* Read Verbose Config Version Info */
-       skb = btbcm_read_verbose_config(hdev);
-       if (IS_ERR(skb))
-               return PTR_ERR(skb);
-
-       BT_INFO("%s: BCM: chip id %u", hdev->name, skb->data[1]);
-       kfree_skb(skb);
-
-       /* Read Controller Features */
-       skb = btbcm_read_controller_features(hdev);
-       if (IS_ERR(skb))
-               return PTR_ERR(skb);
-
-       BT_INFO("%s: BCM: features 0x%2.2x", hdev->name, skb->data[1]);
-       kfree_skb(skb);
-
-       /* Read Local Name */
-       skb = btbcm_read_local_name(hdev);
-       if (IS_ERR(skb))
-               return PTR_ERR(skb);
-
-       BT_INFO("%s: %s", hdev->name, (char *)(skb->data + 1));
-       kfree_skb(skb);
+       /* Read controller information */
+       err = btbcm_read_info(hdev);
+       if (err)
+               return err;
 
        switch ((rev & 0xf000) >> 12) {
        case 0: