Bluetooth: Host: Refactor tx_notify, simplify locking
The control flow around the irq-lockout used for fetching from
`tx_complete` has been simplified so that there is exactly one
line with irq_unlock that is unconditionally called.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c
index a910240..c949976 100644
--- a/subsys/bluetooth/host/conn.c
+++ b/subsys/bluetooth/host/conn.c
@@ -189,21 +189,22 @@
BT_DBG("conn %p", conn);
while (1) {
- struct bt_conn_tx *tx;
+ struct bt_conn_tx *tx = NULL;
unsigned int key;
bt_conn_tx_cb_t cb;
void *user_data;
key = irq_lock();
- if (sys_slist_is_empty(&conn->tx_complete)) {
- irq_unlock(key);
- break;
+ if (!sys_slist_is_empty(&conn->tx_complete)) {
+ tx = CONTAINER_OF(sys_slist_get_not_empty(&conn->tx_complete),
+ struct bt_conn_tx, node);
}
-
- tx = CONTAINER_OF(sys_slist_get_not_empty(&conn->tx_complete),
- struct bt_conn_tx, node);
irq_unlock(key);
+ if (!tx) {
+ return;
+ }
+
BT_DBG("tx %p cb %p user_data %p", tx, tx->cb, tx->user_data);
/* Copy over the params */