Skip to content

Commit 5488305

Browse files
jhedbergolivier-le-sage
authored andcommitted
[nrf fromtree] Bluetooth: Host: scan: Use bt_hci_cmd_alloc()
Use bt_hci_cmd_alloc() instead of the soon to be deprecated bt_hci_cmd_create(). Signed-off-by: Johan Hedberg <[email protected]> (cherry picked from commit 8962129)
1 parent 5a8f9a2 commit 5488305

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

subsys/bluetooth/host/scan.c

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int cmd_le_set_ext_scan_enable(bool enable, bool filter_duplicates, uint1
133133
struct net_buf *buf;
134134
int err;
135135

136-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE, sizeof(*cp));
136+
buf = bt_hci_cmd_alloc(K_FOREVER);
137137
if (!buf) {
138138
return -ENOBUFS;
139139
}
@@ -163,7 +163,7 @@ static int cmd_le_set_scan_enable_legacy(bool enable, bool filter_duplicates)
163163
struct net_buf *buf;
164164
int err;
165165

166-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_SCAN_ENABLE, sizeof(*cp));
166+
buf = bt_hci_cmd_alloc(K_FOREVER);
167167
if (!buf) {
168168
return -ENOBUFS;
169169
}
@@ -252,10 +252,7 @@ static int start_le_scan_ext(struct bt_le_scan_param *scan_param)
252252
return err;
253253
}
254254

255-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_EXT_SCAN_PARAM,
256-
sizeof(*set_param) +
257-
(phy_1m ? sizeof(*phy_1m) : 0) +
258-
(phy_coded ? sizeof(*phy_coded) : 0));
255+
buf = bt_hci_cmd_alloc(K_FOREVER);
259256
if (!buf) {
260257
return -ENOBUFS;
261258
}
@@ -322,7 +319,7 @@ static int start_le_scan_legacy(struct bt_le_scan_param *param)
322319
return err;
323320
}
324321

325-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_SCAN_PARAM, sizeof(set_param));
322+
buf = bt_hci_cmd_alloc(K_FOREVER);
326323
if (!buf) {
327324
return -ENOBUFS;
328325
}
@@ -1166,8 +1163,7 @@ static int per_adv_sync_terminate(uint16_t handle)
11661163
struct bt_hci_cp_le_per_adv_terminate_sync *cp;
11671164
struct net_buf *buf;
11681165

1169-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC,
1170-
sizeof(*cp));
1166+
buf = bt_hci_cmd_alloc(K_FOREVER);
11711167
if (!buf) {
11721168
return -ENOBUFS;
11731169
}
@@ -1359,9 +1355,7 @@ int bt_le_per_adv_sync_subevent(struct bt_le_per_adv_sync *per_adv_sync,
13591355
return -EINVAL;
13601356
}
13611357

1362-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_PER_ADV_SYNC_SUBEVENT,
1363-
sizeof(*cp) + params->num_subevents);
1364-
1358+
buf = bt_hci_cmd_alloc(K_FOREVER);
13651359
if (!buf) {
13661360
return -ENOBUFS;
13671361
}
@@ -1399,9 +1393,7 @@ int bt_le_per_adv_set_response_data(struct bt_le_per_adv_sync *per_adv_sync,
13991393
return -EINVAL;
14001394
}
14011395

1402-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_PER_ADV_RESPONSE_DATA,
1403-
sizeof(*cp) + data->len);
1404-
1396+
buf = bt_hci_cmd_alloc(K_FOREVER);
14051397
if (!buf) {
14061398
return -ENOBUFS;
14071399
}
@@ -1927,7 +1919,7 @@ int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param,
19271919
return -ENOMEM;
19281920
}
19291921

1930-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_PER_ADV_CREATE_SYNC, sizeof(*cp));
1922+
buf = bt_hci_cmd_alloc(K_FOREVER);
19311923
if (!buf) {
19321924
per_adv_sync_delete(per_adv_sync);
19331925
return -ENOBUFS;
@@ -2034,7 +2026,7 @@ static int bt_le_per_adv_sync_create_cancel(
20342026
return err;
20352027
}
20362028

2037-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL, 0);
2029+
buf = bt_hci_cmd_alloc(K_FOREVER);
20382030
if (!buf) {
20392031
return -ENOBUFS;
20402032
}
@@ -2130,8 +2122,7 @@ static int bt_le_set_per_adv_recv_enable(
21302122
return -EALREADY;
21312123
}
21322124

2133-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE,
2134-
sizeof(*cp));
2125+
buf = bt_hci_cmd_alloc(K_FOREVER);
21352126
if (!buf) {
21362127
return -ENOBUFS;
21372128
}
@@ -2189,8 +2180,7 @@ int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync,
21892180
return -ENOTSUP;
21902181
}
21912182

2192-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_PER_ADV_SYNC_TRANSFER,
2193-
sizeof(*cp));
2183+
buf = bt_hci_cmd_alloc(K_FOREVER);
21942184
if (!buf) {
21952185
return -ENOBUFS;
21962186
}
@@ -2230,7 +2220,7 @@ static int past_param_set(const struct bt_conn *conn, uint8_t mode,
22302220
struct bt_hci_cp_le_past_param *cp;
22312221
struct net_buf *buf;
22322222

2233-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_PAST_PARAM, sizeof(*cp));
2223+
buf = bt_hci_cmd_alloc(K_FOREVER);
22342224
if (!buf) {
22352225
return -ENOBUFS;
22362226
}
@@ -2253,7 +2243,7 @@ static int default_past_param_set(uint8_t mode, uint16_t skip, uint16_t timeout,
22532243
struct bt_hci_cp_le_default_past_param *cp;
22542244
struct net_buf *buf;
22552245

2256-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_DEFAULT_PAST_PARAM, sizeof(*cp));
2246+
buf = bt_hci_cmd_alloc(K_FOREVER);
22572247
if (!buf) {
22582248
return -ENOBUFS;
22592249
}
@@ -2381,8 +2371,7 @@ int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid)
23812371
return -EAGAIN;
23822372
}
23832373

2384-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST,
2385-
sizeof(*cp));
2374+
buf = bt_hci_cmd_alloc(K_FOREVER);
23862375
if (!buf) {
23872376
return -ENOBUFS;
23882377
}
@@ -2412,8 +2401,7 @@ int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid)
24122401
return -EAGAIN;
24132402
}
24142403

2415-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST,
2416-
sizeof(*cp));
2404+
buf = bt_hci_cmd_alloc(K_FOREVER);
24172405
if (!buf) {
24182406
return -ENOBUFS;
24192407
}

0 commit comments

Comments
 (0)