aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_event.c
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2011-11-04 13:16:53 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-11-08 09:54:08 -0500
commit89352e7d3ab372ffad8efe2aa070e0b63df42b85 (patch)
tree90f0ef4e574bf48b3077efe7e7e5b6a8c4bfd7a0 /net/bluetooth/hci_event.c
parent023d50498d04c77b73eed11d849e436ef5639ed2 (diff)
Bluetooth: Periodic Inquiry and Discovery
By using periodic inquiry command we're not able to detect correctly when the controller has started inquiry. Today we have this workaround in inquiry result event handler to set the HCI_INQUIRY flag when it sees the first inquiry result event. This workaround isn't enough because the device may be performing an inquiry but the HCI_INQUIRY flag is not set. For instance, if there is no device in range, no inquiry result event is generated, consequently, the HCI_INQUIRY flags isn't set when it should so. We rely on HCI_INQUIRY flag to implement the discovery procedure properly. So, as we aren't able to clear/set the HCI_INQUIRY flag in a reliable manner, periodic inquiry events shouldn't change the HCI_INQUIRY flag. Thus, due to that issue and in order to keep compatibility with userspace, periodic inquiry events shouldn't send mgmt discovering events. In future, we might track if periodic inquiry is enabled or not. By tracking this state we'll be able to do some improvements in Discovery such as failing MGMT_OP_START_DISCOVERY command in case periodic inquiry is on. We can also send no mgmt_device_found event if periodic inquiry is on. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r--net/bluetooth/hci_event.c43
1 files changed, 11 insertions, 32 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9dc54db693a3..0c11203c261a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -58,9 +58,9 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
58 if (status) 58 if (status)
59 return; 59 return;
60 60
61 if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && 61 clear_bit(HCI_INQUIRY, &hdev->flags);
62 test_bit(HCI_MGMT, &hdev->flags)) 62
63 mgmt_discovering(hdev->id, 0); 63 mgmt_discovering(hdev->id, 0);
64 64
65 hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); 65 hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
66 66
@@ -76,10 +76,6 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
76 if (status) 76 if (status)
77 return; 77 return;
78 78
79 if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) &&
80 test_bit(HCI_MGMT, &hdev->flags))
81 mgmt_discovering(hdev->id, 0);
82
83 hci_conn_check_pending(hdev); 79 hci_conn_check_pending(hdev);
84} 80}
85 81
@@ -986,9 +982,9 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
986 return; 982 return;
987 } 983 }
988 984
989 if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags) && 985 set_bit(HCI_INQUIRY, &hdev->flags);
990 test_bit(HCI_MGMT, &hdev->flags)) 986
991 mgmt_discovering(hdev->id, 1); 987 mgmt_discovering(hdev->id, 1);
992} 988}
993 989
994static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) 990static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
@@ -1367,13 +1363,14 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
1367 1363
1368 BT_DBG("%s status %d", hdev->name, status); 1364 BT_DBG("%s status %d", hdev->name, status);
1369 1365
1370 if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) &&
1371 test_bit(HCI_MGMT, &hdev->flags))
1372 mgmt_discovering(hdev->id, 0);
1373
1374 hci_req_complete(hdev, HCI_OP_INQUIRY, status); 1366 hci_req_complete(hdev, HCI_OP_INQUIRY, status);
1375 1367
1376 hci_conn_check_pending(hdev); 1368 hci_conn_check_pending(hdev);
1369
1370 if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
1371 return;
1372
1373 mgmt_discovering(hdev->id, 0);
1377} 1374}
1378 1375
1379static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) 1376static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
@@ -1389,12 +1386,6 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
1389 1386
1390 hci_dev_lock(hdev); 1387 hci_dev_lock(hdev);
1391 1388
1392 if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
1393
1394 if (test_bit(HCI_MGMT, &hdev->flags))
1395 mgmt_discovering(hdev->id, 1);
1396 }
1397
1398 for (; num_rsp; num_rsp--, info++) { 1389 for (; num_rsp; num_rsp--, info++) {
1399 bacpy(&data.bdaddr, &info->bdaddr); 1390 bacpy(&data.bdaddr, &info->bdaddr);
1400 data.pscan_rep_mode = info->pscan_rep_mode; 1391 data.pscan_rep_mode = info->pscan_rep_mode;
@@ -2395,12 +2386,6 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
2395 2386
2396 hci_dev_lock(hdev); 2387 hci_dev_lock(hdev);
2397 2388
2398 if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
2399
2400 if (test_bit(HCI_MGMT, &hdev->flags))
2401 mgmt_discovering(hdev->id, 1);
2402 }
2403
2404 if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { 2389 if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
2405 struct inquiry_info_with_rssi_and_pscan_mode *info; 2390 struct inquiry_info_with_rssi_and_pscan_mode *info;
2406 info = (void *) (skb->data + 1); 2391 info = (void *) (skb->data + 1);
@@ -2563,12 +2548,6 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
2563 if (!num_rsp) 2548 if (!num_rsp)
2564 return; 2549 return;
2565 2550
2566 if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) {
2567
2568 if (test_bit(HCI_MGMT, &hdev->flags))
2569 mgmt_discovering(hdev->id, 1);
2570 }
2571
2572 hci_dev_lock(hdev); 2551 hci_dev_lock(hdev);
2573 2552
2574 for (; num_rsp; num_rsp--, info++) { 2553 for (; num_rsp; num_rsp--, info++) {