From 8c118f86734f87ea514d653890263ff154b87a4b Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 20 Oct 2016 15:54:37 +0200 Subject: [PATCH] Bluetooth: L2CAP: Fix build with unified kernel Use helper for accesing nano_sem count. This fix build error on unified kernel where nano_sem is wrapped by k_sem. Change-Id: Iad840e3c635a0fbc3b5eeee2e61479fa3d39ca30 Signed-off-by: Szymon Janc --- net/bluetooth/l2cap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 44f6756dc42..24033d48b40 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -541,9 +541,7 @@ static void l2cap_chan_destroy(struct bt_l2cap_chan *chan) /* There could be a writer waiting for credits so return a dummy credit * to wake it up. */ - if (!ch->tx.credits.nsig) { - l2cap_chan_tx_give_credits(ch, 1); - } + l2cap_chan_tx_give_credits(ch, 1); /* Destroy segmented SDU if it exists */ if (ch->_sdu) { @@ -851,7 +849,7 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident, ch = BT_L2CAP_LE_CHAN(chan); - if (ch->tx.credits.nsig + credits > UINT16_MAX) { + if (nano_sem_count_get(&ch->tx.credits) + credits > UINT16_MAX) { BT_ERR("Credits overflow"); bt_l2cap_chan_disconnect(chan); return; @@ -955,12 +953,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 (chan->rx.credits.nsig > L2CAP_LE_CREDITS_THRESHOLD) { + if (nano_sem_count_get(&chan->tx.credits) > + L2CAP_LE_CREDITS_THRESHOLD) { goto done; } /* Restore credits */ - credits = L2CAP_LE_MAX_CREDITS - chan->rx.credits.nsig; + credits = L2CAP_LE_MAX_CREDITS - nano_sem_count_get(&chan->tx.credits); l2cap_chan_rx_give_credits(chan, credits); buf = bt_l2cap_create_pdu(&le_sig, 0);