* [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising @ 2014-07-08 13:05 johan.hedberg 2014-07-08 13:05 ` [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery johan.hedberg 2014-07-08 13:12 ` [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising Marcel Holtmann 0 siblings, 2 replies; 4+ messages in thread From: johan.hedberg @ 2014-07-08 13:05 UTC (permalink / raw) To: linux-bluetooth From: Johan Hedberg <johan.hedberg@intel.com> There are many different places that can disable LE scanning but we only want to re-enable advertising in hci_cc_le_set_scan_enable() for a very specific use case, which is when the active scanning part of Start Discovery is complete. Because of this, fix the discovery state check to test for the exact state. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5d3095d7d4b0..2b3d366e5d98 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1188,7 +1188,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, &hdev->dev_flags)) hci_discovery_set_state(hdev, DISCOVERY_STOPPED); else if (!test_bit(HCI_LE_ADV, &hdev->dev_flags) && - hdev->discovery.state != DISCOVERY_STARTING) + hdev->discovery.state == DISCOVERY_FINDING) mgmt_reenable_advertising(hdev); break; -- 1.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery 2014-07-08 13:05 [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising johan.hedberg @ 2014-07-08 13:05 ` johan.hedberg 2014-07-08 13:12 ` Marcel Holtmann 2014-07-08 13:12 ` [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising Marcel Holtmann 1 sibling, 1 reply; 4+ messages in thread From: johan.hedberg @ 2014-07-08 13:05 UTC (permalink / raw) To: linux-bluetooth From: Johan Hedberg <johan.hedberg@intel.com> If any of the HCI commands from the hci_stop_discovery function were successfully sent we need to set the discovery state to STOPPING. The Stop Discovery code was already handling this, but the code in clean_up_hci_state was not. This patch updates the hci_stop_discovery to return a bool to indicate whether it queued any commands and the clean_up_hci_state() function respectively to look at the return value and call hci_discovery_set_state() if necessary. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> --- net/bluetooth/mgmt.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 944e6463fd61..a4232bc237f3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -1251,7 +1251,7 @@ static void clean_up_hci_complete(struct hci_dev *hdev, u8 status) } } -static void hci_stop_discovery(struct hci_request *req) +static bool hci_stop_discovery(struct hci_request *req) { struct hci_dev *hdev = req->hdev; struct hci_cp_remote_name_req_cancel cp; @@ -1266,32 +1266,39 @@ static void hci_stop_discovery(struct hci_request *req) hci_req_add_le_scan_disable(req); } - break; + return true; case DISCOVERY_RESOLVING: e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING); if (!e) - return; + break; bacpy(&cp.bdaddr, &e->data.bdaddr); hci_req_add(req, HCI_OP_REMOTE_NAME_REQ_CANCEL, sizeof(cp), &cp); - break; + return true; default: /* Passive scanning */ - if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) + if (test_bit(HCI_LE_SCAN, &hdev->dev_flags)) { hci_req_add_le_scan_disable(req); + return true; + } + break; } + + return false; } static int clean_up_hci_state(struct hci_dev *hdev) { struct hci_request req; struct hci_conn *conn; + bool discov_stopped; + int err; hci_req_init(&req, hdev); @@ -1304,7 +1311,7 @@ static int clean_up_hci_state(struct hci_dev *hdev) if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) disable_advertising(&req); - hci_stop_discovery(&req); + discov_stopped = hci_stop_discovery(&req); list_for_each_entry(conn, &hdev->conn_hash.list, list) { struct hci_cp_disconnect dc; @@ -1338,7 +1345,11 @@ static int clean_up_hci_state(struct hci_dev *hdev) } } - return hci_req_run(&req, clean_up_hci_complete); + err = hci_req_run(&req, clean_up_hci_complete); + if (!err && discov_stopped) + hci_discovery_set_state(hdev, DISCOVERY_STOPPING); + + return err; } static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data, -- 1.9.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery 2014-07-08 13:05 ` [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery johan.hedberg @ 2014-07-08 13:12 ` Marcel Holtmann 0 siblings, 0 replies; 4+ messages in thread From: Marcel Holtmann @ 2014-07-08 13:12 UTC (permalink / raw) To: Johan Hedberg; +Cc: linux-bluetooth Hi Johan, > If any of the HCI commands from the hci_stop_discovery function were > successfully sent we need to set the discovery state to STOPPING. The > Stop Discovery code was already handling this, but the code in > clean_up_hci_state was not. This patch updates the hci_stop_discovery to > return a bool to indicate whether it queued any commands and the > clean_up_hci_state() function respectively to look at the return value > and call hci_discovery_set_state() if necessary. > > Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> > --- > net/bluetooth/mgmt.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising 2014-07-08 13:05 [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising johan.hedberg 2014-07-08 13:05 ` [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery johan.hedberg @ 2014-07-08 13:12 ` Marcel Holtmann 1 sibling, 0 replies; 4+ messages in thread From: Marcel Holtmann @ 2014-07-08 13:12 UTC (permalink / raw) To: Johan Hedberg; +Cc: linux-bluetooth Hi Johan, > There are many different places that can disable LE scanning but we only > want to re-enable advertising in hci_cc_le_set_scan_enable() for a very > specific use case, which is when the active scanning part of Start > Discovery is complete. Because of this, fix the discovery state check to > test for the exact state. > > Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> > --- > net/bluetooth/hci_event.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) patch has been applied to bluetooth-next tree. Regards Marcel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-08 13:12 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-07-08 13:05 [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising johan.hedberg 2014-07-08 13:05 ` [PATCH 2/2] Bluetooth: Fix setting STOPPING state for discovery johan.hedberg 2014-07-08 13:12 ` Marcel Holtmann 2014-07-08 13:12 ` [PATCH 1/2] Bluetooth: Fix check for re-enabling advertising Marcel Holtmann
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox