2012-07-27 22:32:53

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 0/7] Bluetooth: Refactoring hci_connect()

Hi,

Changes from last version:
* Changed the names of the functions that send HCI Commands to avoid confusion;
* There was no need for exporting some functions related to connections;

Cheers,

Vinicius Costa Gomes (7):
Bluetooth: Remove some functions from being exported
Bluetooth: Rename LE and ACL connection functions
Bluetooth: Refactor LE connection into its own function
Bluetooth: Refactor ACL connection into its own function
Bluetooth: Refactor SCO connection into its own function
Bluetooth: Simplify a the connection type handling
Bluetooth: Add type information to the hci_connect() debug statement

include/net/bluetooth/hci_core.h | 2 -
net/bluetooth/hci_conn.c | 99 ++++++++++++++++++++++++--------------
2 files changed, 62 insertions(+), 39 deletions(-)

--
1.7.10.4


2012-07-29 01:35:59

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v4 4/7] Bluetooth: Refactor ACL connection into its own function

The hci_connect() function was starting to get too complicated to be
quickly understood. We can separate the creation of a new ACL
connection into its own function.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0a74399..1d70e9f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -497,18 +497,10 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
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,
- __u8 dst_type, __u8 sec_level, __u8 auth_type)
+static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
+ u8 sec_level, u8 auth_type)
{
struct hci_conn *acl;
- struct hci_conn *sco;
-
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
-
- if (type == LE_LINK)
- return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);

acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) {
@@ -526,6 +518,26 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
hci_acl_create_connection(acl);
}

+ return acl;
+}
+
+/* Create SCO, ACL or LE connection.
+ * Device _must_ be locked */
+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
+ __u8 dst_type, __u8 sec_level, __u8 auth_type)
+{
+ struct hci_conn *acl;
+ struct hci_conn *sco;
+
+ BT_DBG("%s dst %s", hdev->name, batostr(dst));
+
+ if (type == LE_LINK)
+ return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
+
+ acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
+ if (IS_ERR(acl))
+ return acl;
+
if (type == ACL_LINK)
return acl;

--
1.7.10.4


2012-07-29 00:13:21

by Vinicius Costa Gomes

[permalink] [raw]
Subject: Re: [PATCH v3 4/7] Bluetooth: Refactor ACL connection into its own function

Hi Lizardo,

On 18:52 Fri 27 Jul, Anderson Lizardo wrote:
> Hi Vinicius,
>
> On Fri, Jul 27, 2012 at 6:32 PM, Vinicius Costa Gomes
> <[email protected]> wrote:
> > The hci_connect() function was starting to get too complicated to be
> > quickly understood. We can separated the creation of a new ACL
>
> small typo: separated -> separate

Ugh. Thanks.


Cheers,
--
Vinicius

2012-07-27 22:55:10

by Anderson Lizardo

[permalink] [raw]
Subject: Re: [PATCH v3 4/7] Bluetooth: Refactor ACL connection into its own function

Hi Vinicius,

On Fri, Jul 27, 2012 at 6:52 PM, Anderson Lizardo
<[email protected]> wrote:
> Does it make sense to merge the two if()'s above into one? i.e.:
>
> if (IS_ERR(acl) || type == ACL_LINK)
> return acl;
>
> It's still clear, IMHO.

Nevermind, now I see you just factored out this code on next patch.

Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

2012-07-27 22:52:27

by Anderson Lizardo

[permalink] [raw]
Subject: Re: [PATCH v3 4/7] Bluetooth: Refactor ACL connection into its own function

Hi Vinicius,

On Fri, Jul 27, 2012 at 6:32 PM, Vinicius Costa Gomes
<[email protected]> wrote:
> The hci_connect() function was starting to get too complicated to be
> quickly understood. We can separated the creation of a new ACL

small typo: separated -> separate

> connection into its own function.
>
> Signed-off-by: Vinicius Costa Gomes <[email protected]>
> ---
> net/bluetooth/hci_conn.c | 32 ++++++++++++++++++++++----------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 0a74399..1d70e9f 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -497,18 +497,10 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
> 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,
> - __u8 dst_type, __u8 sec_level, __u8 auth_type)
> +static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
> + u8 sec_level, u8 auth_type)
> {
> struct hci_conn *acl;
> - struct hci_conn *sco;
> -
> - BT_DBG("%s dst %s", hdev->name, batostr(dst));
> -
> - if (type == LE_LINK)
> - return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
>
> acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
> if (!acl) {
> @@ -526,6 +518,26 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
> hci_acl_create_connection(acl);
> }
>
> + return acl;
> +}
> +
> +/* Create SCO, ACL or LE connection.
> + * Device _must_ be locked */
> +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
> + __u8 dst_type, __u8 sec_level, __u8 auth_type)
> +{
> + struct hci_conn *acl;
> + struct hci_conn *sco;
> +
> + BT_DBG("%s dst %s", hdev->name, batostr(dst));
> +
> + if (type == LE_LINK)
> + return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
> +
> + acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
> + if (IS_ERR(acl))
> + return acl;
> +
> if (type == ACL_LINK)
> return acl;

Does it make sense to merge the two if()'s above into one? i.e.:

if (IS_ERR(acl) || type == ACL_LINK)
return acl;

It's still clear, IMHO.

Best Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

2012-07-27 22:33:00

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 7/7] Bluetooth: Add type information to the hci_connect() debug statement

