* [RFC] Bluetooth: Remove duplicated code in l2cap conn req
@ 2012-02-24 14:00 Andrei Emeltchenko
2012-02-24 16:36 ` Ulisses Furquim
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2012-02-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The same sequence sending L2CAP Connection Request was
used in several places. Using subroutine makes those
places easy to read.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/l2cap_core.c | 49 +++++++++++++++++--------------------------
1 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5f4cfea..e9fadce 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -667,6 +667,21 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan)
return !test_bit(CONF_CONNECT_PEND, &chan->conf_state);
}
+static void l2cap_send_conn_req(struct l2cap_chan *chan)
+{
+ struct l2cap_conn *conn = chan->conn;
+ struct l2cap_conn_req req;
+
+ req.scid = cpu_to_le16(chan->scid);
+ req.psm = chan->psm;
+
+ chan->ident = l2cap_get_ident(conn);
+
+ set_bit(CONF_CONNECT_PEND, &chan->conf_state);
+
+ l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req);
+}
+
static void l2cap_do_start(struct l2cap_chan *chan)
{
struct l2cap_conn *conn = chan->conn;
@@ -676,17 +691,8 @@ static void l2cap_do_start(struct l2cap_chan *chan)
return;
if (l2cap_chan_check_security(chan) &&
- __l2cap_no_conn_pending(chan)) {
- struct l2cap_conn_req req;
- req.scid = cpu_to_le16(chan->scid);
- req.psm = chan->psm;
-
- chan->ident = l2cap_get_ident(conn);
- set_bit(CONF_CONNECT_PEND, &chan->conf_state);
-
- l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ,
- sizeof(req), &req);
- }
+ __l2cap_no_conn_pending(chan))
+ l2cap_send_conn_req(chan);
} else {
struct l2cap_info_req req;
req.type = cpu_to_le16(L2CAP_IT_FEAT_MASK);
@@ -763,8 +769,6 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
}
if (chan->state == BT_CONNECT) {
- struct l2cap_conn_req req;
-
if (!l2cap_chan_check_security(chan) ||
!__l2cap_no_conn_pending(chan)) {
l2cap_chan_unlock(chan);
@@ -779,14 +783,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
continue;
}
- req.scid = cpu_to_le16(chan->scid);
- req.psm = chan->psm;
-
- chan->ident = l2cap_get_ident(conn);
- set_bit(CONF_CONNECT_PEND, &chan->conf_state);
-
- l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ,
- sizeof(req), &req);
+ l2cap_send_conn_req(chan);
} else if (chan->state == BT_CONNECT2) {
struct l2cap_conn_rsp rsp;
@@ -4609,15 +4606,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
if (chan->state == BT_CONNECT) {
if (!status) {
- struct l2cap_conn_req req;
- req.scid = cpu_to_le16(chan->scid);
- req.psm = chan->psm;
-
- chan->ident = l2cap_get_ident(conn);
- set_bit(CONF_CONNECT_PEND, &chan->conf_state);
-
- l2cap_send_cmd(conn, chan->ident,
- L2CAP_CONN_REQ, sizeof(req), &req);
+ l2cap_send_conn_req(chan);
} else {
__clear_chan_timer(chan);
__set_chan_timer(chan,
--
1.7.9
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC] Bluetooth: Remove duplicated code in l2cap conn req
2012-02-24 14:00 [RFC] Bluetooth: Remove duplicated code in l2cap conn req Andrei Emeltchenko
@ 2012-02-24 16:36 ` Ulisses Furquim
2012-02-24 20:21 ` Gustavo Padovan
2012-02-24 20:29 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Ulisses Furquim @ 2012-02-24 16:36 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Fri, Feb 24, 2012 at 12:00 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> The same sequence sending L2CAP Connection Request was
> used in several places. Using subroutine makes those
> places easy to read.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 49 +++++++++++++++++--------------------------
> 1 files changed, 19 insertions(+), 30 deletions(-)
Looks good to me.
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Regards,
--
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Bluetooth: Remove duplicated code in l2cap conn req
2012-02-24 14:00 [RFC] Bluetooth: Remove duplicated code in l2cap conn req Andrei Emeltchenko
2012-02-24 16:36 ` Ulisses Furquim
@ 2012-02-24 20:21 ` Gustavo Padovan
2012-02-24 20:29 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Gustavo Padovan @ 2012-02-24 20:21 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-02-24 16:00:00 +0200]:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> The same sequence sending L2CAP Connection Request was
> used in several places. Using subroutine makes those
> places easy to read.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 49 +++++++++++++++++--------------------------
> 1 files changed, 19 insertions(+), 30 deletions(-)
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Bluetooth: Remove duplicated code in l2cap conn req
2012-02-24 14:00 [RFC] Bluetooth: Remove duplicated code in l2cap conn req Andrei Emeltchenko
2012-02-24 16:36 ` Ulisses Furquim
2012-02-24 20:21 ` Gustavo Padovan
@ 2012-02-24 20:29 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-02-24 20:29 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Fri, Feb 24, 2012, Andrei Emeltchenko wrote:
> The same sequence sending L2CAP Connection Request was
> used in several places. Using subroutine makes those
> places easy to read.
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 49 +++++++++++++++++--------------------------
> 1 files changed, 19 insertions(+), 30 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-24 20:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-24 14:00 [RFC] Bluetooth: Remove duplicated code in l2cap conn req Andrei Emeltchenko
2012-02-24 16:36 ` Ulisses Furquim
2012-02-24 20:21 ` Gustavo Padovan
2012-02-24 20:29 ` Johan Hedberg
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.