Bluetooth: hci_core: Remove usage of hci_req_sync
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 1 Jul 2024 20:00:08 +0000 (16:00 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 15 Jul 2024 14:11:27 +0000 (10:11 -0400)
hci_request functions are considered deprecated so this replaces the
usage of hci_req_sync with hci_inquiry_sync.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
include/net/bluetooth/hci_sync.h
net/bluetooth/hci_core.c
net/bluetooth/hci_sync.c

index 20168732f20e48be0a921aa7f314678805f8a474..620e6014beb229054bceb686bde2f4cd2f2e6ea2 100644 (file)
@@ -131,6 +131,8 @@ int hci_update_discoverable(struct hci_dev *hdev);
 
 int hci_update_connectable_sync(struct hci_dev *hdev);
 
+int hci_inquiry_sync(struct hci_dev *hdev, u8 length, u8 num_rsp);
+
 int hci_start_discovery_sync(struct hci_dev *hdev);
 int hci_stop_discovery_sync(struct hci_dev *hdev);
 
index db9b9bb7d74df8fb4db477e57e9d4478b12a1826..cce755a84ea782312a33aebd8c29c7ce004e656b 100644 (file)
@@ -312,33 +312,12 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
        return copied;
 }
 
-static int hci_inq_req(struct hci_request *req, unsigned long opt)
-{
-       struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt;
-       struct hci_dev *hdev = req->hdev;
-       struct hci_cp_inquiry cp;
-
-       BT_DBG("%s", hdev->name);
-
-       if (test_bit(HCI_INQUIRY, &hdev->flags))
-               return 0;
-
-       /* Start Inquiry */
-       memcpy(&cp.lap, &ir->lap, 3);
-       cp.length  = ir->length;
-       cp.num_rsp = ir->num_rsp;
-       hci_req_add(req, HCI_OP_INQUIRY, sizeof(cp), &cp);
-
-       return 0;
-}
-
 int hci_inquiry(void __user *arg)
 {
        __u8 __user *ptr = arg;
        struct hci_inquiry_req ir;
        struct hci_dev *hdev;
        int err = 0, do_inquiry = 0, max_rsp;
-       long timeo;
        __u8 *buf;
 
        if (copy_from_user(&ir, ptr, sizeof(ir)))
@@ -377,11 +356,11 @@ int hci_inquiry(void __user *arg)
        }
        hci_dev_unlock(hdev);
 
-       timeo = ir.length * msecs_to_jiffies(2000);
-
        if (do_inquiry) {
-               err = hci_req_sync(hdev, hci_inq_req, (unsigned long) &ir,
-                                  timeo, NULL);
+               hci_req_sync_lock(hdev);
+               err = hci_inquiry_sync(hdev, ir.length, ir.num_rsp);
+               hci_req_sync_unlock(hdev);
+
                if (err < 0)
                        goto done;
 
index 76b283b8e90d34cd1f47996e3e0d2d15fc7d066e..46b394842a27e6e86ed59a86a95480da72f4ebe3 100644 (file)
@@ -347,10 +347,9 @@ static int scan_disable_sync(struct hci_dev *hdev, void *data)
        return hci_scan_disable_sync(hdev);
 }
 
-static int hci_inquiry_sync(struct hci_dev *hdev, u8 length);
 static int interleaved_inquiry_sync(struct hci_dev *hdev, void *data)
 {
-       return hci_inquiry_sync(hdev, DISCOV_INTERLEAVED_INQUIRY_LEN);
+       return hci_inquiry_sync(hdev, DISCOV_INTERLEAVED_INQUIRY_LEN, 0);
 }
 
 static void le_scan_disable(struct work_struct *work)
@@ -5662,7 +5661,7 @@ int hci_update_connectable_sync(struct hci_dev *hdev)
        return hci_update_passive_scan_sync(hdev);
 }
 
-static int hci_inquiry_sync(struct hci_dev *hdev, u8 length)
+int hci_inquiry_sync(struct hci_dev *hdev, u8 length, u8 num_rsp)
 {
        const u8 giac[3] = { 0x33, 0x8b, 0x9e };
        const u8 liac[3] = { 0x00, 0x8b, 0x9e };
@@ -5685,6 +5684,7 @@ static int hci_inquiry_sync(struct hci_dev *hdev, u8 length)
                memcpy(&cp.lap, giac, sizeof(cp.lap));
 
        cp.length = length;
+       cp.num_rsp = num_rsp;
 
        return __hci_cmd_sync_status(hdev, HCI_OP_INQUIRY,
                                     sizeof(cp), &cp, HCI_CMD_TIMEOUT);
@@ -5771,7 +5771,7 @@ static int hci_start_interleaved_discovery_sync(struct hci_dev *hdev)
        if (err)
                return err;
 
-       return hci_inquiry_sync(hdev, DISCOV_BREDR_INQUIRY_LEN);
+       return hci_inquiry_sync(hdev, DISCOV_BREDR_INQUIRY_LEN, 0);
 }
 
 int hci_start_discovery_sync(struct hci_dev *hdev)
@@ -5783,7 +5783,7 @@ int hci_start_discovery_sync(struct hci_dev *hdev)
 
        switch (hdev->discovery.type) {
        case DISCOV_TYPE_BREDR:
-               return hci_inquiry_sync(hdev, DISCOV_BREDR_INQUIRY_LEN);
+               return hci_inquiry_sync(hdev, DISCOV_BREDR_INQUIRY_LEN, 0);
        case DISCOV_TYPE_INTERLEAVED:
                /* When running simultaneous discovery, the LE scanning time
                 * should occupy the whole discovery time sine BR/EDR inquiry