net: buf: remove use of special putter and getter functions
Convert users of net_buf_put() and net_buf_get() functions to use
non-wrapped putters and getters k_fifo_put() and k_fifo_get().
Special handling of net_bufs in k_fifos is no longer needed after commit
3d306c181f
, since these actions are now
atomic regardless of any net_buf fragments.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
parent
cb47ed206b
commit
69fe9b0c50
40 changed files with 154 additions and 155 deletions
|
@ -106,7 +106,7 @@ static int drv_send(const struct device *dev, struct net_buf *buf)
|
|||
LOG_HEXDUMP_DBG(buf->data, buf->len, "buf");
|
||||
|
||||
__ASSERT_NO_MSG(buf);
|
||||
net_buf_put(&drv_send_fifo, buf);
|
||||
k_fifo_put(&drv_send_fifo, buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ ZTEST(hci_uart, test_h2c_cmd_flow_control)
|
|||
for (uint16_t i = 0; i < HCI_NORMAL_CMD_BUF_COUNT; i++) {
|
||||
/* The mock controller processes a command. */
|
||||
{
|
||||
struct net_buf *buf = net_buf_get(&drv_send_fifo, TIMEOUT_PRESUME_STUCK);
|
||||
struct net_buf *buf = k_fifo_get(&drv_send_fifo, TIMEOUT_PRESUME_STUCK);
|
||||
|
||||
zassert_not_null(buf);
|
||||
zassert_equal(buf->len, sizeof(h4_msg_cmd_dummy1) - 1, "Wrong length");
|
||||
|
@ -241,7 +241,7 @@ ZTEST(hci_uart, test_h2c_cmd_flow_control)
|
|||
for (uint16_t i = 0; i < TEST_PARAM_HOST_COMPLETE_COUNT; i++) {
|
||||
/* The mock controller processes a 'HCI Host Number of Completed Packets'. */
|
||||
{
|
||||
struct net_buf *buf = net_buf_get(&drv_send_fifo, TIMEOUT_PRESUME_STUCK);
|
||||
struct net_buf *buf = k_fifo_get(&drv_send_fifo, TIMEOUT_PRESUME_STUCK);
|
||||
|
||||
zassert_not_null(buf);
|
||||
zassert_equal(buf->len, sizeof(h4_msg_cmd_host_num_complete) - 1,
|
||||
|
|
|
@ -387,7 +387,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,7 +355,7 @@ static void rx_thread(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf;
|
||||
|
||||
/* Wait until a buffer is available */
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
recv(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ static void command_status(struct net_buf *buf)
|
|||
*/
|
||||
static void discard_event(void)
|
||||
{
|
||||
struct net_buf *buf = net_buf_get(&event_queue, K_FOREVER);
|
||||
struct net_buf *buf = k_fifo_get(&event_queue, K_FOREVER);
|
||||
|
||||
net_buf_unref(buf);
|
||||
m_events--;
|
||||
|
@ -292,7 +292,7 @@ static struct net_buf *queue_event(struct net_buf *buf)
|
|||
bt_buf_set_type(evt, BT_BUF_EVT);
|
||||
net_buf_add_le32(evt, sys_cpu_to_le32(k_uptime_get()));
|
||||
net_buf_add_mem(evt, buf->data, buf->len);
|
||||
net_buf_put(&event_queue, evt);
|
||||
k_fifo_put(&event_queue, evt);
|
||||
m_events++;
|
||||
}
|
||||
return evt;
|
||||
|
@ -306,7 +306,7 @@ static void service_events(void *p1, void *p2, void *p3)
|
|||
struct net_buf *buf, *evt;
|
||||
|
||||
while (1) {
|
||||
buf = net_buf_get(&rx_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&rx_queue, K_FOREVER);
|
||||
if (bt_buf_get_type(buf) == BT_BUF_EVT) {
|
||||
|
||||
evt = queue_event(buf);
|
||||
|
@ -348,7 +348,7 @@ static void service_events(void *p1, void *p2, void *p3)
|
|||
net_buf_add_le32(data,
|
||||
sys_cpu_to_le32(k_uptime_get()));
|
||||
net_buf_add_mem(data, buf->data, buf->len);
|
||||
net_buf_put(&data_queue, data);
|
||||
k_fifo_put(&data_queue, data);
|
||||
}
|
||||
#if defined(CONFIG_BT_ISO)
|
||||
} else if (bt_buf_get_type(buf) == BT_BUF_ISO_IN) {
|
||||
|
@ -360,7 +360,7 @@ static void service_events(void *p1, void *p2, void *p3)
|
|||
net_buf_add_le32(data,
|
||||
sys_cpu_to_le32(k_uptime_get()));
|
||||
net_buf_add_mem(data, buf->data, buf->len);
|
||||
net_buf_put(&iso_data_queue, data);
|
||||
k_fifo_put(&iso_data_queue, data);
|
||||
}
|
||||
#endif /* CONFIG_BT_ISO */
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ static void flush_events(uint16_t size)
|
|||
uint16_t response = sys_cpu_to_le16(CMD_FLUSH_EVENTS_RSP);
|
||||
struct net_buf *buf;
|
||||
|
||||
while ((buf = net_buf_get(&event_queue, K_NO_WAIT))) {
|
||||
while ((buf = k_fifo_get(&event_queue, K_NO_WAIT))) {
|
||||
net_buf_unref(buf);
|
||||
m_events--;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ static void get_event(uint16_t size)
|
|||
size = 0;
|
||||
|
||||
edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK);
|
||||
buf = net_buf_get(&event_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&event_queue, K_FOREVER);
|
||||
if (buf) {
|
||||
size = sys_cpu_to_le16(buf->len);
|
||||
edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK);
|
||||
|
@ -428,7 +428,7 @@ static void get_events(uint16_t size)
|
|||
edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK);
|
||||
edtt_write((uint8_t *)&count, sizeof(count), EDTTT_BLOCK);
|
||||
while (count--) {
|
||||
buf = net_buf_get(&event_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&event_queue, K_FOREVER);
|
||||
size = sys_cpu_to_le16(buf->len);
|
||||
edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK);
|
||||
edtt_write((uint8_t *)buf->data, buf->len, EDTTT_BLOCK);
|
||||
|
@ -467,7 +467,7 @@ static void le_flush_data(uint16_t size)
|
|||
uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_DATA_RSP);
|
||||
struct net_buf *buf;
|
||||
|
||||
while ((buf = net_buf_get(&data_queue, K_NO_WAIT))) {
|
||||
while ((buf = k_fifo_get(&data_queue, K_NO_WAIT))) {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
read_excess_bytes(size);
|
||||
|
@ -514,7 +514,7 @@ static void le_data_read(uint16_t size)
|
|||
size = 0;
|
||||
|
||||
edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK);
|
||||
buf = net_buf_get(&data_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&data_queue, K_FOREVER);
|
||||
if (buf) {
|
||||
size = sys_cpu_to_le16(buf->len);
|
||||
edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK);
|
||||
|
@ -584,7 +584,7 @@ static void le_flush_iso_data(uint16_t size)
|
|||
uint16_t response = sys_cpu_to_le16(CMD_LE_FLUSH_ISO_DATA_RSP);
|
||||
struct net_buf *buf;
|
||||
|
||||
while ((buf = net_buf_get(&iso_data_queue, K_NO_WAIT))) {
|
||||
while ((buf = k_fifo_get(&iso_data_queue, K_NO_WAIT))) {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
read_excess_bytes(size);
|
||||
|
@ -631,7 +631,7 @@ static void le_iso_data_read(uint16_t size)
|
|||
size = 0;
|
||||
|
||||
edtt_write((uint8_t *)&response, sizeof(response), EDTTT_BLOCK);
|
||||
buf = net_buf_get(&iso_data_queue, K_FOREVER);
|
||||
buf = k_fifo_get(&iso_data_queue, K_FOREVER);
|
||||
if (buf) {
|
||||
size = sys_cpu_to_le16(buf->len);
|
||||
edtt_write((uint8_t *)&size, sizeof(size), EDTTT_BLOCK);
|
||||
|
|
|
@ -140,8 +140,8 @@ ZTEST(net_buf_tests, test_net_buf_2)
|
|||
}
|
||||
|
||||
k_fifo_init(&fifo);
|
||||
net_buf_put(&fifo, head);
|
||||
head = net_buf_get(&fifo, K_NO_WAIT);
|
||||
k_fifo_put(&fifo, head);
|
||||
head = k_fifo_get(&fifo, K_NO_WAIT);
|
||||
|
||||
destroy_called = 0;
|
||||
net_buf_unref(head);
|
||||
|
@ -159,7 +159,7 @@ static void test_3_thread(void *arg1, void *arg2, void *arg3)
|
|||
|
||||
k_sem_give(sema);
|
||||
|
||||
buf = net_buf_get(fifo, TEST_TIMEOUT);
|
||||
buf = k_fifo_get(fifo, TEST_TIMEOUT);
|
||||
zassert_not_null(buf, "Unable to get buffer");
|
||||
|
||||
destroy_called = 0;
|
||||
|
@ -201,7 +201,7 @@ ZTEST(net_buf_tests, test_net_buf_3)
|
|||
zassert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
"Timeout while waiting for semaphore");
|
||||
|
||||
net_buf_put(&fifo, head);
|
||||
k_fifo_put(&fifo, head);
|
||||
|
||||
zassert_true(k_sem_take(&sema, TEST_TIMEOUT) == 0,
|
||||
"Timeout while waiting for semaphore");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue