Thread (5 messages) 5 messages, 2 authors, 2012-05-29

[PATCH 1/2] Bluetooth: Create function to to the ERTM header size

STALE5238d

From: Gustavo Padovan <hidden>
Date: 2012-05-29 02:55:06
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

From: Gustavo Padovan <redacted>

Simplify the handling of different ERTM header size. We were the same
check in some places of the code, and more is expected to come, so just
replace them with a function.

Signed-off-by: Gustavo Padovan <redacted>
---
 net/bluetooth/l2cap_core.c |   25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6f30d1d..ad06393 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -814,17 +814,20 @@ static inline void __pack_control(struct l2cap_chan *chan,
 	}
 }
 
+static inline unsigned int l2cap_ertm_hdr_size(struct l2cap_chan *chan)
+{
+	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
+		return L2CAP_EXT_HDR_SIZE;
+	else
+		return L2CAP_ENH_HDR_SIZE;
+}
+
 static struct sk_buff *l2cap_create_sframe_pdu(struct l2cap_chan *chan,
 					       u32 control)
 {
 	struct sk_buff *skb;
 	struct l2cap_hdr *lh;
-	int hlen;
-
-	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
-		hlen = L2CAP_EXT_HDR_SIZE;
-	else
-		hlen = L2CAP_ENH_HDR_SIZE;
+	int hlen = l2cap_ertm_hdr_size(chan);
 
 	if (chan->fcs == L2CAP_FCS_CRC16)
 		hlen += L2CAP_FCS_SIZE;
@@ -1999,10 +2002,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan,
 	if (!conn)
 		return ERR_PTR(-ENOTCONN);
 
-	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
-		hlen = L2CAP_EXT_HDR_SIZE;
-	else
-		hlen = L2CAP_ENH_HDR_SIZE;
+	hlen = l2cap_ertm_hdr_size(chan);
 
 	if (sdulen)
 		hlen += L2CAP_SDULEN_SIZE;
@@ -2068,10 +2068,7 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
 	if (chan->fcs)
 		pdu_len -= L2CAP_FCS_SIZE;
 
-	if (test_bit(FLAG_EXT_CTRL, &chan->flags))
-		pdu_len -= L2CAP_EXT_HDR_SIZE;
-	else
-		pdu_len -= L2CAP_ENH_HDR_SIZE;
+	pdu_len -= l2cap_ertm_hdr_size(chan);
 
 	/* Remote device may have requested smaller PDUs */
 	pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
-- 
1.7.10.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help