Skip to content

Commit a5dd15c

Browse files
jhedbergolivier-le-sage
authored andcommitted
[nrf fromtree] Bluetooth: Host: direction: 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 6f26436)
1 parent 2d7bb30 commit a5dd15c

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

subsys/bluetooth/host/direction.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ static int hci_df_set_cl_cte_tx_params(const struct bt_le_ext_adv *adv,
129129
return -EINVAL;
130130
}
131131

132-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS,
133-
sizeof(*cp) + params->num_ant_ids);
132+
buf = bt_hci_cmd_alloc(K_FOREVER);
134133
if (!buf) {
135134
return -ENOBUFS;
136135
}
@@ -216,7 +215,7 @@ static int hci_df_set_adv_cte_tx_enable(struct bt_le_ext_adv *adv,
216215
struct bt_hci_cmd_state_set state;
217216
struct net_buf *buf;
218217

219-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE, sizeof(*cp));
218+
buf = bt_hci_cmd_alloc(K_FOREVER);
220219
if (!buf) {
221220
return -ENOBUFS;
222221
}
@@ -296,9 +295,7 @@ prepare_cl_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt_le_per_adv_s
296295
/* If CTE Rx is enabled, command parameters total length must include
297296
* antenna ids, so command size if extended by num_and_ids.
298297
*/
299-
*buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE,
300-
(sizeof(struct bt_hci_cp_le_set_cl_cte_sampling_enable) +
301-
(enable ? switch_pattern_len : 0)));
298+
*buf = bt_hci_cmd_alloc(K_FOREVER);
302299
if (!(*buf)) {
303300
return -ENOBUFS;
304301
}
@@ -528,7 +525,6 @@ static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn,
528525
struct bt_hci_rp_le_set_conn_cte_tx_params *rp;
529526
struct bt_hci_cmd_state_set state;
530527
struct net_buf *buf, *rsp;
531-
uint8_t num_ant_ids;
532528
int err;
533529

534530
/* If AoD is not enabled, ant_ids are ignored by controller:
@@ -538,11 +534,7 @@ static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn,
538534
return -EINVAL;
539535
}
540536

541-
num_ant_ids = ((params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) ?
542-
params->num_ant_ids : 0);
543-
544-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS,
545-
sizeof(struct bt_hci_cp_le_set_conn_cte_tx_params) + num_ant_ids);
537+
buf = bt_hci_cmd_alloc(K_FOREVER);
546538
if (!buf) {
547539
return -ENOBUFS;
548540
}
@@ -587,9 +579,7 @@ static int prepare_conn_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt
587579
/* If CTE Rx is enabled, command parameters total length must include
588580
* antenna ids, so command size if extended by num_and_ids.
589581
*/
590-
*buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS,
591-
(sizeof(struct bt_hci_cp_le_set_conn_cte_rx_params) +
592-
(enable ? switch_pattern_len : 0)));
582+
*buf = bt_hci_cmd_alloc(K_FOREVER);
593583
if (!(*buf)) {
594584
return -ENOBUFS;
595585
}
@@ -823,8 +813,7 @@ static int hci_df_set_conn_cte_req_enable(struct bt_conn *conn, bool enable,
823813
return -EINVAL;
824814
}
825815

826-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE,
827-
sizeof(struct bt_hci_cp_le_conn_cte_req_enable));
816+
buf = bt_hci_cmd_alloc(K_FOREVER);
828817
if (!buf) {
829818
return -ENOBUFS;
830819
}
@@ -909,8 +898,7 @@ static int hci_df_set_conn_cte_rsp_enable(struct bt_conn *conn, bool enable)
909898
struct net_buf *buf, *rsp;
910899
int err;
911900

912-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE,
913-
sizeof(struct bt_hci_cp_le_conn_cte_rsp_enable));
901+
buf = bt_hci_cmd_alloc(K_FOREVER);
914902
if (!buf) {
915903
return -ENOBUFS;
916904
}

0 commit comments

Comments
 (0)