Commit 2a42ebc7 authored by Luiz Augusto von Dentz's avatar Luiz Augusto von Dentz Committed by Anas Nashif
Browse files

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: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
parent 9d0fb5ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1504,7 +1504,7 @@ struct bt_conn *conn_lookup_iso(struct bt_conn *conn)
			return iso_conn;
		}

		if (iso_conn->iso.acl == conn) {
		if (bt_conn_iso(iso_conn)->acl == conn) {
			return iso_conn;
		}

+16 −10
Original line number Diff line number Diff line
@@ -258,31 +258,26 @@ int hci_le_remove_cig(uint8_t cig_id)

void bt_iso_cleanup(struct bt_conn *conn)
{
	struct bt_conn_iso *iso = bt_conn_iso(conn);
	int i;

	CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) {
		BT_DBG("Invalid parameters: conn %p conn->type %u", conn,
		       conn ? conn->type : 0);
		return;
	}

	BT_DBG("%p", conn);

	/* Check if ISO connection is in fact a BIS */
	if (!conn->iso.acl) {
	if (!iso->acl) {
		goto done;
	}

	/* If ACL is still connected there are channels to serve that means the
	 * connection is still in use.
	 */
	if (conn->iso.acl->state == BT_CONN_CONNECTED &&
	if (iso->acl->state == BT_CONN_CONNECTED &&
	    !sys_slist_is_empty(&conn->channels)) {
		goto done;
	}

	bt_conn_unref(conn->iso.acl);
	conn->iso.acl = NULL;
	bt_conn_unref(iso->acl);
	iso->acl = NULL;

	/* Check if conn is last of CIG */
	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)
	return bt_conn_send(chan->conn, buf);
}

struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn)
{
	CHECKIF(!conn || conn->type != BT_CONN_TYPE_ISO) {
		BT_DBG("Invalid parameters: conn %p conn->type %u", conn,
		       conn ? conn->type : 0);
		return NULL;
	}

	return &conn->iso;
}

#if defined(CONFIG_BT_ISO_BROADCAST)

static struct bt_iso_big *get_free_big(void)
+2 −0
Original line number Diff line number Diff line
@@ -133,3 +133,5 @@ void bt_iso_chan_set_state(struct bt_iso_chan *chan, uint8_t state);

/* Process incoming data for a connection */
void bt_iso_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags);

struct bt_conn_iso *bt_conn_iso(struct bt_conn *conn);