linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: Add shutdown callback before closing the device
@ 2015-02-05 19:44 Tedd Ho-Jeong An
  2015-02-12 19:48 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Tedd Ho-Jeong An @ 2015-02-05 19:44 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org; +Cc: An, Tedd, Johan Hedberg, Marcel Holtmann

From: Tedd Ho-Jeong An <tedd.an@intel.com>

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

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
---
 include/net/bluetooth/hci_core.h | 1 +
 net/bluetooth/hci_core.c         | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 52863c3..1d868b2 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -377,6 +377,7 @@ struct hci_dev {
 	void (*notify)(struct hci_dev *hdev, unsigned int evt);
 	void (*hw_error)(struct hci_dev *hdev, u8 code);
 	int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
+	int (*shutdown)(struct hci_dev *hdev);
 };
 
 #define HCI_PHY_HANDLE(handle)	(handle & 0xff)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3322d3f..d151aef 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1591,6 +1591,10 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 {
 	BT_DBG("%s %p", hdev->name, hdev);
 
+	/* allows vendors to send the command before close the device */
+	if (!test_bit(HCI_UNREGISTER, &hdev->dev_flags) && hdev->shutdown)
+		hdev->shutdown(hdev);
+
 	cancel_delayed_work(&hdev->power_off);
 
 	hci_req_cancel(hdev, ENODEV);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] Bluetooth: Add shutdown callback before closing the device
  2015-02-05 19:44 [PATCH 1/2] Bluetooth: Add shutdown callback before closing the device Tedd Ho-Jeong An
@ 2015-02-12 19:48 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2015-02-12 19:48 UTC (permalink / raw)
  To: Tedd Ho-Jeong An; +Cc: linux-bluetooth@vger.kernel.org, Johan Hedberg

Hi Tedd,

> This callback allows a vendor to send the vendor specific commands
> before cloing the hci interface.
> 
> Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_core.c         | 4 ++++
> 2 files changed, 5 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 52863c3..1d868b2 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -377,6 +377,7 @@ struct hci_dev {
> 	void (*notify)(struct hci_dev *hdev, unsigned int evt);
> 	void (*hw_error)(struct hci_dev *hdev, u8 code);
> 	int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
> +	int (*shutdown)(struct hci_dev *hdev);

I think we should move the shutdown higher up. So after setup() should be a good place.

> };
> 
> #define HCI_PHY_HANDLE(handle)	(handle & 0xff)
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 3322d3f..d151aef 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1591,6 +1591,10 @@ static int hci_dev_do_close(struct hci_dev *hdev)
> {
> 	BT_DBG("%s %p", hdev->name, hdev);
> 
> +	/* allows vendors to send the command before close the device */
> +	if (!test_bit(HCI_UNREGISTER, &hdev->dev_flags) && hdev->shutdown)
> +		hdev->shutdown(hdev);
> +

	if (!test_bit()) {
		/* ..... */
		if (hdev->shutdown)
			hdev->shutdown(hdev);
	}

I know this is the same code, but I prefer to have the check for the function pointer provided a little bit close to the call so that it is really obvious.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-12 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05 19:44 [PATCH 1/2] Bluetooth: Add shutdown callback before closing the device Tedd Ho-Jeong An
2015-02-12 19:48 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).