Now that we have a "connect" function for each link type, we should be
able to indentify which function is going to be called.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 2e7b776..98670b1 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -566,7 +566,7 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, bdaddr_t *dst,
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
__u8 dst_type, __u8 sec_level, __u8 auth_type)
{
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ BT_DBG("%s dst %s type 0x%x", hdev->name, batostr(dst), type);

switch (type) {
case LE_LINK:
--
1.7.10.4


2012-07-27 22:32:59

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 6/7] Bluetooth: Simplify a the connection type handling

Now that we have separate ways of doing connections for each link type,
we can do better than an "if" statement to handle each link type.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index de7df88..2e7b776 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -568,13 +568,16 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
{
BT_DBG("%s dst %s", hdev->name, batostr(dst));

- if (type == LE_LINK)
+ switch (type) {
+ case LE_LINK:
return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
-
- if (type == ACL_LINK)
+ case ACL_LINK:
return hci_connect_acl(hdev, dst, sec_level, auth_type);
+ case SCO_LINK:
+ return hci_connect_sco(hdev, dst, sec_level, auth_type);
+ }

- return hci_connect_sco(hdev, dst, sec_level, auth_type);
+ return ERR_PTR(-EINVAL);
}

/* Check link security requirement */
--
1.7.10.4


2012-07-27 22:32:58

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 5/7] Bluetooth: Refactor SCO connection into its own function

We can do the same that we did for the other link types, for SCO
connections. The only thing that's worth noting is that as SCO
links need an ACL link, this functions uses the function that adds
an ACL link.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 1d70e9f..de7df88 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -521,29 +521,19 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
return acl;
}

-/* Create SCO, ACL or LE connection.
- * Device _must_ be locked */
-struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
- __u8 dst_type, __u8 sec_level, __u8 auth_type)
+static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, bdaddr_t *dst,
+ u8 sec_level, u8 auth_type)
{
struct hci_conn *acl;
struct hci_conn *sco;

- BT_DBG("%s dst %s", hdev->name, batostr(dst));
-
- if (type == LE_LINK)
- return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
-
acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
if (IS_ERR(acl))
return acl;

- if (type == ACL_LINK)
- return acl;
-
- sco = hci_conn_hash_lookup_ba(hdev, type, dst);
+ sco = hci_conn_hash_lookup_ba(hdev, SCO_LINK, dst);
if (!sco) {
- sco = hci_conn_add(hdev, type, dst);
+ sco = hci_conn_add(hdev, SCO_LINK, dst);
if (!sco) {
hci_conn_put(acl);
return ERR_PTR(-ENOMEM);
@@ -572,6 +562,21 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
return sco;
}

+/* Create SCO, ACL or LE connection. */
+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
+ __u8 dst_type, __u8 sec_level, __u8 auth_type)
+{
+ BT_DBG("%s dst %s", hdev->name, batostr(dst));
+
+ if (type == LE_LINK)
+ return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
+
+ if (type == ACL_LINK)
+ return hci_connect_acl(hdev, dst, sec_level, auth_type);
+
+ return hci_connect_sco(hdev, dst, sec_level, auth_type);
+}
+
/* Check link security requirement */
int hci_conn_check_link_mode(struct hci_conn *conn)
{
--
1.7.10.4


2012-07-27 22:32:57

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 4/7] Bluetooth: Refactor ACL connection into its own function

The hci_connect() function was starting to get too complicated to be
quickly understood. We can separated the creation of a new ACL
connection into its own function.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0a74399..1d70e9f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -497,18 +497,10 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
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,
- __u8 dst_type, __u8 sec_level, __u8 auth_type)
+static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
+ u8 sec_level, u8 auth_type)
{
struct hci_conn *acl;
- struct hci_conn *sco;
-
- BT_DBG("%s dst %s", hdev->name, batostr(dst));
-
- if (type == LE_LINK)
- return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);

acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) {
@@ -526,6 +518,26 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
hci_acl_create_connection(acl);
}

+ return acl;
+}
+
+/* Create SCO, ACL or LE connection.
+ * Device _must_ be locked */
+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
+ __u8 dst_type, __u8 sec_level, __u8 auth_type)
+{
+ struct hci_conn *acl;
+ struct hci_conn *sco;
+
+ BT_DBG("%s dst %s", hdev->name, batostr(dst));
+
+ if (type == LE_LINK)
+ return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
+
+ acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
+ if (IS_ERR(acl))
+ return acl;
+
if (type == ACL_LINK)
return acl;

--
1.7.10.4


2012-07-27 22:32:56

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 3/7] Bluetooth: Refactor LE connection into its own function

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 <[email protected]>
---
net/bluetooth/hci_conn.c | 53 +++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index c30c507..0a74399 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -470,6 +470,33 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
}
EXPORT_SYMBOL(hci_get_route);

+static struct hci_conn *hci_connect_le(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_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
+ if (le)
+ return ERR_PTR(-EBUSY);
+
+ le = hci_conn_add(hdev, LE_LINK, dst);
+ if (!le)
+ return ERR_PTR(-ENOMEM);
+
+ le->dst_type = bdaddr_to_le(dst_type);
+ hci_le_create_connection(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,
@@ -477,33 +504,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_hash_lookup_state(hdev, LE_LINK,
- BT_CONNECT);
- if (le)
- return ERR_PTR(-EBUSY);
-
- le = hci_conn_add(hdev, LE_LINK, dst);
- if (!le)
- return ERR_PTR(-ENOMEM);
-
- le->dst_type = bdaddr_to_le(dst_type);
- hci_le_create_connection(le);
- }
-
- le->pending_sec_level = sec_level;
- le->auth_type = auth_type;
-
- hci_conn_hold(le);
-
- return le;
- }
+ if (type == LE_LINK)
+ return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);

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


2012-07-27 22:32:55

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 2/7] Bluetooth: Rename LE and ACL connection functions

These names were causing much confusion, so we rename these functions
that send HCI commands to be more similar in naming to the actual HCI
commands that will be sent.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
net/bluetooth/hci_conn.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 724eea9..c30c507 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -30,7 +30,7 @@
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/a2mp.h>

-static void hci_le_connect(struct hci_conn *conn)
+static void hci_le_create_connection(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_le_create_conn cp;
@@ -54,12 +54,12 @@ static void hci_le_connect(struct hci_conn *conn)
hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
}

-static void hci_le_connect_cancel(struct hci_conn *conn)
+static void hci_le_create_connection_cancel(struct hci_conn *conn)
{
hci_send_cmd(conn->hdev, HCI_OP_LE_CREATE_CONN_CANCEL, 0, NULL);
}

-static void hci_acl_connect(struct hci_conn *conn)
+static void hci_acl_create_connection(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie;
@@ -103,7 +103,7 @@ static void hci_acl_connect(struct hci_conn *conn)
hci_send_cmd(hdev, HCI_OP_CREATE_CONN, sizeof(cp), &cp);
}

