aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-06 06:41:15 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2014-07-06 07:46:15 -0400
commit09ae260ba452c2ed36ec295941a58cb75db213ed (patch)
tree55b108d9a368ee131a6e7e723c26ea65e0f56f10 /net/bluetooth
parent5ea234d3e5ff9b6e5c82bde5979307213dde249d (diff)
Bluetooth: Use lower timeout for LE auto-connections
When we establish connections as a consequence of receiving an advertising report it makes no sense to wait the normal 20 second LE connection timeout. This patch modifies the hci_connect_le function to take an extra timeout value and uses a lower 2 second timeout for the auto-connection case. This timeout is intentionally chosen to be just a bit higher than the 1.28 second timeout that High Duty Cycle Advertising uses. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_conn.c4
-rw-r--r--net/bluetooth/hci_event.c6
-rw-r--r--net/bluetooth/l2cap_core.c2
-rw-r--r--net/bluetooth/mgmt.c3
4 files changed, 9 insertions, 6 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0d579d036833..faa032fcdaee 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -700,7 +700,8 @@ static void hci_req_directed_advertising(struct hci_request *req,
700} 700}
701 701
702struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, 702struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
703 u8 dst_type, u8 sec_level, u8 auth_type) 703 u8 dst_type, u8 sec_level, u8 auth_type,
704 u16 conn_timeout)
704{ 705{
705 struct hci_conn_params *params; 706 struct hci_conn_params *params;
706 struct hci_conn *conn; 707 struct hci_conn *conn;
@@ -758,6 +759,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
758 conn->sec_level = BT_SECURITY_LOW; 759 conn->sec_level = BT_SECURITY_LOW;
759 conn->pending_sec_level = sec_level; 760 conn->pending_sec_level = sec_level;
760 conn->auth_type = auth_type; 761 conn->auth_type = auth_type;
762 conn->conn_timeout = conn_timeout;
761 763
762 hci_req_init(&req, hdev); 764 hci_req_init(&req, hdev);
763 765
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c2ba79c8fe51..f452e44eff3c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1073,7 +1073,7 @@ static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
1073 if (conn) 1073 if (conn)
1074 queue_delayed_work(hdev->workqueue, 1074 queue_delayed_work(hdev->workqueue,
1075 &conn->le_conn_timeout, 1075 &conn->le_conn_timeout,
1076 HCI_LE_CONN_TIMEOUT); 1076 conn->conn_timeout);
1077 } 1077 }
1078 1078
1079 mgmt_advertising(hdev, *sent); 1079 mgmt_advertising(hdev, *sent);
@@ -1913,7 +1913,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status)
1913 if (cp->filter_policy == HCI_LE_USE_PEER_ADDR) 1913 if (cp->filter_policy == HCI_LE_USE_PEER_ADDR)
1914 queue_delayed_work(conn->hdev->workqueue, 1914 queue_delayed_work(conn->hdev->workqueue,
1915 &conn->le_conn_timeout, 1915 &conn->le_conn_timeout,
1916 HCI_LE_CONN_TIMEOUT); 1916 conn->conn_timeout);
1917 1917
1918unlock: 1918unlock:
1919 hci_dev_unlock(hdev); 1919 hci_dev_unlock(hdev);
@@ -4238,7 +4238,7 @@ static bool check_pending_le_conn(struct hci_dev *hdev, bdaddr_t *addr,
4238 return false; 4238 return false;
4239 4239
4240 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW, 4240 conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
4241 HCI_AT_NO_BONDING); 4241 HCI_AT_NO_BONDING, HCI_LE_AUTOCONN_TIMEOUT);
4242 if (!IS_ERR(conn)) 4242 if (!IS_ERR(conn))
4243 return true; 4243 return true;
4244 4244
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index f1f544a12c3c..a219276d9f92 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7135,7 +7135,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7135 dst_type = ADDR_LE_DEV_RANDOM; 7135 dst_type = ADDR_LE_DEV_RANDOM;
7136 7136
7137 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level, 7137 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level,
7138 auth_type); 7138 auth_type, HCI_LE_CONN_TIMEOUT);
7139 } else { 7139 } else {
7140 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type); 7140 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type);
7141 } 7141 }
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e253f8e1fa47..be91d55c258b 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3116,7 +3116,8 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
3116 hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type); 3116 hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
3117 3117
3118 conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type, 3118 conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type,
3119 sec_level, auth_type); 3119 sec_level, auth_type,
3120 HCI_LE_CONN_TIMEOUT);
3120 } 3121 }
3121 3122
3122 if (IS_ERR(conn)) { 3123 if (IS_ERR(conn)) {