Bluetooth: Don't try background scanning if LE is not enabled
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 7 Jul 2014 12:19:50 +0000 (15:19 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 7 Jul 2014 13:18:16 +0000 (15:18 +0200)
For adapters that do not support LE and ones where LE hasn't been
enabled we shouldn't be trying to initiate background scanning. This
patch adds an extra check to the hci_update_background_scan() to ensure
that we bail out if HCI_LE_ENABLED is not set.

Since we do allow user space to feed the kernel with LE connection
parameters even when LE is not enabled we now need to also call
hci_update_background_scan() as soon as LE gets enabled so that scanning
gets started if necessary.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c
net/bluetooth/mgmt.c

index 6790dc8cff991ec9905113d0b7df0b5b1f004175..f1c5a077e5584e7fbcb8bfcd68a550bfb5664671 100644 (file)
@@ -5403,6 +5403,10 @@ void hci_update_background_scan(struct hci_dev *hdev)
            test_bit(HCI_UNREGISTER, &hdev->dev_flags))
                return;
 
+       /* No point in doing scanning if LE support hasn't been enabled */
+       if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
+               return;
+
        /* If discovery is active don't interfere with it */
        if (hdev->discovery.state != DISCOVERY_STOPPED)
                return;
index b391e2fef4b64789293caa2c1c45775d9ac70131..9cc7108f4c45f95a2dee5f2f5ce980dfdde5a9db 100644 (file)
@@ -2152,6 +2152,8 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status)
                update_scan_rsp_data(&req);
                hci_req_run(&req, NULL);
 
+               hci_update_background_scan(hdev);
+
                hci_dev_unlock(hdev);
        }
 }