Skip to content

Commit 307315b

Browse files
Yagoorrlubos
authored andcommitted
[nrf fromtree] Bluetooth: Audio: Conn callbacks registration with BT_CONN_CB_DEFINE
This commit registers the connection callbacks using BT_CONN_CB_DEFINE, which ensures they are set up at link time rather than runtime. Signed-off-by: Yago Fontoura do Rosario <[email protected]> (cherry picked from commit b1eaf02) Signed-off-by: Sean Madigan <[email protected]>
1 parent 0c9f335 commit 307315b

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

subsys/bluetooth/audio/bap_unicast_client.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,14 +4456,13 @@ static void unicast_client_disconnected(struct bt_conn *conn, uint8_t reason)
44564456
unicast_client_ep_reset(conn, reason);
44574457
}
44584458

4459-
static struct bt_conn_cb conn_cbs = {
4459+
BT_CONN_CB_DEFINE(conn_cbs) = {
44604460
.disconnected = unicast_client_disconnected,
44614461
};
44624462

44634463
int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir)
44644464
{
44654465
struct unicast_client *client;
4466-
static bool conn_cb_registered;
44674466
uint8_t role;
44684467
int err;
44694468

@@ -4496,11 +4495,6 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir)
44964495
client->disc_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE;
44974496
client->disc_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE;
44984497

4499-
if (!conn_cb_registered) {
4500-
bt_conn_cb_register(&conn_cbs);
4501-
conn_cb_registered = true;
4502-
}
4503-
45044498
err = bt_gatt_discover(conn, &client->disc_params);
45054499
if (err != 0) {
45064500
atomic_clear_bit(client->flags, UNICAST_CLIENT_FLAG_BUSY);

subsys/bluetooth/audio/csip_set_member.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static void csip_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
647647
}
648648
}
649649

650-
static struct bt_conn_cb conn_callbacks = {
650+
BT_CONN_CB_DEFINE(conn_callbacks) = {
651651
.disconnected = csip_disconnected,
652652
.security_changed = csip_security_changed,
653653
};
@@ -926,7 +926,6 @@ int bt_csip_set_member_register(const struct bt_csip_set_member_register_param *
926926
for (size_t i = 0U; i < ARRAY_SIZE(svc_insts); i++) {
927927
k_mutex_init(&svc_insts[i].mutex);
928928
}
929-
bt_conn_cb_register(&conn_callbacks);
930929
bt_conn_auth_info_cb_register(&auth_callbacks);
931930
first_register = true;
932931
}

0 commit comments

Comments
 (0)