Skip to content

Commit

Permalink
Bluetooth: hci_core: Remove usage of hci_req_sync
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vudentz committed Jul 15, 2024
1 parent 88b73fd commit 92048ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
2 changes: 2 additions & 0 deletions include/net/bluetooth/hci_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
29 changes: 4 additions & 25 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions net/bluetooth/hci_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 };
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 92048ab

Please sign in to comment.