@@ -66,7 +66,7 @@ NET_BUF_POOL_DEFINE(prep_pool, CONFIG_BT_ATT_PREPARE_COUNT, BT_ATT_MTU,
6666#endif /* CONFIG_BT_ATT_PREPARE_COUNT */
6767
6868K_MEM_SLAB_DEFINE (req_slab , sizeof (struct bt_att_req ),
69- CONFIG_BT_ATT_TX_MAX , __alignof__(struct bt_att_req ));
69+ CONFIG_BT_L2CAP_TX_BUF_COUNT , __alignof__(struct bt_att_req ));
7070
7171enum {
7272 ATT_PENDING_RSP ,
@@ -88,7 +88,6 @@ struct bt_att_chan {
8888 struct bt_att_req * req ;
8989 struct k_fifo tx_queue ;
9090 struct k_delayed_work timeout_work ;
91- struct k_sem tx_sem ;
9291 void (* sent )(struct bt_att_chan * chan );
9392 sys_snode_t node ;
9493};
@@ -315,12 +314,7 @@ static void bt_att_sent(struct bt_l2cap_chan *ch)
315314 }
316315
317316 /* Process global queue */
318- err = process_queue (chan , & att -> tx_queue );
319- if (!err ) {
320- return ;
321- }
322-
323- k_sem_give (& chan -> tx_sem );
317+ (void )process_queue (chan , & att -> tx_queue );
324318}
325319
326320static void chan_cfm_sent (struct bt_att_chan * chan )
@@ -464,13 +458,6 @@ static int bt_att_chan_send(struct bt_att_chan *chan, struct net_buf *buf,
464458 BT_DBG ("chan %p flags %u code 0x%02x" , chan , atomic_get (chan -> flags ),
465459 hdr -> code );
466460
467- /* Don't use tx_sem if caller has set it own callback */
468- if (!cb ) {
469- if (k_sem_take (& chan -> tx_sem , K_NO_WAIT ) < 0 ) {
470- return - EAGAIN ;
471- }
472- }
473-
474461 return chan_send (chan , buf , cb );
475462}
476463
@@ -565,25 +552,14 @@ static uint8_t att_mtu_req(struct bt_att_chan *chan, struct net_buf *buf)
565552static int bt_att_chan_req_send (struct bt_att_chan * chan ,
566553 struct bt_att_req * req )
567554{
568- int err ;
569-
570555 __ASSERT_NO_MSG (chan );
571556 __ASSERT_NO_MSG (req );
572557 __ASSERT_NO_MSG (req -> func );
573558 __ASSERT_NO_MSG (!chan -> req );
574559
575560 BT_DBG ("req %p" , req );
576561
577- if (k_sem_take (& chan -> tx_sem , K_NO_WAIT ) < 0 ) {
578- return - EAGAIN ;
579- }
580-
581- err = chan_req_send (chan , req );
582- if (err < 0 ) {
583- k_sem_give (& chan -> tx_sem );
584- }
585-
586- return err ;
562+ return chan_req_send (chan , req );
587563}
588564
589565static void att_process (struct bt_att * att )
@@ -2567,17 +2543,11 @@ static void att_reset(struct bt_att *att)
25672543static void att_chan_detach (struct bt_att_chan * chan )
25682544{
25692545 struct net_buf * buf ;
2570- int i ;
25712546
25722547 BT_DBG ("chan %p" , chan );
25732548
25742549 sys_slist_find_and_remove (& chan -> att -> chans , & chan -> node );
25752550
2576- /* Ensure that any waiters are woken up */
2577- for (i = 0 ; i < CONFIG_BT_ATT_TX_MAX ; i ++ ) {
2578- k_sem_give (& chan -> tx_sem );
2579- }
2580-
25812551 /* Release pending buffers */
25822552 while ((buf = net_buf_get (& chan -> tx_queue , K_NO_WAIT ))) {
25832553 net_buf_unref (buf );
@@ -2811,7 +2781,6 @@ static struct bt_att_chan *att_chan_new(struct bt_att *att, atomic_val_t flags)
28112781 (void )memset (chan , 0 , sizeof (* chan ));
28122782 chan -> chan .chan .ops = & ops ;
28132783 k_fifo_init (& chan -> tx_queue );
2814- k_sem_init (& chan -> tx_sem , CONFIG_BT_ATT_TX_MAX , CONFIG_BT_ATT_TX_MAX );
28152784 atomic_set (chan -> flags , flags );
28162785 chan -> att = att ;
28172786
0 commit comments