]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Bluetooth: Create hci_req_add_le_scan_disable helper
authorAndre Guedes <andre.guedes@openbossa.org>
Wed, 26 Feb 2014 23:21:40 +0000 (20:21 -0300)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 27 Feb 2014 03:41:33 +0000 (19:41 -0800)
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>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/mgmt.c

index 269c8201a362b16f6ab05713e25d13558433aed0..bef65d0a14f0bc808e77d35486d6f5e5513d6df8 100644 (file)
@@ -1129,6 +1129,8 @@ 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);
 struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
index 669c76ec659a7daa440616b2f1bee378072d5ad8..9a078cf81d3f0f87aa89f97eb76ea2891d5576aa 100644 (file)
@@ -3318,7 +3318,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;
 
@@ -3326,9 +3325,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)
@@ -4872,3 +4869,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);
+}
index d6e269287cfcee6b1cd9dd1a8c5ebaaa5b2f5775..cfcaf97c998b57742bb50dde2def44a448668df6 100644 (file)
@@ -1052,11 +1052,7 @@ static int clean_up_hci_state(struct hci_dev *hdev)
                disable_advertising(&req);
 
        if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) {
-               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);
+               hci_req_add_le_scan_disable(&req);
        }
 
        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,
        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);
@@ -3563,10 +3558,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;