Bluetooth: Fix clearing Fast Connectable when powering off
Subsystems (2)
PATCH 1/2 Bluetooth: Fix clearing Fast Connectable when powering off
From: Johan Hedberg <[email protected]>
The Fast Connectable setting can only be enabled when powered on, so it should implicitly be cleared when powering off. So far the code was relying on HCI_Reset clearing the flag in dev_flags, however usually this happens only upon power on, meaning the flag is left dangling while powered off.
--- net/bluetooth/mgmt.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/mgmt.c +5 -0
@@ -6509,6 +6509,11 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) goto new_settings; } +/* Fast Connectable is only valid while the controller is +* powered on. +*/ +clear_bit (HCI_FAST_CONNECTABLE , &hdev->dev_flags); +mgmt_pending_foreach (MGMT_OP_SET_POWERED , hdev, settings_rsp, &match);/* If the power off is because of hdev unregistration let
Signature · 1 line
2.1.0
PATCH 2/2 Bluetooth: Update Fast Connectable Behavior to match latest mgmt spec
From: Johan Hedberg <[email protected]>
Now that the page scan state can change based on the BR/EDR whitelist we shouldn't require the connectable setting as a pre-requisite. This patch removes the HCI_CONNECTABLE check from set_fast_connectable() and removes any changes to the page scan parameters from set_connectable() (since the parameters are now independent from any connectable setting changes).
--- net/bluetooth/mgmt.c | 13 ------------- 1 file changed, 13 deletions(-)
net/bluetooth/mgmt.c +0 -13
@@ -1968,15 +1968,6 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, } no_scan_update: -/* If we're going from non-connectable to connectable or -* vice-versa when fast connectable is enabled ensure that fast -* connectable gets disabled. write_fast_connectable won't do -* anything if the page scan parameters are already what they -* should be. -*/ -if (cp->val ||test_bit (HCI_FAST_CONNECTABLE , &hdev->dev_flags)) -write_fast_connectable (&req, false); -/* Update the advertising parameters if necessary */ if (test_bit (HCI_ADVERTISING , &hdev->dev_flags))enable_advertising (&req);
@@ -4664,10 +4655,6 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,return mgmt_cmd_status (sk, hdev->id,MGMT_OP_SET_FAST_CONNECTABLE ,MGMT_STATUS_NOT_POWERED ); -if (!test_bit (HCI_CONNECTABLE , &hdev->dev_flags)) -return mgmt_cmd_status (sk, hdev->id,MGMT_OP_SET_FAST_CONNECTABLE , -MGMT_STATUS_REJECTED ); -hci_dev_lock (hdev);if (mgmt_pending_find (MGMT_OP_SET_FAST_CONNECTABLE , hdev)) {
Signature · 1 line
2.1.0