Return-Path: MIME-Version: 1.0 In-Reply-To: <20170313175412.11365-2-eu@felipetonello.com> References: <20170313175412.11365-1-eu@felipetonello.com> <20170313175412.11365-2-eu@felipetonello.com> From: Luiz Augusto von Dentz Date: Tue, 14 Mar 2017 15:08:14 +0200 Message-ID: Subject: Re: [RFC][PATCH v3 BlueZ 1/3] Bluetooth: L2CAP: Refactor L2CAP_CONN_PARAM_UPDATE_REQ into a function To: "Felipe F. Tonello" Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: Hi Felipe, On Mon, Mar 13, 2017 at 7:54 PM, Felipe F. Tonello wrote: > This signaling command is useful for any connection parameter change > procedure, thus it is important to allow access to it from outside this > translation unit. > > Signed-off-by: Felipe F. Tonello > --- > include/net/bluetooth/l2cap.h | 3 +++ > net/bluetooth/l2cap_core.c | 36 +++++++++++++++++++++++------------- > 2 files changed, 26 insertions(+), 13 deletions(-) > > diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h > index 5ee3c689c863..ab9ad42d8ed0 100644 > --- a/include/net/bluetooth/l2cap.h > +++ b/include/net/bluetooth/l2cap.h > @@ -948,4 +948,7 @@ void l2cap_conn_put(struct l2cap_conn *conn); > int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user); > void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user); > > +void l2cap_le_conn_req(struct l2cap_conn *conn, u8 min_interval, > + u8 max_interval, u8 latency, u8 supv_timeout); > + > #endif /* __L2CAP_H */ > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c > index fc7f321a3823..50bf68074b44 100644 > --- a/net/bluetooth/l2cap_core.c > +++ b/net/bluetooth/l2cap_core.c > @@ -1483,6 +1483,24 @@ static void l2cap_conn_start(struct l2cap_conn *conn) > mutex_unlock(&conn->chan_lock); > } > > +void l2cap_le_conn_req(struct l2cap_conn *conn, u8 min_interval, > + u8 max_interval, u8 latency, u8 supv_timeout) > +{ > + struct l2cap_conn_param_update_req req; > + > + if (conn->hcon->role != HCI_ROLE_SLAVE) > + return; > + > + req.min = cpu_to_le16(min_interval); > + req.max = cpu_to_le16(max_interval); > + req.latency = cpu_to_le16(latency); > + req.to_multiplier = cpu_to_le16(supv_timeout); > + > + l2cap_send_cmd(conn, l2cap_get_ident(conn), > + L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req); > +} > + > + > static void l2cap_le_conn_ready(struct l2cap_conn *conn) > { > struct hci_conn *hcon = conn->hcon; > @@ -1501,19 +1519,11 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) > * been configured for this connection. If not, then trigger > * the connection update procedure. > */ > - if (hcon->role == HCI_ROLE_SLAVE && > - (hcon->le_conn_interval < hcon->le_conn_min_interval || > - hcon->le_conn_interval > hcon->le_conn_max_interval)) { > - struct l2cap_conn_param_update_req req; > - > - req.min = cpu_to_le16(hcon->le_conn_min_interval); > - req.max = cpu_to_le16(hcon->le_conn_max_interval); > - req.latency = cpu_to_le16(hcon->le_conn_latency); > - req.to_multiplier = cpu_to_le16(hcon->le_supv_timeout); > - > - l2cap_send_cmd(conn, l2cap_get_ident(conn), > - L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req); > - } > + if (hcon->le_conn_interval < hcon->le_conn_min_interval || > + hcon->le_conn_interval > hcon->le_conn_max_interval) > + l2cap_le_conn_req(conn, hcon->le_conn_min_interval, > + hcon->le_conn_max_interval, hcon->le_conn_latency, > + hcon->le_supv_timeout); > } > > static void l2cap_conn_ready(struct l2cap_conn *conn) > -- > 2.12.0 Reviewed-By: Luiz Augusto von Dentz -- Luiz Augusto von Dentz