@@ -631,7 +631,7 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
return ptr;
}
-static void create_eir(struct hci_dev *hdev, u8 *data)
+void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
size_t name_len;
@@ -5263,11 +5263,47 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data,
return err;
}
+// FIXME: This really needs to moved some more common place
+void create_eir(struct hci_dev *hdev, u8 *data);
+
+static void do_update_eir(struct hci_dev *hdev)
+{
+ struct hci_cp_write_eir cp;
+ struct sk_buff *skb;
+
+ if (!hdev_is_powered(hdev))
+ return;
+
+ if (!lmp_ext_inq_capable(hdev))
+ return;
+
+ if (!hci_dev_test_flag(hdev, HCI_SSP_ENABLED))
+ return;
+
+ if (hci_dev_test_flag(hdev, HCI_SERVICE_CACHE))
+ return;
+
+ // FIXME: can these tests be done before calling the work?
+
+ memset(&cp, 0, sizeof(cp));
+
+ create_eir(hdev, cp.data);
+
+ if (memcmp(cp.data, hdev->eir, sizeof(cp.data)) == 0)
+ return;
+
+ memcpy(hdev->eir, cp.data, sizeof(cp.data));
+
+ skb = __hci_cmd_sync(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp,
+ HCI_INIT_TIMEOUT);
+ if (!IS_ERR_OR_NULL(skb))
+ kfree_skb(skb);
+}
+
static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
u16 len)
{
struct mgmt_cp_set_device_id *cp = data;
- struct hci_request req;
int err;
__u16 source;
@@ -5289,12 +5325,10 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEVICE_ID, 0,
NULL, 0);
- hci_req_init(&req, hdev);
- __hci_req_update_eir(&req);
- hci_req_run(&req, NULL);
-
hci_dev_unlock(hdev);
+ hci_cmd_sync_queue(hdev, do_update_eir);
+
return err;
}
This is an attempt for converting Set Device ID to use hci_cmd_sync_queue. This command is rather simple since the mgmt_cmd_complete is always send and the update is done unconditional, but it shows how easy the converion from hci_req_run can be. However create_eir function and alike would have to be moved into a better location. This be better located in hci_br.c and nicely abstracted. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> --- net/bluetooth/hci_request.c | 2 +- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-)