Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36812
b: refs/heads/master
c: 6ac5934
h: refs/heads/master
v: v3
  • Loading branch information
Marcel Holtmann authored and David S. Miller committed Sep 29, 2006
1 parent a12e336 commit 3ede62d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1143e5a6d4d69cd36d44e0184769aa2b17041a10
refs/heads/master: 6ac59344ef25d5f0ebadb5663cf700d25d2a3886
6 changes: 6 additions & 0 deletions trunk/include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ struct hci_cp_host_buffer_size {

/* Link Control */
#define OGF_LINK_CTL 0x01

#define OCF_CREATE_CONN 0x0005
struct hci_cp_create_conn {
bdaddr_t bdaddr;
Expand All @@ -307,6 +308,11 @@ struct hci_cp_create_conn {
__u8 role_switch;
} __attribute__ ((packed));

#define OCF_CREATE_CONN_CANCEL 0x0008
struct hci_cp_create_conn_cancel {
bdaddr_t bdaddr;
} __attribute__ ((packed));

#define OCF_ACCEPT_CONN_REQ 0x0009
struct hci_cp_accept_conn_req {
bdaddr_t bdaddr;
Expand Down
9 changes: 6 additions & 3 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,13 @@ static inline void hci_conn_put(struct hci_conn *conn)
if (atomic_dec_and_test(&conn->refcnt)) {
unsigned long timeo;
if (conn->type == ACL_LINK) {
timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT);
if (!conn->out)
timeo *= 2;
del_timer(&conn->idle_timer);
if (conn->state == BT_CONNECTED) {
timeo = msecs_to_jiffies(HCI_DISCONN_TIMEOUT);
if (!conn->out)
timeo *= 2;
} else
timeo = msecs_to_jiffies(10);
} else
timeo = msecs_to_jiffies(10);
mod_timer(&conn->disc_timer, jiffies + timeo);
Expand Down
31 changes: 27 additions & 4 deletions trunk/net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ static void hci_acl_connect(struct hci_conn *conn)
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp);
}

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

BT_DBG("%p", conn);

if (conn->hdev->hci_ver < 2)
return;

bacpy(&cp.bdaddr, &conn->dst);
hci_send_cmd(conn->hdev, OGF_LINK_CTL,
OCF_CREATE_CONN_CANCEL, sizeof(cp), &cp);
}

void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
{
struct hci_cp_disconnect cp;
Expand All @@ -94,7 +108,8 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)

cp.handle = __cpu_to_le16(conn->handle);
cp.reason = reason;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, sizeof(cp), &cp);
hci_send_cmd(conn->hdev, OGF_LINK_CTL,
OCF_DISCONNECT, sizeof(cp), &cp);
}

void hci_add_sco(struct hci_conn *conn, __u16 handle)
Expand Down Expand Up @@ -124,12 +139,20 @@ static void hci_conn_timeout(unsigned long arg)
return;

hci_dev_lock(hdev);
if (conn->state == BT_CONNECTED)

switch (conn->state) {
case BT_CONNECT:
hci_acl_connect_cancel(conn);
break;
case BT_CONNECTED:
hci_acl_disconn(conn, 0x13);
else
break;
default:
conn->state = BT_CLOSED;
break;
}

hci_dev_unlock(hdev);
return;
}

static void hci_conn_idle(unsigned long arg)
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (test_bit(HCI_ENCRYPT, &hdev->flags))
conn->link_mode |= HCI_LM_ENCRYPT;

hci_conn_hold(conn);

/* Get remote features */
if (conn->type == ACL_LINK) {
struct hci_cp_read_remote_features cp;
Expand Down Expand Up @@ -778,6 +780,8 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
hci_send_cmd(hdev, OGF_LINK_CTL,
OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
}

hci_conn_put(conn);
} else
conn->state = BT_CLOSED;

Expand Down

0 comments on commit 3ede62d

Please sign in to comment.