aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_conn.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-08 08:07:53 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-08 08:22:06 -0400
commite8bb6b9739e2e80e0e413f56816af3871388cfe8 (patch)
tree19cd939c436586fc2857a0160dc0e655c1e435e6 /net/bluetooth/hci_conn.c
parent376f54c171674ac1f9a2eefe67d413db4836d25a (diff)
Bluetooth: Fix advertising and active scanning co-existence
Many controllers allow simultaneous active scanning and advertising (e.g. Intel and Broadcom) but some do not (e.g. CSR). It's therefore safest to implement mutual exclusion of these states in the kernel. This patch ensures that the two states are never entered simultaneously. Extra precaution needs to be taken for outgoing connection attempts in slave role (i.e. through directed advertising) in which case the operation that came first has precedence and the one that comes after gets a rejection. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r--net/bluetooth/hci_conn.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 1517f1549f85..490ee8846d9e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -772,6 +772,16 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
772 772
773 /* If requested to connect as slave use directed advertising */ 773 /* If requested to connect as slave use directed advertising */
774 if (!master) { 774 if (!master) {
775 /* If we're active scanning most controllers are unable
776 * to initiate advertising. Simply reject the attempt.
777 */
778 if (test_bit(HCI_LE_SCAN, &hdev->dev_flags) &&
779 hdev->le_scan_type == LE_SCAN_ACTIVE) {
780 skb_queue_purge(&req.cmd_q);
781 hci_conn_del(conn);
782 return ERR_PTR(-EBUSY);
783 }
784
775 hci_req_directed_advertising(&req, conn); 785 hci_req_directed_advertising(&req, conn);
776 goto create_conn; 786 goto create_conn;
777 } 787 }