Bluetooth: btbcm: Allow using btbcm_initialize() for reinit
authorHans de Goede <hdegoede@redhat.com>
Fri, 20 Apr 2018 12:44:05 +0000 (14:44 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 18 May 2018 04:37:51 +0000 (06:37 +0200)
btbcm_finalize() does a re-init of the controller, which is almost the
same as the initial init. Modify btbcm_initialize() so that it can be
used for this re-init and modify btbcm_finalize() to use it.

As an added bonus this also makes the dev_info from btbcm_finalize()
use the proper hw_name instead of always printing "BCM".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btbcm.c
drivers/bluetooth/btbcm.h
drivers/bluetooth/hci_bcm.c

index dd243afe32de061d21b167439b2b2312cd564b0f..fdcbeb489a2e54d92e302aaf2143ec0c9c159dad 100644 (file)
@@ -346,7 +346,8 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
        { }
 };
 
-int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len)
+int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len,
+                    bool reinit)
 {
        u16 subver, rev, pid, vid;
        const char *hw_name = NULL;
@@ -371,9 +372,11 @@ int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len)
        kfree_skb(skb);
 
        /* Read controller information */
-       err = btbcm_read_info(hdev);
-       if (err)
-               return err;
+       if (!reinit) {
+               err = btbcm_read_info(hdev);
+               if (err)
+                       return err;
+       }
 
        /* Upper nibble of rev should be between 0 and 3? */
        if (((rev & 0xf000) >> 12) > 3)
@@ -416,30 +419,14 @@ EXPORT_SYMBOL_GPL(btbcm_initialize);
 
 int btbcm_finalize(struct hci_dev *hdev)
 {
-       struct sk_buff *skb;
-       struct hci_rp_read_local_version *ver;
-       u16 subver, rev;
+       char fw_name[64];
        int err;
 
-       /* Reset */
-       err = btbcm_reset(hdev);
+       /* Re-initialize */
+       err = btbcm_initialize(hdev, fw_name, sizeof(fw_name), true);
        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);
-
-       bt_dev_info(hdev, "BCM (%3.3u.%3.3u.%3.3u) build %4.4u",
-                   (subver & 0xe000) >> 13, (subver & 0x1f00) >> 8,
-                   (subver & 0x00ff), rev & 0x0fff);
-
        btbcm_check_bdaddr(hdev);
 
        set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
index cfe6ad4cc62153d59e0b7b2b88f6132e7604b31e..5346515c880c6582131a770e74af9f2de49825b2 100644 (file)
@@ -73,7 +73,8 @@ int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fw);
 int btbcm_setup_patchram(struct hci_dev *hdev);
 int btbcm_setup_apple(struct hci_dev *hdev);
 
-int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len);
+int btbcm_initialize(struct hci_dev *hdev, char *fw_name, size_t len,
+                    bool reinit);
 int btbcm_finalize(struct hci_dev *hdev);
 
 #else
@@ -104,7 +105,7 @@ static inline int btbcm_setup_apple(struct hci_dev *hdev)
 }
 
 static inline int btbcm_initialize(struct hci_dev *hdev, char *fw_name,
-                                  size_t len)
+                                  size_t len, bool reinit)
 {
        return 0;
 }
index 04c4b93b4c6f292b878cf078d31b022c2bc582cc..f06f0f1132fb4f804767e037c5393ce1e7930723 100644 (file)
@@ -501,7 +501,7 @@ static int bcm_setup(struct hci_uart *hu)
        hu->hdev->set_diag = bcm_set_diag;
        hu->hdev->set_bdaddr = btbcm_set_bdaddr;
 
-       err = btbcm_initialize(hu->hdev, fw_name, sizeof(fw_name));
+       err = btbcm_initialize(hu->hdev, fw_name, sizeof(fw_name), false);
        if (err)
                return err;