* [PATCH 1/2] Bluetooth: Create function to to the ERTM header size
@ 2012-05-29 2:55 Gustavo Padovan
2012-05-29 2:55 ` [PATCH 2/2] Bluetooth: Remove unused err var from l2cap_segment_sdu() Gustavo Padovan
2012-05-29 2:58 ` [PATCH -v2] Bluetooth: Create function to return the ERTM header size Gustavo Padovan
0 siblings, 2 replies; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-29 2:55 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
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>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] Bluetooth: Remove unused err var from l2cap_segment_sdu()
2012-05-29 2:55 [PATCH 1/2] Bluetooth: Create function to to the ERTM header size Gustavo Padovan
@ 2012-05-29 2:55 ` Gustavo Padovan
2012-05-29 2:58 ` [PATCH -v2] Bluetooth: Create function to return the ERTM header size Gustavo Padovan
1 sibling, 0 replies; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-29 2:55 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Trivial fix, let the code cleaner.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ad06393..aceb52f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2049,7 +2049,6 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
struct sk_buff *skb;
u16 sdu_len;
size_t pdu_len;
- int err = 0;
u8 sar;
BT_DBG("chan %p, msg %p, len %d", chan, msg, (int)len);
@@ -2108,7 +2107,7 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan,
}
}
- return err;
+ return 0;
}
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
--
1.7.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -v2] Bluetooth: Create function to return the ERTM header size
2012-05-29 2:55 [PATCH 1/2] Bluetooth: Create function to to the ERTM header size Gustavo Padovan
2012-05-29 2:55 ` [PATCH 2/2] Bluetooth: Remove unused err var from l2cap_segment_sdu() Gustavo Padovan
@ 2012-05-29 2:58 ` Gustavo Padovan
2012-05-29 6:58 ` Andrei Emeltchenko
1 sibling, 1 reply; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-29 2:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
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>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -v2] Bluetooth: Create function to return the ERTM header size
2012-05-29 2:58 ` [PATCH -v2] Bluetooth: Create function to return the ERTM header size Gustavo Padovan
@ 2012-05-29 6:58 ` Andrei Emeltchenko
2012-05-29 15:27 ` Gustavo Padovan
0 siblings, 1 reply; 5+ messages in thread
From: Andrei Emeltchenko @ 2012-05-29 6:58 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
Hi Gustavo,
On Mon, May 28, 2012 at 11:58:37PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> 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>
> ---
> 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);
I prefer simpler name like:
int hlen = __hdr_size(chan); or __ertm_hdr_size
Otherwise looks good.
Best regards
Andrei Emeltchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -v2] Bluetooth: Create function to return the ERTM header size
2012-05-29 6:58 ` Andrei Emeltchenko
@ 2012-05-29 15:27 ` Gustavo Padovan
0 siblings, 0 replies; 5+ messages in thread
From: Gustavo Padovan @ 2012-05-29 15:27 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth, Gustavo Padovan
Hi Andrei,
* Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com> [2012-05-29 09:58:32 +0300]:
> Hi Gustavo,
>
> On Mon, May 28, 2012 at 11:58:37PM -0300, Gustavo Padovan wrote:
> > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> >
> > 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>
> > ---
> > 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);
>
> I prefer simpler name like:
>
> int hlen = __hdr_size(chan); or __ertm_hdr_size
Yes, __ertm_hdr_size() seems nicer.
Gustavo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-29 15:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-29 2:55 [PATCH 1/2] Bluetooth: Create function to to the ERTM header size Gustavo Padovan
2012-05-29 2:55 ` [PATCH 2/2] Bluetooth: Remove unused err var from l2cap_segment_sdu() Gustavo Padovan
2012-05-29 2:58 ` [PATCH -v2] Bluetooth: Create function to return the ERTM header size Gustavo Padovan
2012-05-29 6:58 ` Andrei Emeltchenko
2012-05-29 15:27 ` Gustavo Padovan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.