Skip to contentSkip to conversation

Bluetooth: Add shutdown callback before closing the device

PATCH In review Tedd Ho-Jeong An 2 participants 2 messages Feb 13, 2015 – Feb 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Bluetooth: Add shutdown callback before closing the device

From: Tedd Ho-Jeong An <[email protected]>

This callback allows a vendor to send the vendor specific commands before cloing the hci interface.

---
 include/net/bluetooth/hci_core.h | 1 +
 net/bluetooth/hci_core.c         | 5 +++++
 2 files changed, 6 insertions(+)
include/net/bluetooth/hci_core.h +1 -0
index 52863c3..5f1ca33 100644
@@ -373,6 +373,7 @@ struct hci_dev {
 	int (*close)(struct hci_dev *hdev);
 	int (*flush)(struct hci_dev *hdev);
 	int (*setup)(struct hci_dev *hdev);
+	int (*shutdown)(struct hci_dev *hdev);
 	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);
net/bluetooth/hci_core.c +5 -0
index 3322d3f..4611a04 100644
@@ -1591,6 +1591,11 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 {
 	BT_DBG("%s %p", hdev->name, hdev);
 
+	if (!test_bit(HCI_UNREGISTER, &hdev->dev_flags)) {
+		/* Execute vendor specific shutdown routine */
+		if (hdev->shutdown)
+			hdev->shutdown(hdev);
+	}
 	cancel_delayed_work(&hdev->power_off);
 
 	hci_req_cancel(hdev, ENODEV);
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Hi Tedd,

Quoted 26 lines

This callback allows a vendor to send the vendor specific commands before cloing the hci interface.

---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 5 +++++

2 files changed, 6 insertions(+)
include/net/bluetooth/hci_core.h +1 -0
index 52863c3..5f1ca33 100644
@@ -373,6 +373,7 @@ struct hci_dev {
 	int (*close)(struct hci_dev *hdev);
 	int (*flush)(struct hci_dev *hdev);
 	int (*setup)(struct hci_dev *hdev);
+	int (*shutdown)(struct hci_dev *hdev);
 	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);
net/bluetooth/hci_core.c +0 -0
index 3322d3f..4611a04 100644

net/bluetooth/hci_core.c static int hci_dev_do_close(struct hci_dev *hdev) · line 1598

Quoted 8 lines
net/bluetooth/hci_core.c +5 -0
@@ -1591,6 +1591,11 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 {
 	BT_DBG("%s %p", hdev->name, hdev);
 
+	if (!test_bit(HCI_UNREGISTER, &hdev->dev_flags)) {
+		/* Execute vendor specific shutdown routine */
+		if (hdev->shutdown)
+			hdev->shutdown(hdev);
+	}

you should have had an extra empty line here. I fixed that for you.

net/bluetooth/hci_core.c static int hci_dev_do_close(struct hci_dev *hdev) · line 1601

Quoted 3 lines
net/bluetooth/hci_core.c +0 -0
 	cancel_delayed_work(&hdev->power_off);
 
 	hci_req_cancel(hdev, ENODEV);

Patch has been applied to bluetooth-next tree.

Regards

Marcel