Linux bluetooth development
 help / color / mirror / Atom feed
* [RFC v9 01/10] Bluetooth: Create hci_req_add_le_scan_disable helper
@ 2014-02-18 17:54 Andre Guedes
  2014-02-18 17:54 ` [RFC v9 02/10] Bluetooth: Declare le_conn_failed in hci_core.h Andre Guedes
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Andre Guedes @ 2014-02-18 17:54 UTC (permalink / raw)
  To: linux-bluetooth

This patch moves stop LE scanning duplicate code to one single
place and reuses it. This will avoid more duplicate code in
upcoming patches.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_core.c         | 14 ++++++++++----
 net/bluetooth/mgmt.c             |  6 +-----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4461c00..6a24756 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1112,6 +1112,7 @@ void hci_req_add(struct hci_request *req, u16 opcode, u32 plen,
 void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
 		    const void *param, u8 event);
 void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status);
+void hci_req_add_le_scan_disable(struct hci_request *req);
 
 struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
 			       const void *param, u32 timeout);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cdba470..6a21dcf 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3147,7 +3147,6 @@ static void le_scan_disable_work(struct work_struct *work)
 {
 	struct hci_dev *hdev = container_of(work, struct hci_dev,
 					    le_scan_disable.work);
-	struct hci_cp_le_set_scan_enable cp;
 	struct hci_request req;
 	int err;
 
@@ -3155,9 +3154,7 @@ static void le_scan_disable_work(struct work_struct *work)
 
 	hci_req_init(&req, hdev);
 
-	memset(&cp, 0, sizeof(cp));
-	cp.enable = LE_SCAN_DISABLE;
-	hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
+	hci_req_add_le_scan_disable(&req);
 
 	err = hci_req_run(&req, le_scan_disable_work_complete);
 	if (err)
@@ -4628,3 +4625,12 @@ static void hci_cmd_work(struct work_struct *work)
 		}
 	}
 }
+
+void hci_req_add_le_scan_disable(struct hci_request *req)
+{
+	struct hci_cp_le_set_scan_enable cp;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.enable = LE_SCAN_DISABLE;
+	hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
+}
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 90aac90..25a0c46 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3411,7 +3411,6 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
 	struct hci_cp_remote_name_req_cancel cp;
 	struct inquiry_entry *e;
 	struct hci_request req;
-	struct hci_cp_le_set_scan_enable enable_cp;
 	int err;
 
 	BT_DBG("%s", hdev->name);
@@ -3447,10 +3446,7 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
 		} else {
 			cancel_delayed_work(&hdev->le_scan_disable);
 
-			memset(&enable_cp, 0, sizeof(enable_cp));
-			enable_cp.enable = LE_SCAN_DISABLE;
-			hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE,
-				    sizeof(enable_cp), &enable_cp);
+			hci_req_add_le_scan_disable(&req);
 		}
 
 		break;
-- 
1.8.5.4


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

end of thread, other threads:[~2014-02-18 19:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-18 17:54 [RFC v9 01/10] Bluetooth: Create hci_req_add_le_scan_disable helper Andre Guedes
2014-02-18 17:54 ` [RFC v9 02/10] Bluetooth: Declare le_conn_failed in hci_core.h Andre Guedes
2014-02-18 17:54 ` [RFC v9 03/10] Bluetooth: Stop scanning on LE connection Andre Guedes
2014-02-18 17:54 ` [RFC v9 04/10] Bluetooth: Remove unused function Andre Guedes
2014-02-18 17:54 ` [RFC v9 05/10] Bluetooth: Introduce hdev->pend_le_conn list Andre Guedes
2014-02-18 17:54 ` [RFC v9 06/10] Bluetooth: Introduce LE auto connection infrastructure Andre Guedes
2014-02-18 17:54 ` [RFC v9 07/10] Bluetooth: Temporarily stop background scanning on discovery Andre Guedes
2014-02-18 17:54 ` [RFC v9 08/10] Bluetooth: Introduce LE auto connect options Andre Guedes
2014-02-18 17:55 ` [RFC v9 09/10] Bluetooth: Auto connection and power on Andre Guedes
2014-02-18 17:55 ` [RFC v9 10/10] Bluetooth: Add le_auto_conn file on debugfs Andre Guedes
2014-02-18 19:50 ` [RFC v9 01/10] Bluetooth: Create hci_req_add_le_scan_disable helper Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox