aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-15 13:57:40 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-15 14:28:42 -0400
commitd1967ff88b3854d1bb002cccd15d28ad0d9223a9 (patch)
treed2f7b58e1b1350c7064d33ec3de2eadb3bb14988 /net/bluetooth/mgmt.c
parentefdcf8e3d716730d2212dfd973571a0ed00c9b10 (diff)
Bluetooth: Update class of device on discoverable timeout
When the discoverable timeout triggers and limited discoverable mode was used, then the class of device needs to be updated to remove the limited discoverable bit. To keep the class of device logic in a central place, expose a new function mgmt_discoverable_timeout that can be called from the timeout callback. In case the class of device value needs updating, it will add the HCI command to the transaction. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 292e81fcfa95..ca3cdb520b2f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4288,6 +4288,30 @@ void mgmt_set_powered_failed(struct hci_dev *hdev, int err)
4288 mgmt_pending_remove(cmd); 4288 mgmt_pending_remove(cmd);
4289} 4289}
4290 4290
4291void mgmt_discoverable_timeout(struct hci_dev *hdev)
4292{
4293 struct hci_request req;
4294 u8 scan = SCAN_PAGE;
4295
4296 hci_dev_lock(hdev);
4297
4298 /* When discoverable timeout triggers, then just make sure
4299 * the limited discoverable flag is cleared. Even in the case
4300 * of a timeout triggered from general discoverable, it is
4301 * safe to unconditionally clear the flag.
4302 */
4303 clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
4304
4305 hci_req_init(&req, hdev);
4306 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan);
4307 update_class(&req);
4308 hci_req_run(&req, NULL);
4309
4310 hdev->discov_timeout = 0;
4311
4312 hci_dev_unlock(hdev);
4313}
4314
4291void mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) 4315void mgmt_discoverable(struct hci_dev *hdev, u8 discoverable)
4292{ 4316{
4293 bool changed; 4317 bool changed;