Skip to contentSkip to conversation

Bluetooth: Move arming of discoverable timeout to complete handler

PATCH Applied Marcel Holtmann 2 participants 2 messages Oct 15, 2013

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Move arming of discoverable timeout to complete handler

The discoverable timeout is currently armed from hci_event.c and causes some side effects when using HCI commands instead of the management interface. To make this clear, only arm the discoverable timeout from the management command complete handler.

---
 net/bluetooth/hci_event.c |  5 -----
 net/bluetooth/mgmt.c      | 11 +++++++++--
 2 files changed, 9 insertions(+), 7 deletions(-)
net/bluetooth/hci_event.c +0 -5
index 7b133f0..071c0df 100644
@@ -310,11 +310,6 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
 		set_bit(HCI_ISCAN, &hdev->flags);
 		if (!old_iscan)
 			mgmt_discoverable(hdev, 1);
-		if (hdev->discov_timeout > 0) {
-			int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
-			queue_delayed_work(hdev->workqueue, &hdev->discov_off,
-					   to);
-		}
 	} else if (old_iscan)
 		mgmt_discoverable(hdev, 0);
 
net/bluetooth/mgmt.c +9 -2
index 6db2393..686bda76 100644
@@ -1043,12 +1043,19 @@ static void set_discoverable_complete(struct hci_dev *hdev, u8 status)
 	}
 
 	cp = cmd->param;
-	if (cp->val)
+	if (cp->val) {
 		changed = !test_and_set_bit(HCI_DISCOVERABLE,
 					    &hdev->dev_flags);
-	else
+
+		if (hdev->discov_timeout > 0) {
+			int to = msecs_to_jiffies(hdev->discov_timeout * 1000);
+			queue_delayed_work(hdev->workqueue, &hdev->discov_off,
+					   to);
+		}
+	} else {
 		changed = test_and_clear_bit(HCI_DISCOVERABLE,
 					     &hdev->dev_flags);
+	}
 
 	send_settings_rsp(cmd->sk, MGMT_OP_SET_DISCOVERABLE, hdev);
 
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Marcel,

Quoted 10 lines · Marcel Holtmann

The discoverable timeout is currently armed from hci_event.c and causes some side effects when using HCI commands instead of the management interface. To make this clear, only arm the discoverable timeout from the management command complete handler.

---
 net/bluetooth/hci_event.c |  5 -----
 net/bluetooth/mgmt.c      | 11 +++++++++--
 2 files changed, 9 insertions(+), 7 deletions(-)

Applied to bluetooth-next. Thanks.

Johan