Bluetooth: Introduce HCI_DEV_OPEN and HCI_DEV_CLOSE events
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 4 Oct 2015 21:34:00 +0000 (23:34 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 5 Oct 2015 07:29:36 +0000 (10:29 +0300)
When opening the HCI transport via hdev->open send HCI_DEV_OPEN event
and when closing the HCI transport via hdev->close send HCI_DEV_CLOSE.

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

index 7ca6690355ea08acd54aa87b3302f78702c206c7..e7f938cac7c663b207e5f8bbbdbe65058f0bd491 100644 (file)
@@ -44,6 +44,8 @@
 #define HCI_DEV_DOWN                   4
 #define HCI_DEV_SUSPEND                        5
 #define HCI_DEV_RESUME                 6
+#define HCI_DEV_OPEN                   7
+#define HCI_DEV_CLOSE                  8
 
 /* HCI notify events */
 #define HCI_NOTIFY_CONN_ADD            1
index 79356469c3775be6d36e966f73918ab08bffeb8a..5af33c87cbbadfe5d80cd6241eb607acb16bc224 100644 (file)
@@ -1385,6 +1385,8 @@ static int hci_dev_do_open(struct hci_dev *hdev)
                goto done;
        }
 
+       hci_notify(hdev, HCI_DEV_OPEN);
+
        atomic_set(&hdev->cmd_cnt, 1);
        set_bit(HCI_INIT, &hdev->flags);
 
@@ -1466,6 +1468,8 @@ static int hci_dev_do_open(struct hci_dev *hdev)
                        hdev->sent_cmd = NULL;
                }
 
+               hci_notify(hdev, HCI_DEV_CLOSE);
+
                hdev->close(hdev);
                hdev->flags &= BIT(HCI_RAW);
        }
@@ -1649,6 +1653,8 @@ int hci_dev_do_close(struct hci_dev *hdev)
                hdev->sent_cmd = NULL;
        }
 
+       hci_notify(hdev, HCI_DEV_CLOSE);
+
        /* After this point our queues are empty
         * and no tasks are scheduled. */
        hdev->close(hdev);