Skip to content

Commit 651cd3d

Browse files
bgixVudentz
authored andcommitted
Bluetooth: convert hci_update_adv_data to hci_sync
hci_update_adv_data() is called from hci_event and hci_core due to events from the controller. The prior function used the deprecated hci_request method, and the new one uses hci_sync.c Signed-off-by: Brian Gix <brian.gix@intel.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 3fe318e commit 651cd3d

File tree

6 files changed

+23
-68
lines changed

6 files changed

+23
-68
lines changed

include/net/bluetooth/hci_sync.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
6161

6262
int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance);
6363
int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance);
64+
int hci_update_adv_data(struct hci_dev *hdev, u8 instance);
6465
int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
6566
bool force);
6667

net/bluetooth/hci_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static void hci_update_passive_scan_state(struct hci_dev *hdev, u8 scan)
714714
hci_dev_set_flag(hdev, HCI_BREDR_ENABLED);
715715

716716
if (hci_dev_test_flag(hdev, HCI_LE_ENABLED))
717-
hci_req_update_adv_data(hdev, hdev->cur_adv_instance);
717+
hci_update_adv_data(hdev, hdev->cur_adv_instance);
718718

719719
mgmt_new_settings(hdev);
720720
}

net/bluetooth/hci_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,7 @@ static u8 hci_cc_set_ext_adv_param(struct hci_dev *hdev, void *data,
21522152
adv_instance->tx_power = rp->tx_power;
21532153
}
21542154
/* Update adv data as tx power is known now */
2155-
hci_req_update_adv_data(hdev, cp->handle);
2155+
hci_update_adv_data(hdev, cp->handle);
21562156

21572157
hci_dev_unlock(hdev);
21582158

net/bluetooth/hci_request.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -829,70 +829,6 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
829829
addr_resolv);
830830
}
831831

832-
static void __hci_req_update_adv_data(struct hci_request *req, u8 instance)
833-
{
834-
struct hci_dev *hdev = req->hdev;
835-
u8 len;
836-
837-
if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
838-
return;
839-
840-
if (ext_adv_capable(hdev)) {
841-
struct {
842-
struct hci_cp_le_set_ext_adv_data cp;
843-
u8 data[HCI_MAX_EXT_AD_LENGTH];
844-
} pdu;
845-
846-
memset(&pdu, 0, sizeof(pdu));
847-
848-
len = eir_create_adv_data(hdev, instance, pdu.data);
849-
850-
/* There's nothing to do if the data hasn't changed */
851-
if (hdev->adv_data_len == len &&
852-
memcmp(pdu.data, hdev->adv_data, len) == 0)
853-
return;
854-
855-
memcpy(hdev->adv_data, pdu.data, len);
856-
hdev->adv_data_len = len;
857-
858-
pdu.cp.length = len;
859-
pdu.cp.handle = instance;
860-
pdu.cp.operation = LE_SET_ADV_DATA_OP_COMPLETE;
861-
pdu.cp.frag_pref = LE_SET_ADV_DATA_NO_FRAG;
862-
863-
hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_DATA,
864-
sizeof(pdu.cp) + len, &pdu.cp);
865-
} else {
866-
struct hci_cp_le_set_adv_data cp;
867-
868-
memset(&cp, 0, sizeof(cp));
869-
870-
len = eir_create_adv_data(hdev, instance, cp.data);
871-
872-
/* There's nothing to do if the data hasn't changed */
873-
if (hdev->adv_data_len == len &&
874-
memcmp(cp.data, hdev->adv_data, len) == 0)
875-
return;
876-
877-
memcpy(hdev->adv_data, cp.data, sizeof(cp.data));
878-
hdev->adv_data_len = len;
879-
880-
cp.length = len;
881-
882-
hci_req_add(req, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
883-
}
884-
}
885-
886-
int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance)
887-
{
888-
struct hci_request req;
889-
890-
hci_req_init(&req, hdev);
891-
__hci_req_update_adv_data(&req, instance);
892-
893-
return hci_req_run(&req, NULL);
894-
}
895-
896832
static int hci_req_add_le_interleaved_scan(struct hci_request *req,
897833
unsigned long opt)
898834
{

net/bluetooth/hci_request.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ void hci_req_add_le_passive_scan(struct hci_request *req);
7373

7474
void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next);
7575

76-
int hci_req_update_adv_data(struct hci_dev *hdev, u8 instance);
77-
7876
int hci_abort_conn(struct hci_conn *conn, u8 reason);
7977
void hci_request_setup(struct hci_dev *hdev);
8078
void hci_request_cancel_all(struct hci_dev *hdev);

net/bluetooth/hci_sync.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6065,3 +6065,23 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
60656065

60666066
return 0;
60676067
}
6068+
6069+
static int _update_adv_data_sync(struct hci_dev *hdev, void *data)
6070+
{
6071+
u8 instance = *(u8 *)data;
6072+
6073+
kfree(data);
6074+
6075+
return hci_update_adv_data_sync(hdev, instance);
6076+
}
6077+
6078+
int hci_update_adv_data(struct hci_dev *hdev, u8 instance)
6079+
{
6080+
u8 *inst_ptr = kmalloc(1, GFP_KERNEL);
6081+
6082+
if (!inst_ptr)
6083+
return -ENOMEM;
6084+
6085+
*inst_ptr = instance;
6086+
return hci_cmd_sync_queue(hdev, _update_adv_data_sync, inst_ptr, NULL);
6087+
}

0 commit comments

Comments
 (0)