diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index 81ee38f2fdf..cd6bba36e9c 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -2238,7 +2238,7 @@ static int bt_att_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return 0; } -BT_L2CAP_CHANNEL_DEFINE(att_fixed_chan, BT_L2CAP_CID_ATT, bt_att_accept); +BT_L2CAP_CHANNEL_DEFINE(att_fixed_chan, BT_L2CAP_CID_ATT, bt_att_accept, NULL); void bt_att_init(void) { diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index c59a0b417b9..4dba4257695 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -354,7 +354,7 @@ void bt_l2cap_connected(struct bt_conn *conn) ch->rx.cid = fchan->cid; ch->tx.cid = fchan->cid; - if (!l2cap_chan_add(conn, chan, NULL)) { + if (!l2cap_chan_add(conn, chan, fchan->destroy)) { return; } @@ -1919,7 +1919,7 @@ static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return -ENOMEM; } -BT_L2CAP_CHANNEL_DEFINE(le_fixed_chan, BT_L2CAP_CID_LE_SIG, l2cap_accept); +BT_L2CAP_CHANNEL_DEFINE(le_fixed_chan, BT_L2CAP_CID_LE_SIG, l2cap_accept, NULL); void bt_l2cap_init(void) { diff --git a/subsys/bluetooth/host/l2cap_internal.h b/subsys/bluetooth/host/l2cap_internal.h index 8f06795533c..a5d10a86de2 100644 --- a/subsys/bluetooth/host/l2cap_internal.h +++ b/subsys/bluetooth/host/l2cap_internal.h @@ -202,12 +202,14 @@ struct bt_l2cap_le_credits { struct bt_l2cap_fixed_chan { u16_t cid; int (*accept)(struct bt_conn *conn, struct bt_l2cap_chan **chan); + bt_l2cap_chan_destroy_t destroy; }; -#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept) \ +#define BT_L2CAP_CHANNEL_DEFINE(_name, _cid, _accept, _destroy) \ const Z_STRUCT_SECTION_ITERABLE(bt_l2cap_fixed_chan, _name) = { \ - .cid = _cid, \ - .accept = _accept, \ + .cid = _cid, \ + .accept = _accept, \ + .destroy = _destroy, \ } /* Need a name different than bt_l2cap_fixed_chan for a different section */ diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index 2261c419435..9ece69e384b 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -5311,10 +5311,10 @@ static bool le_sc_supported(void) BT_CMD_TEST(bt_dev.supported_commands, 34, 2); } -BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept); +BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept, NULL); #if defined(CONFIG_BT_BREDR) BT_L2CAP_CHANNEL_DEFINE(smp_br_fixed_chan, BT_L2CAP_CID_BR_SMP, - bt_smp_br_accept); + bt_smp_br_accept, NULL); #endif /* CONFIG_BT_BREDR */ int bt_smp_init(void) diff --git a/subsys/bluetooth/host/smp_null.c b/subsys/bluetooth/host/smp_null.c index 7518a34f8ca..ddb41244c3b 100644 --- a/subsys/bluetooth/host/smp_null.c +++ b/subsys/bluetooth/host/smp_null.c @@ -93,7 +93,7 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) return -ENOMEM; } -BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept); +BT_L2CAP_CHANNEL_DEFINE(smp_fixed_chan, BT_L2CAP_CID_SMP, bt_smp_accept, NULL); int bt_smp_init(void) {