Skip to content

Commit 2a42ebc

Browse files
Vudentznashif
authored andcommitted
Bluetooth: ISO: Add function to access bt_conn_iso
This adds bt_conn_iso function to safely access the struct bt_conn_iso within a bt_conn. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 9d0fb5e commit 2a42ebc

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ struct bt_conn *conn_lookup_iso(struct bt_conn *conn)
15041504
return iso_conn;
15051505
}
15061506

1507-
if (iso_conn->iso.acl == conn) {
1507+
if (bt_conn_iso(iso_conn)->acl == conn) {
15081508
return iso_conn;
15091509
}
15101510

subsys/bluetooth/host/iso.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,26 @@ int hci_le_remove_cig(uint8_t cig_id)
258258

259259
void bt_iso_cleanup(struct bt_conn *conn)
260260
{
261+
struct bt_conn_iso *iso = bt_conn_iso(conn);
261262
int i;
262263

263-
CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) {
264-
BT_DBG("Invalid parameters: conn %p conn->type %u", conn,
265-
conn ? conn->type : 0);
266-
return;
267-
}
268-
269264
BT_DBG("%p", conn);
270265

271266
/* Check if ISO connection is in fact a BIS */
272-
if (!conn->iso.acl) {
267+
if (!iso->acl) {
273268
goto done;
274269
}
275270

276271
/* If ACL is still connected there are channels to serve that means the
277272
* connection is still in use.
278273
*/
279-
if (conn->iso.acl->state == BT_CONN_CONNECTED &&
274+
if (iso->acl->state == BT_CONN_CONNECTED &&
280275
!sys_slist_is_empty(&conn->channels)) {
281276
goto done;
282277
}
283278

284-
bt_conn_unref(conn->iso.acl);
285-
conn->iso.acl = NULL;
279+
bt_conn_unref(iso->acl);
280+
iso->acl = NULL;
286281

287282
/* Check if conn is last of CIG */
288283
for (i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
@@ -1183,6 +1178,17 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
11831178
return bt_conn_send(chan->conn, buf);
11841179
}
11851180

1181+
struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn)
1182+
{
1183+
CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) {
1184+
BT_DBG("Invalid parameters: conn %p conn->type %u", conn,
1185+
conn ? conn->type : 0);
1186+
return NULL;
1187+
}
1188+
1189+
return &conn->iso;
1190+
}
1191+
11861192
#if defined(CONFIG_BT_ISO_BROADCAST)
11871193

11881194
static struct bt_iso_big *get_free_big(void)

subsys/bluetooth/host/iso_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state);
133133

134134
/* Process incoming data for a connection */
135135
void bt_iso_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags);
136+
137+
struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn);

0 commit comments

Comments
 (0)