Skip to content

Commit 2dff20f

Browse files
MariuszSkamracarlescufi
authored andcommitted
csis: Simplify the current connections counting
This makes the code cleaner. Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 86c45b7 commit 2dff20f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

subsys/bluetooth/audio/csis.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,10 @@ static void csis_connected(struct bt_conn *conn, uint8_t err)
530530
for (int i = 0; i < ARRAY_SIZE(csis_insts); i++) {
531531
struct bt_csis *csis = &csis_insts[i];
532532

533-
csis->srv.conn_cnt++;
533+
__ASSERT(csis->srv.conn_cnt < CONFIG_BT_MAX_CONN,
534+
"conn_cnt is %d", CONFIG_BT_MAX_CONN);
534535

535-
__ASSERT(csis->srv.conn_cnt <= CONFIG_BT_MAX_CONN,
536-
"Invalid csis->srv.conn_cnt value");
536+
csis->srv.conn_cnt++;
537537
}
538538
}
539539
}
@@ -557,13 +557,14 @@ static void disconnect_adv(struct k_work *work)
557557
static void handle_csis_disconnect(struct bt_csis *csis, struct bt_conn *conn)
558558
{
559559
#if defined(CONFIG_BT_EXT_ADV)
560-
__ASSERT(csis->srv.conn_cnt != 0, "Invalid csis->srv.conn_cnt value");
560+
__ASSERT(csis->srv.conn_cnt > 0, "conn_cnt is 0");
561561

562562
if (csis->srv.conn_cnt == CONFIG_BT_MAX_CONN &&
563563
csis->srv.adv_enabled) {
564564
/* A connection spot opened up */
565565
k_work_submit(&csis->srv.work);
566566
}
567+
567568
csis->srv.conn_cnt--;
568569
#endif /* CONFIG_BT_EXT_ADV */
569570

0 commit comments

Comments
 (0)