Bluetooth: host: Convert bluetooth host to using k_timeout_t struct
Convert bluetooth host to using k_timeout_struct for the timeout values. This is mostly replacing s32_t with k_timeout_t. In l2cap the handling of no timeout in send channel request was removed since the timeout is both documented as minimum of 1 second and never given any no timeout value. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
05e5db74cf
commit
d858264d9e
12 changed files with 50 additions and 50 deletions
|
@ -57,11 +57,11 @@ enum bt_buf_type {
|
|||
*
|
||||
* @param type Type of buffer. Only BT_BUF_EVT and BT_BUF_ACL_IN are
|
||||
* allowed.
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @param timeout Non-negative waiting period to obtain a buffer or one of the
|
||||
* special values K_NO_WAIT and K_FOREVER.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout);
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout);
|
||||
|
||||
/** Allocate a buffer for outgoing data
|
||||
*
|
||||
|
@ -70,13 +70,13 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout);
|
|||
*
|
||||
* @param type Type of buffer. Only BT_BUF_CMD, BT_BUF_ACL_OUT or
|
||||
* BT_BUF_H4, when operating on H:4 mode, are allowed.
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @param timeout Non-negative waiting period to obtain a buffer or one of the
|
||||
* special values K_NO_WAIT and K_FOREVER.
|
||||
* @param data Initial data to append to buffer.
|
||||
* @param size Initial data size.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, s32_t timeout,
|
||||
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
|
||||
const void *data, size_t size);
|
||||
|
||||
/** Allocate a buffer for an HCI Command Complete/Status Event
|
||||
|
@ -84,11 +84,11 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, s32_t timeout,
|
|||
* This will set the buffer type so bt_buf_set_type() does not need to
|
||||
* be explicitly called before bt_recv_prio().
|
||||
*
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @param timeout Non-negative waiting period to obtain a buffer or one of the
|
||||
* special values K_NO_WAIT and K_FOREVER.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_cmd_complete(s32_t timeout);
|
||||
struct net_buf *bt_buf_get_cmd_complete(k_timeout_t timeout);
|
||||
|
||||
/** Allocate a buffer for an HCI Event
|
||||
*
|
||||
|
@ -97,11 +97,11 @@ struct net_buf *bt_buf_get_cmd_complete(s32_t timeout);
|
|||
*
|
||||
* @param evt HCI event code
|
||||
* @param discardable Whether the driver considers the event discardable.
|
||||
* @param timeout Timeout in milliseconds, or one of the special values
|
||||
* K_NO_WAIT and K_FOREVER.
|
||||
* @param timeout Non-negative waiting period to obtain a buffer or one of
|
||||
* the special values K_NO_WAIT and K_FOREVER.
|
||||
* @return A new buffer.
|
||||
*/
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, s32_t timeout);
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, k_timeout_t timeout);
|
||||
|
||||
/** Set the buffer type
|
||||
*
|
||||
|
|
|
@ -2265,7 +2265,7 @@ u16_t bt_att_get_mtu(struct bt_conn *conn)
|
|||
return att->chan.tx.mtu;
|
||||
}
|
||||
|
||||
struct bt_att_req *bt_att_req_alloc(s32_t timeout)
|
||||
struct bt_att_req *bt_att_req_alloc(k_timeout_t timeout)
|
||||
{
|
||||
struct bt_att_req *req = NULL;
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ struct net_buf *bt_att_create_pdu(struct bt_conn *conn, u8_t op,
|
|||
size_t len);
|
||||
|
||||
/* Allocate a new request */
|
||||
struct bt_att_req *bt_att_req_alloc(s32_t timeout);
|
||||
struct bt_att_req *bt_att_req_alloc(k_timeout_t timeout);
|
||||
|
||||
/* Free a request */
|
||||
void bt_att_req_free(struct bt_att_req *req);
|
||||
|
|
|
@ -2430,10 +2430,11 @@ int bt_conn_le_conn_update(struct bt_conn *conn,
|
|||
}
|
||||
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *bt_conn_create_frag_timeout_debug(size_t reserve, s32_t timeout,
|
||||
struct net_buf *bt_conn_create_frag_timeout_debug(size_t reserve,
|
||||
k_timeout_t timeout,
|
||||
const char *func, int line)
|
||||
#else
|
||||
struct net_buf *bt_conn_create_frag_timeout(size_t reserve, s32_t timeout)
|
||||
struct net_buf *bt_conn_create_frag_timeout(size_t reserve, k_timeout_t timeout)
|
||||
#endif
|
||||
{
|
||||
struct net_buf_pool *pool = NULL;
|
||||
|
@ -2452,11 +2453,12 @@ struct net_buf *bt_conn_create_frag_timeout(size_t reserve, s32_t timeout)
|
|||
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *bt_conn_create_pdu_timeout_debug(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout,
|
||||
size_t reserve,
|
||||
k_timeout_t timeout,
|
||||
const char *func, int line)
|
||||
#else
|
||||
struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout)
|
||||
size_t reserve, k_timeout_t timeout)
|
||||
#endif
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
@ -2496,7 +2498,7 @@ struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool,
|
|||
}
|
||||
|
||||
if (!buf) {
|
||||
BT_WARN("Unable to allocate buffer: timeout %d", timeout);
|
||||
BT_WARN("Unable to allocate buffer within timeout");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,8 @@ void bt_conn_security_changed(struct bt_conn *conn, enum bt_security_err err);
|
|||
/* Prepare a PDU to be sent over a connection */
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *bt_conn_create_pdu_timeout_debug(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout,
|
||||
size_t reserve,
|
||||
k_timeout_t timeout,
|
||||
const char *func, int line);
|
||||
#define bt_conn_create_pdu_timeout(_pool, _reserve, _timeout) \
|
||||
bt_conn_create_pdu_timeout_debug(_pool, _reserve, _timeout, \
|
||||
|
@ -260,7 +261,7 @@ struct net_buf *bt_conn_create_pdu_timeout_debug(struct net_buf_pool *pool,
|
|||
__func__, __line__)
|
||||
#else
|
||||
struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout);
|
||||
size_t reserve, k_timeout_t timeout);
|
||||
|
||||
#define bt_conn_create_pdu(_pool, _reserve) \
|
||||
bt_conn_create_pdu_timeout(_pool, _reserve, K_FOREVER)
|
||||
|
@ -268,7 +269,8 @@ struct net_buf *bt_conn_create_pdu_timeout(struct net_buf_pool *pool,
|
|||
|
||||
/* Prepare a PDU to be sent over a connection */
|
||||
#if defined(CONFIG_NET_BUF_LOG)
|
||||
struct net_buf *bt_conn_create_frag_timeout_debug(size_t reserve, s32_t timeout,
|
||||
struct net_buf *bt_conn_create_frag_timeout_debug(size_t reserve,
|
||||
k_timeout_t timeout,
|
||||
const char *func, int line);
|
||||
|
||||
#define bt_conn_create_frag_timeout(_reserve, _timeout) \
|
||||
|
@ -279,7 +281,8 @@ struct net_buf *bt_conn_create_frag_timeout_debug(size_t reserve, s32_t timeout,
|
|||
bt_conn_create_frag_timeout_debug(_reserve, K_FOREVER, \
|
||||
__func__, __LINE__)
|
||||
#else
|
||||
struct net_buf *bt_conn_create_frag_timeout(size_t reserve, s32_t timeout);
|
||||
struct net_buf *bt_conn_create_frag_timeout(size_t reserve,
|
||||
k_timeout_t timeout);
|
||||
|
||||
#define bt_conn_create_frag(_reserve) \
|
||||
bt_conn_create_frag_timeout(_reserve, K_FOREVER)
|
||||
|
|
|
@ -53,7 +53,8 @@
|
|||
|
||||
/* Peripheral timeout to initialize Connection Parameter Update procedure */
|
||||
#define CONN_UPDATE_TIMEOUT K_MSEC(CONFIG_BT_CONN_PARAM_UPDATE_TIMEOUT)
|
||||
#define RPA_TIMEOUT K_SECONDS(CONFIG_BT_RPA_TIMEOUT)
|
||||
#define RPA_TIMEOUT_MS (CONFIG_BT_RPA_TIMEOUT * MSEC_PER_SEC)
|
||||
#define RPA_TIMEOUT K_MSEC(RPA_TIMEOUT_MS)
|
||||
|
||||
#define HCI_CMD_TIMEOUT K_SECONDS(10)
|
||||
|
||||
|
@ -1234,7 +1235,7 @@ static inline bool rpa_is_new(void)
|
|||
* timeout was started.
|
||||
*/
|
||||
return k_delayed_work_remaining_get(&bt_dev.rpa_update) >
|
||||
(RPA_TIMEOUT - K_MSEC(500));
|
||||
(RPA_TIMEOUT_MS - 500);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -8273,7 +8274,7 @@ int bt_le_set_chan_map(u8_t chan_map[5])
|
|||
buf, NULL);
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout)
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
@ -8298,7 +8299,7 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout)
|
|||
return buf;
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_cmd_complete(s32_t timeout)
|
||||
struct net_buf *bt_buf_get_cmd_complete(k_timeout_t timeout)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
unsigned int key;
|
||||
|
@ -8321,7 +8322,7 @@ struct net_buf *bt_buf_get_cmd_complete(s32_t timeout)
|
|||
return bt_buf_get_rx(BT_BUF_EVT, timeout);
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, s32_t timeout)
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, k_timeout_t timeout)
|
||||
{
|
||||
switch (evt) {
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
|
|
|
@ -65,7 +65,7 @@ int bt_hci_driver_register(const struct bt_hci_driver *drv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout)
|
||||
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
|
@ -89,7 +89,7 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, s32_t timeout)
|
|||
return buf;
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, s32_t timeout,
|
||||
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
@ -139,12 +139,12 @@ struct net_buf *bt_buf_get_tx(enum bt_buf_type type, s32_t timeout,
|
|||
return buf;
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_cmd_complete(s32_t timeout)
|
||||
struct net_buf *bt_buf_get_cmd_complete(k_timeout_t timeout)
|
||||
{
|
||||
return bt_buf_get_rx(BT_BUF_EVT, timeout);
|
||||
}
|
||||
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, s32_t timeout)
|
||||
struct net_buf *bt_buf_get_evt(u8_t evt, bool discardable, k_timeout_t timeout)
|
||||
{
|
||||
return bt_buf_get_rx(BT_BUF_EVT, timeout);
|
||||
}
|
||||
|
|
|
@ -411,7 +411,7 @@ static struct net_buf *l2cap_create_le_sig_pdu(struct net_buf *buf,
|
|||
|
||||
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
|
||||
static void l2cap_chan_send_req(struct bt_l2cap_le_chan *chan,
|
||||
struct net_buf *buf, s32_t timeout)
|
||||
struct net_buf *buf, k_timeout_t timeout)
|
||||
{
|
||||
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:
|
||||
*
|
||||
|
@ -422,11 +422,7 @@ static void l2cap_chan_send_req(struct bt_l2cap_le_chan *chan,
|
|||
* final expiration, when the response is received, or the physical
|
||||
* link is lost.
|
||||
*/
|
||||
if (timeout) {
|
||||
k_delayed_work_submit(&chan->chan.rtx_work, timeout);
|
||||
} else {
|
||||
k_delayed_work_cancel(&chan->chan.rtx_work);
|
||||
}
|
||||
k_delayed_work_submit(&chan->chan.rtx_work, timeout);
|
||||
|
||||
bt_l2cap_send(chan->chan.conn, BT_L2CAP_CID_LE_SIG, buf);
|
||||
}
|
||||
|
@ -496,7 +492,8 @@ void bt_l2cap_encrypt_change(struct bt_conn *conn, u8_t hci_status)
|
|||
}
|
||||
|
||||
struct net_buf *bt_l2cap_create_pdu_timeout(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout)
|
||||
size_t reserve,
|
||||
k_timeout_t timeout)
|
||||
{
|
||||
return bt_conn_create_pdu_timeout(pool,
|
||||
sizeof(struct bt_l2cap_hdr) + reserve,
|
||||
|
@ -1644,7 +1641,7 @@ int bt_l2cap_chan_recv_complete(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct net_buf *l2cap_alloc_frag(s32_t timeout, void *user_data)
|
||||
static struct net_buf *l2cap_alloc_frag(k_timeout_t timeout, void *user_data)
|
||||
{
|
||||
struct bt_l2cap_le_chan *chan = user_data;
|
||||
struct net_buf *frag = NULL;
|
||||
|
|
|
@ -226,7 +226,7 @@ static u8_t l2cap_br_get_ident(void)
|
|||
}
|
||||
|
||||
static void l2cap_br_chan_send_req(struct bt_l2cap_br_chan *chan,
|
||||
struct net_buf *buf, s32_t timeout)
|
||||
struct net_buf *buf, k_timeout_t timeout)
|
||||
{
|
||||
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:
|
||||
*
|
||||
|
@ -237,11 +237,7 @@ static void l2cap_br_chan_send_req(struct bt_l2cap_br_chan *chan,
|
|||
* final expiration, when the response is received, or the physical
|
||||
* link is lost.
|
||||
*/
|
||||
if (timeout) {
|
||||
k_delayed_work_submit(&chan->chan.rtx_work, timeout);
|
||||
} else {
|
||||
k_delayed_work_cancel(&chan->chan.rtx_work);
|
||||
}
|
||||
k_delayed_work_submit(&chan->chan.rtx_work, timeout);
|
||||
|
||||
bt_l2cap_send(chan->chan.conn, BT_L2CAP_CID_BR_SIG, buf);
|
||||
}
|
||||
|
|
|
@ -261,7 +261,8 @@ void bt_l2cap_encrypt_change(struct bt_conn *conn, u8_t hci_status);
|
|||
|
||||
/* Prepare an L2CAP PDU to be sent over a connection */
|
||||
struct net_buf *bt_l2cap_create_pdu_timeout(struct net_buf_pool *pool,
|
||||
size_t reserve, s32_t timeout);
|
||||
size_t reserve,
|
||||
k_timeout_t timeout);
|
||||
|
||||
#define bt_l2cap_create_pdu(_pool, _reserve) \
|
||||
bt_l2cap_create_pdu_timeout(_pool, _reserve, K_FOREVER)
|
||||
|
|
|
@ -531,7 +531,7 @@ static void rfcomm_check_fc(struct bt_rfcomm_dlc *dlc)
|
|||
static void rfcomm_dlc_tx_thread(void *p1, void *p2, void *p3)
|
||||
{
|
||||
struct bt_rfcomm_dlc *dlc = p1;
|
||||
s32_t timeout = K_FOREVER;
|
||||
k_timeout_t timeout = K_FOREVER;
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("Started for dlc %p", dlc);
|
||||
|
|
|
@ -454,7 +454,7 @@ static struct net_buf *smp_create_pdu(struct bt_smp *smp, u8_t op, size_t len)
|
|||
{
|
||||
struct bt_smp_hdr *hdr;
|
||||
struct net_buf *buf;
|
||||
s32_t timeout;
|
||||
k_timeout_t timeout;
|
||||
|
||||
/* Don't if session had already timed out */
|
||||
if (atomic_test_bit(smp->flags, SMP_FLAG_TIMEOUT)) {
|
||||
|
@ -1139,7 +1139,7 @@ static struct net_buf *smp_br_create_pdu(struct bt_smp_br *smp, u8_t op,
|
|||
{
|
||||
struct bt_smp_hdr *hdr;
|
||||
struct net_buf *buf;
|
||||
s32_t timeout;
|
||||
k_timeout_t timeout;
|
||||
|
||||
/* Don't if session had already timed out */
|
||||
if (atomic_test_bit(smp->flags, SMP_FLAG_TIMEOUT)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue