mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
Bluetooth: hci_sync: Convert MGMT_OP_SET_FAST_CONNECTABLE
This creates a synchronized Write Fast Connectable call and attaches it to the MGMT_OP_SET_FAST_CONNECTABLE management opcode. Signed-off-by: Brian Gix <brian.gix@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
abfeea476c
commit
353a0249c3
@ -68,6 +68,8 @@ int hci_disable_advertising_sync(struct hci_dev *hdev);
|
||||
int hci_update_passive_scan_sync(struct hci_dev *hdev);
|
||||
int hci_update_passive_scan(struct hci_dev *hdev);
|
||||
|
||||
int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable);
|
||||
|
||||
int hci_dev_open_sync(struct hci_dev *hdev);
|
||||
int hci_dev_close_sync(struct hci_dev *hdev);
|
||||
|
||||
|
@ -2193,7 +2193,7 @@ static int hci_write_auth_enable_sync(struct hci_dev *hdev)
|
||||
HCI_CMD_TIMEOUT);
|
||||
}
|
||||
|
||||
static int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable)
|
||||
int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable)
|
||||
{
|
||||
struct hci_cp_write_page_scan_activity cp;
|
||||
u8 type;
|
||||
|
@ -5864,22 +5864,15 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
|
||||
return err;
|
||||
}
|
||||
|
||||
static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
|
||||
u16 opcode)
|
||||
static void fast_connectable_complete(struct hci_dev *hdev, void *data, int err)
|
||||
{
|
||||
struct mgmt_pending_cmd *cmd;
|
||||
struct mgmt_pending_cmd *cmd = data;
|
||||
|
||||
bt_dev_dbg(hdev, "status 0x%02x", status);
|
||||
bt_dev_dbg(hdev, "err %d", err);
|
||||
|
||||
hci_dev_lock(hdev);
|
||||
|
||||
cmd = pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev);
|
||||
if (!cmd)
|
||||
goto unlock;
|
||||
|
||||
if (status) {
|
||||
if (err) {
|
||||
mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
mgmt_status(status));
|
||||
mgmt_status(err));
|
||||
} else {
|
||||
struct mgmt_mode *cp = cmd->param;
|
||||
|
||||
@ -5892,10 +5885,15 @@ static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
|
||||
new_settings(hdev, cmd->sk);
|
||||
}
|
||||
|
||||
mgmt_pending_remove(cmd);
|
||||
mgmt_pending_free(cmd);
|
||||
}
|
||||
|
||||
unlock:
|
||||
hci_dev_unlock(hdev);
|
||||
static int write_fast_connectable_sync(struct hci_dev *hdev, void *data)
|
||||
{
|
||||
struct mgmt_pending_cmd *cmd = data;
|
||||
struct mgmt_mode *cp = cmd->param;
|
||||
|
||||
return hci_write_fast_connectable_sync(hdev, cp->val);
|
||||
}
|
||||
|
||||
static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
|
||||
@ -5903,58 +5901,50 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
|
||||
{
|
||||
struct mgmt_mode *cp = data;
|
||||
struct mgmt_pending_cmd *cmd;
|
||||
struct hci_request req;
|
||||
int err;
|
||||
|
||||
bt_dev_dbg(hdev, "sock %p", sk);
|
||||
|
||||
if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED) ||
|
||||
hdev->hci_ver < BLUETOOTH_VER_1_2)
|
||||
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
return mgmt_cmd_status(sk, hdev->id,
|
||||
MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
MGMT_STATUS_NOT_SUPPORTED);
|
||||
|
||||
if (cp->val != 0x00 && cp->val != 0x01)
|
||||
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
return mgmt_cmd_status(sk, hdev->id,
|
||||
MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
MGMT_STATUS_INVALID_PARAMS);
|
||||
|
||||
hci_dev_lock(hdev);
|
||||
|
||||
if (pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev)) {
|
||||
err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
MGMT_STATUS_BUSY);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!!cp->val == hci_dev_test_flag(hdev, HCI_FAST_CONNECTABLE)) {
|
||||
err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
hdev);
|
||||
err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!hdev_is_powered(hdev)) {
|
||||
hci_dev_change_flag(hdev, HCI_FAST_CONNECTABLE);
|
||||
err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
hdev);
|
||||
err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev);
|
||||
new_settings(hdev, sk);
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
cmd = mgmt_pending_add(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev,
|
||||
data, len);
|
||||
if (!cmd) {
|
||||
cmd = mgmt_pending_new(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev, data,
|
||||
len);
|
||||
if (!cmd)
|
||||
err = -ENOMEM;
|
||||
goto unlock;
|
||||
}
|
||||
else
|
||||
err = hci_cmd_sync_queue(hdev, write_fast_connectable_sync, cmd,
|
||||
fast_connectable_complete);
|
||||
|
||||
hci_req_init(&req, hdev);
|
||||
|
||||
__hci_req_write_fast_connectable(&req, cp->val);
|
||||
|
||||
err = hci_req_run(&req, fast_connectable_complete);
|
||||
if (err < 0) {
|
||||
err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
MGMT_STATUS_FAILED);
|
||||
mgmt_pending_remove(cmd);
|
||||
mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
|
||||
MGMT_STATUS_FAILED);
|
||||
|
||||
|
||||
if (cmd)
|
||||
mgmt_pending_free(cmd);
|
||||
}
|
||||
|
||||
unlock:
|
||||
|
Loading…
Reference in New Issue
Block a user