All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] Bluetooth: Refactor LE connection into its own function
@ 2012-05-31  0:20 Vinicius Costa Gomes
  2012-05-31  0:20 ` [PATCH 2/5] Bluetooth: Refactor ACL " Vinicius Costa Gomes
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Vinicius Costa Gomes @ 2012-05-31  0:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

The code that handles LE connection is already quite separated from
the rest of the connection procedure, so we can easily put it into
its own.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
---

Because of the moving around, these patches aren't as easy to follow as one would
expect.


 net/bluetooth/hci_conn.c |   44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 1458667b..a7bfc27 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -469,6 +469,29 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
 }
 EXPORT_SYMBOL(hci_get_route);

+static struct hci_conn *add_le_conn(struct hci_dev *hdev, bdaddr_t *dst,
+				    u8 dst_type, u8 sec_level, u8 auth_type)
+{
+	struct hci_conn *le;
+
+	le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
+	if (!le) {
+		le = hci_conn_add(hdev, LE_LINK, dst);
+		if (!le)
+			return ERR_PTR(-ENOMEM);
+
+		le->dst_type = bdaddr_to_le(dst_type);
+		hci_le_connect(le);
+	}
+
+	le->pending_sec_level = sec_level;
+	le->auth_type = auth_type;
+
+	hci_conn_hold(le);
+
+	return le;
+}
+
 /* Create SCO, ACL or LE connection.
  * Device _must_ be locked */
 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
@@ -476,28 +499,11 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
 {
 	struct hci_conn *acl;
 	struct hci_conn *sco;
-	struct hci_conn *le;

 	BT_DBG("%s dst %s", hdev->name, batostr(dst));

-	if (type == LE_LINK) {
-		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
-		if (!le) {
-			le = hci_conn_add(hdev, LE_LINK, dst);
-			if (!le)
-				return ERR_PTR(-ENOMEM);
-
-			le->dst_type = bdaddr_to_le(dst_type);
-			hci_le_connect(le);
-		}
-
-		le->pending_sec_level = sec_level;
-		le->auth_type = auth_type;
-
-		hci_conn_hold(le);
-
-		return le;
-	}
+	if (type == LE_LINK)
+		return add_le_conn(hdev, dst, dst_type, sec_level, auth_type);

 	acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
 	if (!acl) {
--
1.7.10.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-31 17:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31  0:20 [PATCH 1/5] Bluetooth: Refactor LE connection into its own function Vinicius Costa Gomes
2012-05-31  0:20 ` [PATCH 2/5] Bluetooth: Refactor ACL " Vinicius Costa Gomes
2012-05-31  0:20 ` [PATCH 3/5] Bluetooth: Refactor SCO " Vinicius Costa Gomes
2012-05-31  0:20 ` [PATCH 4/5] Bluetooth: Simplify a the connection type handling Vinicius Costa Gomes
2012-05-31  7:39   ` Andrei Emeltchenko
2012-05-31 13:22     ` Gustavo Padovan
2012-05-31 17:27       ` Vinicius Costa Gomes
2012-05-31  7:43   ` Andrei Emeltchenko
2012-05-31  0:20 ` [PATCH 5/5] Bluetooth: Add type information to the hci_connect() debug statement Vinicius Costa Gomes

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.