Skip to content

Commit ceb567a

Browse files
Thalleykartben
authored andcommitted
Bluetooth: ISO: Cleanup BIG before stopped callback
Modify the big_disconnect function to do cleanup_big before calling the `stopped` callback. This will allow the ISO channels, as well as the BIG itself, to be reused for other purposes directly in the stopped callback, without having to offload such actions to a separate thread. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 69e31d8 commit ceb567a

File tree

1 file changed

+4
-9
lines changed
  • subsys/bluetooth/host

1 file changed

+4
-9
lines changed

subsys/bluetooth/host/iso.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,10 @@ static void big_disconnect(struct bt_iso_big *big, uint8_t reason)
27242724
bt_iso_chan_disconnected(bis, reason);
27252725
}
27262726

2727-
atomic_clear_bit(big->flags, BT_BIG_BUSY);
2727+
/* Cleanup the BIG before calling the `stopped` so that the `big` pointer and the ISO
2728+
* channels in the `big` can be reused in the callback
2729+
*/
2730+
cleanup_big(big);
27282731

27292732
if (!sys_slist_is_empty(&iso_big_cbs)) {
27302733
struct bt_iso_big_cb *listener;
@@ -3162,7 +3165,6 @@ void hci_le_big_complete(struct net_buf *buf)
31623165
big = big_lookup_flag(BT_BIG_PENDING);
31633166
if (big) {
31643167
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3165-
cleanup_big(big);
31663168
}
31673169

31683170
return;
@@ -3180,7 +3182,6 @@ void hci_le_big_complete(struct net_buf *buf)
31803182
big->num_bis);
31813183
}
31823184
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3183-
cleanup_big(big);
31843185
return;
31853186
}
31863187

@@ -3223,7 +3224,6 @@ void hci_le_big_terminate(struct net_buf *buf)
32233224
LOG_DBG("BIG[%u] %p terminated", big->handle, big);
32243225

32253226
big_disconnect(big, evt->reason);
3226-
cleanup_big(big);
32273227
}
32283228
#endif /* CONFIG_BT_ISO_BROADCASTER */
32293229

@@ -3315,7 +3315,6 @@ int bt_iso_big_terminate(struct bt_iso_big *big)
33153315

33163316
if (!err) {
33173317
big_disconnect(big, BT_HCI_ERR_LOCALHOST_TERM_CONN);
3318-
cleanup_big(big);
33193318
}
33203319
} else {
33213320
err = -EINVAL;
@@ -3364,7 +3363,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33643363
big = big_lookup_flag(BT_BIG_SYNCING);
33653364
if (big) {
33663365
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3367-
cleanup_big(big);
33683366
}
33693367

33703368
return;
@@ -3382,7 +3380,6 @@ void hci_le_big_sync_established(struct net_buf *buf)
33823380
big->num_bis);
33833381
}
33843382
big_disconnect(big, evt->status ? evt->status : BT_HCI_ERR_UNSPECIFIED);
3385-
cleanup_big(big);
33863383
return;
33873384
}
33883385

@@ -3425,7 +3422,6 @@ void hci_le_big_sync_lost(struct net_buf *buf)
34253422
LOG_DBG("BIG[%u] %p sync lost", big->handle, big);
34263423

34273424
big_disconnect(big, evt->reason);
3428-
cleanup_big(big);
34293425
}
34303426

34313427
static int hci_le_big_create_sync(const struct bt_le_per_adv_sync *sync, struct bt_iso_big *big,
@@ -3636,7 +3632,6 @@ void bt_iso_reset(void)
36363632
struct bt_iso_big *big = &bigs[i];
36373633

36383634
big_disconnect(big, BT_HCI_ERR_UNSPECIFIED);
3639-
cleanup_big(big);
36403635
}
36413636
#endif /* CONFIG_BT_ISO_BROADCAST */
36423637
}

0 commit comments

Comments
 (0)