Commit 38b3fef1 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Gustavo Padovan

Bluetooth: Improve debugging messages for hci_conn

Improve debugging of hci_conn objects by: adding print to hci_conn
refcounting, adding object spcifier when missing, change conn to hcon
since conn is heavily used for l2cap_conn objects and this is misleading.
Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent b82c29d8
...@@ -587,12 +587,18 @@ void hci_conn_put_device(struct hci_conn *conn); ...@@ -587,12 +587,18 @@ void hci_conn_put_device(struct hci_conn *conn);
static inline void hci_conn_hold(struct hci_conn *conn) static inline void hci_conn_hold(struct hci_conn *conn)
{ {
BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt),
atomic_read(&conn->refcnt) + 1);
atomic_inc(&conn->refcnt); atomic_inc(&conn->refcnt);
cancel_delayed_work(&conn->disc_work); cancel_delayed_work(&conn->disc_work);
} }
static inline void hci_conn_put(struct hci_conn *conn) static inline void hci_conn_put(struct hci_conn *conn)
{ {
BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt),
atomic_read(&conn->refcnt) - 1);
if (atomic_dec_and_test(&conn->refcnt)) { if (atomic_dec_and_test(&conn->refcnt)) {
unsigned long timeo; unsigned long timeo;
if (conn->type == ACL_LINK || conn->type == LE_LINK) { if (conn->type == ACL_LINK || conn->type == LE_LINK) {
......
...@@ -107,7 +107,7 @@ static void hci_acl_connect_cancel(struct hci_conn *conn) ...@@ -107,7 +107,7 @@ static void hci_acl_connect_cancel(struct hci_conn *conn)
{ {
struct hci_cp_create_conn_cancel cp; struct hci_cp_create_conn_cancel cp;
BT_DBG("%p", conn); BT_DBG("hcon %p", conn);
if (conn->hdev->hci_ver < BLUETOOTH_VER_1_2) if (conn->hdev->hci_ver < BLUETOOTH_VER_1_2)
return; return;
...@@ -120,7 +120,7 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason) ...@@ -120,7 +120,7 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
{ {
struct hci_cp_disconnect cp; struct hci_cp_disconnect cp;
BT_DBG("%p", conn); BT_DBG("hcon %p", conn);
conn->state = BT_DISCONN; conn->state = BT_DISCONN;
...@@ -134,7 +134,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle) ...@@ -134,7 +134,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
struct hci_cp_add_sco cp; struct hci_cp_add_sco cp;
BT_DBG("%p", conn); BT_DBG("hcon %p", conn);
conn->state = BT_CONNECT; conn->state = BT_CONNECT;
conn->out = true; conn->out = true;
...@@ -152,7 +152,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle) ...@@ -152,7 +152,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
struct hci_cp_setup_sync_conn cp; struct hci_cp_setup_sync_conn cp;
BT_DBG("%p", conn); BT_DBG("hcon %p", conn);
conn->state = BT_CONNECT; conn->state = BT_CONNECT;
conn->out = true; conn->out = true;
...@@ -196,7 +196,7 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], ...@@ -196,7 +196,7 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
struct hci_cp_le_start_enc cp; struct hci_cp_le_start_enc cp;
BT_DBG("%p", conn); BT_DBG("hcon %p", conn);
memset(&cp, 0, sizeof(cp)); memset(&cp, 0, sizeof(cp));
...@@ -213,11 +213,11 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status) ...@@ -213,11 +213,11 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
{ {
struct hci_conn *sco = conn->link; struct hci_conn *sco = conn->link;
BT_DBG("%p", conn);
if (!sco) if (!sco)
return; return;
BT_DBG("hcon %p", conn);
if (!status) { if (!status) {
if (lmp_esco_capable(conn->hdev)) if (lmp_esco_capable(conn->hdev))
hci_setup_sync(sco, conn->handle); hci_setup_sync(sco, conn->handle);
...@@ -235,7 +235,7 @@ static void hci_conn_timeout(struct work_struct *work) ...@@ -235,7 +235,7 @@ static void hci_conn_timeout(struct work_struct *work)
disc_work.work); disc_work.work);
__u8 reason; __u8 reason;
BT_DBG("conn %p state %s", conn, state_to_string(conn->state)); BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
if (atomic_read(&conn->refcnt)) if (atomic_read(&conn->refcnt))
return; return;
...@@ -266,7 +266,7 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn) ...@@ -266,7 +266,7 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
BT_DBG("conn %p mode %d", conn, conn->mode); BT_DBG("hcon %p mode %d", conn, conn->mode);
if (test_bit(HCI_RAW, &hdev->flags)) if (test_bit(HCI_RAW, &hdev->flags))
return; return;
...@@ -301,7 +301,7 @@ static void hci_conn_idle(unsigned long arg) ...@@ -301,7 +301,7 @@ static void hci_conn_idle(unsigned long arg)
{ {
struct hci_conn *conn = (void *) arg; struct hci_conn *conn = (void *) arg;
BT_DBG("conn %p mode %d", conn, conn->mode); BT_DBG("hcon %p mode %d", conn, conn->mode);
hci_conn_enter_sniff_mode(conn); hci_conn_enter_sniff_mode(conn);
} }
...@@ -382,7 +382,7 @@ int hci_conn_del(struct hci_conn *conn) ...@@ -382,7 +382,7 @@ int hci_conn_del(struct hci_conn *conn)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
BT_DBG("%s conn %p handle %d", hdev->name, conn, conn->handle); BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
del_timer(&conn->idle_timer); del_timer(&conn->idle_timer);
...@@ -557,7 +557,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, ...@@ -557,7 +557,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
/* Check link security requirement */ /* Check link security requirement */
int hci_conn_check_link_mode(struct hci_conn *conn) int hci_conn_check_link_mode(struct hci_conn *conn)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT)) if (hci_conn_ssp_enabled(conn) && !(conn->link_mode & HCI_LM_ENCRYPT))
return 0; return 0;
...@@ -568,7 +568,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn) ...@@ -568,7 +568,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
/* Authenticate remote device */ /* Authenticate remote device */
static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (conn->pending_sec_level > sec_level) if (conn->pending_sec_level > sec_level)
sec_level = conn->pending_sec_level; sec_level = conn->pending_sec_level;
...@@ -602,7 +602,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) ...@@ -602,7 +602,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
/* Encrypt the the link */ /* Encrypt the the link */
static void hci_conn_encrypt(struct hci_conn *conn) static void hci_conn_encrypt(struct hci_conn *conn)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) { if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
struct hci_cp_set_conn_encrypt cp; struct hci_cp_set_conn_encrypt cp;
...@@ -616,7 +616,7 @@ static void hci_conn_encrypt(struct hci_conn *conn) ...@@ -616,7 +616,7 @@ static void hci_conn_encrypt(struct hci_conn *conn)
/* Enable security */ /* Enable security */
int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
/* For sdp we don't need the link key. */ /* For sdp we don't need the link key. */
if (sec_level == BT_SECURITY_SDP) if (sec_level == BT_SECURITY_SDP)
...@@ -669,7 +669,7 @@ EXPORT_SYMBOL(hci_conn_security); ...@@ -669,7 +669,7 @@ EXPORT_SYMBOL(hci_conn_security);
/* Check secure link requirement */ /* Check secure link requirement */
int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level) int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (sec_level != BT_SECURITY_HIGH) if (sec_level != BT_SECURITY_HIGH)
return 1; /* Accept if non-secure is required */ return 1; /* Accept if non-secure is required */
...@@ -684,7 +684,7 @@ EXPORT_SYMBOL(hci_conn_check_secure); ...@@ -684,7 +684,7 @@ EXPORT_SYMBOL(hci_conn_check_secure);
/* Change link key */ /* Change link key */
int hci_conn_change_link_key(struct hci_conn *conn) int hci_conn_change_link_key(struct hci_conn *conn)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_change_conn_link_key cp; struct hci_cp_change_conn_link_key cp;
...@@ -699,7 +699,7 @@ int hci_conn_change_link_key(struct hci_conn *conn) ...@@ -699,7 +699,7 @@ int hci_conn_change_link_key(struct hci_conn *conn)
/* Switch role */ /* Switch role */
int hci_conn_switch_role(struct hci_conn *conn, __u8 role) int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
{ {
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
if (!role && conn->link_mode & HCI_LM_MASTER) if (!role && conn->link_mode & HCI_LM_MASTER)
return 1; return 1;
...@@ -720,7 +720,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) ...@@ -720,7 +720,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
BT_DBG("conn %p mode %d", conn, conn->mode); BT_DBG("hcon %p mode %d", conn, conn->mode);
if (test_bit(HCI_RAW, &hdev->flags)) if (test_bit(HCI_RAW, &hdev->flags))
return; return;
...@@ -894,7 +894,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn) ...@@ -894,7 +894,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn)
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
struct hci_chan *chan; struct hci_chan *chan;
BT_DBG("%s conn %p", hdev->name, conn); BT_DBG("%s hcon %p", hdev->name, conn);
chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL); chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL);
if (!chan) if (!chan)
...@@ -913,7 +913,7 @@ int hci_chan_del(struct hci_chan *chan) ...@@ -913,7 +913,7 @@ int hci_chan_del(struct hci_chan *chan)
struct hci_conn *conn = chan->conn; struct hci_conn *conn = chan->conn;
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
BT_DBG("%s conn %p chan %p", hdev->name, conn, chan); BT_DBG("%s hcon %p chan %p", hdev->name, conn, chan);
list_del_rcu(&chan->list); list_del_rcu(&chan->list);
...@@ -929,7 +929,7 @@ void hci_chan_list_flush(struct hci_conn *conn) ...@@ -929,7 +929,7 @@ void hci_chan_list_flush(struct hci_conn *conn)
{ {
struct hci_chan *chan, *n; struct hci_chan *chan, *n;
BT_DBG("conn %p", conn); BT_DBG("hcon %p", conn);
list_for_each_entry_safe(chan, n, &conn->chan_list, list) list_for_each_entry_safe(chan, n, &conn->chan_list, list)
hci_chan_del(chan); hci_chan_del(chan);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment