Bluetooth: Introduce driver specific post init callback
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 20 Oct 2015 21:25:42 +0000 (23:25 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 21 Oct 2015 04:30:53 +0000 (07:30 +0300)
Some drivers might have to restore certain settings after the init
procedure has been completed. This driver callback allows them to hook
into that stage. This callback is run just before the controller is
declared as powered up.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c

index 989c72aabc455dffc40ebbfe75550442348d809c..44fb95685611688e2b5c7d05aeded9bbbfd655f1 100644 (file)
@@ -398,6 +398,7 @@ struct hci_dev {
        int (*send)(struct hci_dev *hdev, struct sk_buff *skb);
        void (*notify)(struct hci_dev *hdev, unsigned int evt);
        void (*hw_error)(struct hci_dev *hdev, u8 code);
+       int (*post_init)(struct hci_dev *hdev);
        int (*set_diag)(struct hci_dev *hdev, bool enable);
        int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
 };
index ac5cb251f9fb5037a5e34f31f71afdca01b646eb..964fba4c96bfa7944194463d6de50f82cfae86fe 100644 (file)
@@ -1503,8 +1503,11 @@ static int hci_dev_do_open(struct hci_dev *hdev)
 
        if (!ret) {
                if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED) &&
-                   !hci_dev_test_flag(hdev, HCI_USER_CHANNEL))
+                   !hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) {
                        ret = __hci_init(hdev);
+                       if (!ret && hdev->post_init)
+                               ret = hdev->post_init(hdev);
+               }
        }
 
        /* If the HCI Reset command is clearing all diagnostic settings,