From 4f39b4ceb16fe8cd3c3ba01a5c4abbcd48bc3ca8 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Sun, 6 Nov 2016 17:06:23 +0200 Subject: [PATCH] Bluetooth: L2CAP: Fix regression causing credits not to be restored Patch 8c118f86734f87ea514d653890263ff154b87a4b causes the wrong semaphore to checked so receiving credits are never restored which caused the channel to get stuck after all the credits are consumed. JIRA: ZEP-1199 Change-Id: I9cd5474b3bcaafcb19d15613939ce30d07befe0a Signed-off-by: Luiz Augusto von Dentz --- subsys/bluetooth/host/l2cap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 2633fb90eec..542e6e8b07e 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -1165,13 +1165,13 @@ static void l2cap_chan_update_credits(struct bt_l2cap_le_chan *chan) uint16_t credits; /* Only give more credits if it went bellow the defined threshold */ - if (nano_sem_count_get(&chan->tx.credits) > + if (nano_sem_count_get(&chan->rx.credits) > L2CAP_LE_CREDITS_THRESHOLD) { goto done; } /* Restore credits */ - credits = L2CAP_LE_MAX_CREDITS - nano_sem_count_get(&chan->tx.credits); + credits = L2CAP_LE_MAX_CREDITS - nano_sem_count_get(&chan->rx.credits); l2cap_chan_rx_give_credits(chan, credits); buf = bt_l2cap_create_pdu(&le_sig, 0);