From 6f2643638dc2d897b9cfdaa5fc8f1bc1fa55c005 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 19 Jun 2025 03:58:05 +0300 Subject: [PATCH] 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 --- subsys/bluetooth/host/direction.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/subsys/bluetooth/host/direction.c b/subsys/bluetooth/host/direction.c index a59cbdada37..73a196a8e20 100644 --- a/subsys/bluetooth/host/direction.c +++ b/subsys/bluetooth/host/direction.c @@ -129,8 +129,7 @@ static int hci_df_set_cl_cte_tx_params(const struct bt_le_ext_adv *adv, return -EINVAL; } - buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS, - sizeof(*cp) + params->num_ant_ids); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { return -ENOBUFS; } @@ -216,7 +215,7 @@ static int hci_df_set_adv_cte_tx_enable(struct bt_le_ext_adv *adv, struct bt_hci_cmd_state_set state; struct net_buf *buf; - buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE, sizeof(*cp)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { return -ENOBUFS; } @@ -296,9 +295,7 @@ prepare_cl_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt_le_per_adv_s /* If CTE Rx is enabled, command parameters total length must include * antenna ids, so command size if extended by num_and_ids. */ - *buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE, - (sizeof(struct bt_hci_cp_le_set_cl_cte_sampling_enable) + - (enable ? switch_pattern_len : 0))); + *buf = bt_hci_cmd_alloc(K_FOREVER); if (!(*buf)) { return -ENOBUFS; } @@ -528,7 +525,6 @@ static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn, struct bt_hci_rp_le_set_conn_cte_tx_params *rp; struct bt_hci_cmd_state_set state; struct net_buf *buf, *rsp; - uint8_t num_ant_ids; int err; /* 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, return -EINVAL; } - num_ant_ids = ((params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) ? - params->num_ant_ids : 0); - - buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS, - sizeof(struct bt_hci_cp_le_set_conn_cte_tx_params) + num_ant_ids); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { return -ENOBUFS; } @@ -587,9 +579,7 @@ static int prepare_conn_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt /* If CTE Rx is enabled, command parameters total length must include * antenna ids, so command size if extended by num_and_ids. */ - *buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS, - (sizeof(struct bt_hci_cp_le_set_conn_cte_rx_params) + - (enable ? switch_pattern_len : 0))); + *buf = bt_hci_cmd_alloc(K_FOREVER); if (!(*buf)) { return -ENOBUFS; } @@ -823,8 +813,7 @@ static int hci_df_set_conn_cte_req_enable(struct bt_conn *conn, bool enable, return -EINVAL; } - buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE, - sizeof(struct bt_hci_cp_le_conn_cte_req_enable)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { return -ENOBUFS; } @@ -909,8 +898,7 @@ static int hci_df_set_conn_cte_rsp_enable(struct bt_conn *conn, bool enable) struct net_buf *buf, *rsp; int err; - buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE, - sizeof(struct bt_hci_cp_le_conn_cte_rsp_enable)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { return -ENOBUFS; }