diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2014-02-26 18:21:40 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-02-26 22:41:33 -0500 |
commit | b1efcc2870687ec3e3c51fa72210b8e4fa465df8 (patch) | |
tree | 480514a66414891dd560b11447a26af285d88720 | |
parent | 4bd6d38e7f58b163138d3fea8fa135de523bfb92 (diff) |
Bluetooth: Create hci_req_add_le_scan_disable helper
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>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 14 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 12 |
3 files changed, 14 insertions, 14 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 269c8201a362..bef65d0a14f0 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -1129,6 +1129,8 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, | |||
1129 | const void *param, u8 event); | 1129 | const void *param, u8 event); |
1130 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); | 1130 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); |
1131 | 1131 | ||
1132 | void hci_req_add_le_scan_disable(struct hci_request *req); | ||
1133 | |||
1132 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, | 1134 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, |
1133 | const void *param, u32 timeout); | 1135 | const void *param, u32 timeout); |
1134 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, | 1136 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 669c76ec659a..9a078cf81d3f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -3318,7 +3318,6 @@ static void le_scan_disable_work(struct work_struct *work) | |||
3318 | { | 3318 | { |
3319 | struct hci_dev *hdev = container_of(work, struct hci_dev, | 3319 | struct hci_dev *hdev = container_of(work, struct hci_dev, |
3320 | le_scan_disable.work); | 3320 | le_scan_disable.work); |
3321 | struct hci_cp_le_set_scan_enable cp; | ||
3322 | struct hci_request req; | 3321 | struct hci_request req; |
3323 | int err; | 3322 | int err; |
3324 | 3323 | ||
@@ -3326,9 +3325,7 @@ static void le_scan_disable_work(struct work_struct *work) | |||
3326 | 3325 | ||
3327 | hci_req_init(&req, hdev); | 3326 | hci_req_init(&req, hdev); |
3328 | 3327 | ||
3329 | memset(&cp, 0, sizeof(cp)); | 3328 | hci_req_add_le_scan_disable(&req); |
3330 | cp.enable = LE_SCAN_DISABLE; | ||
3331 | hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); | ||
3332 | 3329 | ||
3333 | err = hci_req_run(&req, le_scan_disable_work_complete); | 3330 | err = hci_req_run(&req, le_scan_disable_work_complete); |
3334 | if (err) | 3331 | if (err) |
@@ -4872,3 +4869,12 @@ static void hci_cmd_work(struct work_struct *work) | |||
4872 | } | 4869 | } |
4873 | } | 4870 | } |
4874 | } | 4871 | } |
4872 | |||
4873 | void hci_req_add_le_scan_disable(struct hci_request *req) | ||
4874 | { | ||
4875 | struct hci_cp_le_set_scan_enable cp; | ||
4876 | |||
4877 | memset(&cp, 0, sizeof(cp)); | ||
4878 | cp.enable = LE_SCAN_DISABLE; | ||
4879 | hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); | ||
4880 | } | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d6e269287cfc..cfcaf97c998b 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1052,11 +1052,7 @@ static int clean_up_hci_state(struct hci_dev *hdev) | |||
1052 | disable_advertising(&req); | 1052 | disable_advertising(&req); |
1053 | 1053 | ||
1054 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) { | 1054 | if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) { |
1055 | struct hci_cp_le_set_scan_enable cp; | 1055 | hci_req_add_le_scan_disable(&req); |
1056 | |||
1057 | memset(&cp, 0, sizeof(cp)); | ||
1058 | cp.enable = LE_SCAN_DISABLE; | ||
1059 | hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp); | ||
1060 | } | 1056 | } |
1061 | 1057 | ||
1062 | list_for_each_entry(conn, &hdev->conn_hash.list, list) { | 1058 | list_for_each_entry(conn, &hdev->conn_hash.list, list) { |
@@ -3527,7 +3523,6 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3527 | struct hci_cp_remote_name_req_cancel cp; | 3523 | struct hci_cp_remote_name_req_cancel cp; |
3528 | struct inquiry_entry *e; | 3524 | struct inquiry_entry *e; |
3529 | struct hci_request req; | 3525 | struct hci_request req; |
3530 | struct hci_cp_le_set_scan_enable enable_cp; | ||
3531 | int err; | 3526 | int err; |
3532 | 3527 | ||
3533 | BT_DBG("%s", hdev->name); | 3528 | BT_DBG("%s", hdev->name); |
@@ -3563,10 +3558,7 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, | |||
3563 | } else { | 3558 | } else { |
3564 | cancel_delayed_work(&hdev->le_scan_disable); | 3559 | cancel_delayed_work(&hdev->le_scan_disable); |
3565 | 3560 | ||
3566 | memset(&enable_cp, 0, sizeof(enable_cp)); | 3561 | hci_req_add_le_scan_disable(&req); |
3567 | enable_cp.enable = LE_SCAN_DISABLE; | ||
3568 | hci_req_add(&req, HCI_OP_LE_SET_SCAN_ENABLE, | ||
3569 | sizeof(enable_cp), &enable_cp); | ||
3570 | } | 3562 | } |
3571 | 3563 | ||
3572 | break; | 3564 | break; |