-static void hci_acl_connect_cancel(struct hci_conn *conn)
+static void hci_acl_create_connection_cancel(struct hci_conn *conn)
{
struct hci_cp_create_conn_cancel cp;

@@ -245,9 +245,9 @@ static void hci_conn_timeout(struct work_struct *work)
case BT_CONNECT2:
if (conn->out) {
if (conn->type == ACL_LINK)
- hci_acl_connect_cancel(conn);
+ hci_acl_create_connection_cancel(conn);
else if (conn->type == LE_LINK)
- hci_le_connect_cancel(conn);
+ hci_le_create_connection_cancel(conn);
}
break;
case BT_CONFIG:
@@ -494,7 +494,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
return ERR_PTR(-ENOMEM);

le->dst_type = bdaddr_to_le(dst_type);
- hci_le_connect(le);
+ hci_le_create_connection(le);
}

le->pending_sec_level = sec_level;
@@ -518,7 +518,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
acl->sec_level = BT_SECURITY_LOW;
acl->pending_sec_level = sec_level;
acl->auth_type = auth_type;
- hci_acl_connect(acl);
+ hci_acl_create_connection(acl);
}

if (type == ACL_LINK)
@@ -771,7 +771,7 @@ void hci_conn_check_pending(struct hci_dev *hdev)

conn = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2);
if (conn)
- hci_acl_connect(conn);
+ hci_acl_create_connection(conn);

hci_dev_unlock(hdev);
}
--
1.7.10.4


2012-07-27 22:32:54

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH v3 1/7] Bluetooth: Remove some functions from being exported

Some connection related functions are only used inside hci_conn.c
so no need to have them exported.

Signed-off-by: Vinicius Costa Gomes <[email protected]>
---
include/net/bluetooth/hci_core.h | 2 --
net/bluetooth/hci_conn.c | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 41d9439..7267daf 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -551,9 +551,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
return NULL;
}

-void hci_acl_connect(struct hci_conn *conn);
void hci_acl_disconn(struct hci_conn *conn, __u8 reason);
-void hci_add_sco(struct hci_conn *conn, __u16 handle);
void hci_setup_sync(struct hci_conn *conn, __u16 handle);
void hci_sco_setup(struct hci_conn *conn, __u8 status);

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5ad7da2..724eea9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -59,7 +59,7 @@ static void hci_le_connect_cancel(struct hci_conn *conn)
hci_send_cmd(conn->hdev, HCI_OP_LE_CREATE_CONN_CANCEL, 0, NULL);
}

-void hci_acl_connect(struct hci_conn *conn)
+static void hci_acl_connect(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie;
@@ -129,7 +129,7 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
}

-void hci_add_sco(struct hci_conn *conn, __u16 handle)
+static void hci_add_sco(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_add_sco cp;
--
1.7.10.4


2012-08-16 07:14:16

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [PATCH v3 5/7] Bluetooth: Refactor SCO connection into its own function

Hi Vinicius,

On Fri, Jul 27, 2012 at 07:32:58PM -0300, Vinicius Costa Gomes wrote:
...
> -/* Create SCO, ACL or LE connection.
> - * Device _must_ be locked */
> -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
> - __u8 dst_type, __u8 sec_level, __u8 auth_type)
> +static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, bdaddr_t *dst,
> + u8 sec_level, u8 auth_type)

Here we use u8

...
> +/* Create SCO, ACL or LE connection. */
> +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
> + __u8 dst_type, __u8 sec_level, __u8 auth_type
...

and here __u8

Shall we agree about those type usage, I thought that we use __u* in
headers and u* in c-files. At least in one file we shall use one type.

Best regards
Andrei Emeltchenko


2012-08-15 04:04:39

by Gustavo Padovan

[permalink] [raw]
Subject: Re: [PATCH v3 7/7] Bluetooth: Add type information to the hci_connect() debug statement

Hi Vinicius,

* Vinicius Costa Gomes <[email protected]> [2012-07-27 19:33:00 -0300]:

> Now that we have a "connect" function for each link type, we should be
> able to indentify which function is going to be called.
>
> Signed-off-by: Vinicius Costa Gomes <[email protected]>
> ---
> net/bluetooth/hci_conn.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

all 7 patches have been applied to bluetooth-next. Thanks.

Gustavo