net/bluetooth: replace the common connect prologue

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2022-02-07 11:52:21 +08:00 committed by Alan Carvalho de Assis
parent 8f63596063
commit 8366c87c5b
3 changed files with 14 additions and 18 deletions

View File

@ -31,6 +31,8 @@
#include <sys/socket.h>
#include <queue.h>
#include <nuttx/net/net.h>
#include <nuttx/wireless/bluetooth/bt_hci.h>
#ifdef CONFIG_NET_BLUETOOTH
@ -42,9 +44,9 @@
/* Allocate a new Bluetooth socket data callback */
#define bluetooth_callback_alloc(dev,conn) \
devif_callback_alloc(dev, &conn->bc_list, &conn->bc_list_tail)
devif_callback_alloc(dev, &conn->bc_conn.list, &conn->bc_conn.list_tail)
#define bluetooth_callback_free(dev,conn,cb) \
devif_conn_callback_free(dev, cb, &conn->bc_list, &conn->bc_list_tail)
devif_conn_callback_free(dev, cb, &conn->bc_conn.list, &conn->bc_conn.list_tail)
/* Memory Pools */
@ -78,14 +80,7 @@ struct bluetooth_conn_s
{
/* Common prologue of all connection structures. */
dq_entry_t bc_node; /* Supports a doubly linked list */
/* This is a list of Bluetooth callbacks. Each callback represents
* a thread that is stalled, waiting for a device-specific event.
*/
FAR struct devif_callback_s *bc_list; /* Bluetooth callbacks */
FAR struct devif_callback_s *bc_list_tail; /* Bluetooth callbacks */
struct socket_conn_s bc_conn;
/* Bluetooth-specific content follows. */

View File

@ -69,7 +69,8 @@ uint16_t bluetooth_callback(FAR struct radio_driver_s *radio,
{
/* Perform the callback */
flags = devif_conn_event(&radio->r_dev, conn, flags, conn->bc_list);
flags = devif_conn_event(&radio->r_dev, conn,
flags, conn->bc_conn.list);
}
return flags;

View File

@ -102,7 +102,7 @@ void bluetooth_conn_initialize(void)
{
/* Link each pre-allocated connection structure into the free list. */
dq_addlast(&g_bluetooth_connections[i].bc_node,
dq_addlast(&g_bluetooth_connections[i].bc_conn.node,
&g_free_bluetooth_connections);
}
#endif
@ -135,7 +135,7 @@ FAR struct bluetooth_conn_s *bluetooth_conn_alloc(void)
{
for (i = 0; i < CONFIG_NET_BLUETOOTH_NCONNS; i++)
{
dq_addlast(&conn[i].bc_node,
dq_addlast(&conn[i].bc_conn.node,
&g_active_bluetooth_connections);
}
}
@ -152,7 +152,7 @@ FAR struct bluetooth_conn_s *bluetooth_conn_alloc(void)
/* Enqueue the connection into the active list */
dq_addlast(&conn->bc_node, &g_active_bluetooth_connections);
dq_addlast(&conn->bc_conn.node, &g_active_bluetooth_connections);
}
net_unlock();
@ -180,7 +180,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
/* Remove the connection from the active list */
net_lock();
dq_rem(&conn->bc_node, &g_active_bluetooth_connections);
dq_rem(&conn->bc_conn.node, &g_active_bluetooth_connections);
/* Check if there any any frames attached to the container */
@ -209,7 +209,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
/* Free the connection */
dq_addlast(&conn->bc_node, &g_free_bluetooth_connections);
dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections);
net_unlock();
}
@ -236,7 +236,7 @@ FAR struct bluetooth_conn_s *
for (conn =
(FAR struct bluetooth_conn_s *)g_active_bluetooth_connections.head;
conn != NULL;
conn = (FAR struct bluetooth_conn_s *)conn->bc_node.flink)
conn = (FAR struct bluetooth_conn_s *)conn->bc_conn.node.flink)
{
/* match protocol and channel first */
@ -303,7 +303,7 @@ FAR struct bluetooth_conn_s *
}
else
{
return (FAR struct bluetooth_conn_s *)conn->bc_node.flink;
return (FAR struct bluetooth_conn_s *)conn->bc_conn.node.flink;
}
}