summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-05-29 13:29:16 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-06-05 06:34:15 +0300
commitba7aa64fe24d293bd433b82c30d505ab8611673f (patch)
tree8dbe36cb7a5b13c108ed31d57e93b41906e5215c
parent6810fca724d2a3c08c0d2eb8510648e7a36ab592 (diff)
downloadop-kernel-dev-ba7aa64fe24d293bd433b82c30d505ab8611673f.zip
op-kernel-dev-ba7aa64fe24d293bd433b82c30d505ab8611673f.tar.gz
Bluetooth: Create function to return the ERTM header size
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 <gustavo.padovan@collabora.co.uk> Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/l2cap_core.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8229ae4..136c2af 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -824,17 +824,20 @@ static inline void __pack_control(struct l2cap_chan *chan,
}
}
+static inline unsigned int __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 = __ertm_hdr_size(chan);
if (chan->fcs == L2CAP_FCS_CRC16)
hlen += L2CAP_FCS_SIZE;
@@ -2018,10 +2021,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 = __ertm_hdr_size(chan);
if (sdulen)
hlen += L2CAP_SDULEN_SIZE;
@@ -2087,10 +2087,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 -= __ertm_hdr_size(chan);
/* Remote device may have requested smaller PDUs */
pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
OpenPOWER on IntegriCloud