@@ -902,6 +902,10 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
void hci_le_conn_failed(struct hci_conn *conn, u8 status);
+int register_hci_dev_notifier(struct notifier_block *nb);
+void unregister_hci_dev_notifier(struct notifier_block *nb);
+int call_hci_dev_notifiers(unsigned long val, struct hci_dev *hdev);
+
/*
* hci_conn_get() and hci_conn_put() are used to control the life-time of an
* "hci_conn" object. They do not guarantee that the hci_conn object is running,
@@ -57,6 +57,28 @@ DEFINE_MUTEX(hci_cb_list_lock);
/* HCI ID Numbering */
static DEFINE_IDA(hci_index_ida);
+/* HCI device notifier list */
+static RAW_NOTIFIER_HEAD(hci_dev_chain);
+
+/* ---- HCI notifiers functions ---- */
+
+int register_hci_dev_notifier(struct notifier_block *nb)
+{
+ return raw_notifier_chain_register(&hci_dev_chain, nb);
+}
+EXPORT_SYMBOL(register_hci_dev_notifier);
+
+void unregister_hci_dev_notifier(struct notifier_block *nb)
+{
+ raw_notifier_chain_unregister(&hci_dev_chain, nb);
+}
+EXPORT_SYMBOL(unregister_hci_dev_notifier);
+
+int call_hci_dev_notifiers(unsigned long val, struct hci_dev *hdev)
+{
+ return raw_notifier_call_chain(&hci_dev_chain, val, hdev);
+}
+
/* ---- HCI debugfs entries ---- */
static ssize_t dut_mode_read(struct file *file, char __user *user_buf,
@@ -529,6 +529,8 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event)
}
read_unlock(&hci_sk_list.lock);
}
+
+ call_hci_dev_notifiers(event, hdev);
}
static struct hci_mgmt_chan *__hci_mgmt_chan_find(unsigned short channel)
I need to react at least somehow on a hci dev unregister event to clean all 6LoWPAN interfaces on it. This patch adds a notifier for non socket stuff. I also thought about to react somehow on "struct device" unregister but I didn't found any functionality for that. Signed-off-by: Alexander Aring <aar@pengutronix.de> --- include/net/bluetooth/hci_core.h | 4 ++++ net/bluetooth/hci_core.c | 22 ++++++++++++++++++++++ net/bluetooth/hci_sock.c | 2 ++ 3 files changed, 28 insertions(+)