diff options
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 2 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 40 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 6 |
4 files changed, 43 insertions, 6 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4093133c1283..69967e540c96 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -790,6 +790,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, | |||
790 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, | 790 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, |
791 | u8 *eir); | 791 | u8 *eir); |
792 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); | 792 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); |
793 | int mgmt_discovering(u16 index, u8 discovering); | ||
793 | 794 | ||
794 | /* HCI info for socket */ | 795 | /* HCI info for socket */ |
795 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 796 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index be93dd0eb962..743440615349 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -285,3 +285,5 @@ struct mgmt_ev_remote_name { | |||
285 | bdaddr_t bdaddr; | 285 | bdaddr_t bdaddr; |
286 | __u8 name[MGMT_MAX_NAME_LENGTH]; | 286 | __u8 name[MGMT_MAX_NAME_LENGTH]; |
287 | } __packed; | 287 | } __packed; |
288 | |||
289 | #define MGMT_EV_DISCOVERING 0x0014 | ||
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index cb25628c0583..e64a3de70d77 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -56,7 +56,9 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) | |||
56 | if (status) | 56 | if (status) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | clear_bit(HCI_INQUIRY, &hdev->flags); | 59 | if (test_bit(HCI_MGMT, &hdev->flags) && |
60 | test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) | ||
61 | mgmt_discovering(hdev->id, 0); | ||
60 | 62 | ||
61 | hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); | 63 | hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); |
62 | 64 | ||
@@ -72,7 +74,9 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) | |||
72 | if (status) | 74 | if (status) |
73 | return; | 75 | return; |
74 | 76 | ||
75 | clear_bit(HCI_INQUIRY, &hdev->flags); | 77 | if (test_bit(HCI_MGMT, &hdev->flags) && |
78 | test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) | ||
79 | mgmt_discovering(hdev->id, 0); | ||
76 | 80 | ||
77 | hci_conn_check_pending(hdev); | 81 | hci_conn_check_pending(hdev); |
78 | } | 82 | } |
@@ -841,10 +845,14 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | |||
841 | 845 | ||
842 | if (status) { | 846 | if (status) { |
843 | hci_req_complete(hdev, HCI_OP_INQUIRY, status); | 847 | hci_req_complete(hdev, HCI_OP_INQUIRY, status); |
844 | |||
845 | hci_conn_check_pending(hdev); | 848 | hci_conn_check_pending(hdev); |
846 | } else | 849 | return; |
847 | set_bit(HCI_INQUIRY, &hdev->flags); | 850 | } |
851 | |||
852 | if (test_bit(HCI_MGMT, &hdev->flags) && | ||
853 | !test_and_set_bit(HCI_INQUIRY, | ||
854 | &hdev->flags)) | ||
855 | mgmt_discovering(hdev->id, 1); | ||
848 | } | 856 | } |
849 | 857 | ||
850 | static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) | 858 | static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) |
@@ -1208,7 +1216,9 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff | |||
1208 | 1216 | ||
1209 | BT_DBG("%s status %d", hdev->name, status); | 1217 | BT_DBG("%s status %d", hdev->name, status); |
1210 | 1218 | ||
1211 | clear_bit(HCI_INQUIRY, &hdev->flags); | 1219 | if (test_bit(HCI_MGMT, &hdev->flags) && |
1220 | test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) | ||
1221 | mgmt_discovering(hdev->id, 0); | ||
1212 | 1222 | ||
1213 | hci_req_complete(hdev, HCI_OP_INQUIRY, status); | 1223 | hci_req_complete(hdev, HCI_OP_INQUIRY, status); |
1214 | 1224 | ||
@@ -1228,6 +1238,12 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * | |||
1228 | 1238 | ||
1229 | hci_dev_lock(hdev); | 1239 | hci_dev_lock(hdev); |
1230 | 1240 | ||
1241 | if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { | ||
1242 | |||
1243 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
1244 | mgmt_discovering(hdev->id, 1); | ||
1245 | } | ||
1246 | |||
1231 | for (; num_rsp; num_rsp--, info++) { | 1247 | for (; num_rsp; num_rsp--, info++) { |
1232 | bacpy(&data.bdaddr, &info->bdaddr); | 1248 | bacpy(&data.bdaddr, &info->bdaddr); |
1233 | data.pscan_rep_mode = info->pscan_rep_mode; | 1249 | data.pscan_rep_mode = info->pscan_rep_mode; |
@@ -2158,6 +2174,12 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct | |||
2158 | 2174 | ||
2159 | hci_dev_lock(hdev); | 2175 | hci_dev_lock(hdev); |
2160 | 2176 | ||
2177 | if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { | ||
2178 | |||
2179 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
2180 | mgmt_discovering(hdev->id, 1); | ||
2181 | } | ||
2182 | |||
2161 | if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { | 2183 | if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { |
2162 | struct inquiry_info_with_rssi_and_pscan_mode *info; | 2184 | struct inquiry_info_with_rssi_and_pscan_mode *info; |
2163 | info = (void *) (skb->data + 1); | 2185 | info = (void *) (skb->data + 1); |
@@ -2320,6 +2342,12 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct | |||
2320 | if (!num_rsp) | 2342 | if (!num_rsp) |
2321 | return; | 2343 | return; |
2322 | 2344 | ||
2345 | if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { | ||
2346 | |||
2347 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
2348 | mgmt_discovering(hdev->id, 1); | ||
2349 | } | ||
2350 | |||
2323 | hci_dev_lock(hdev); | 2351 | hci_dev_lock(hdev); |
2324 | 2352 | ||
2325 | for (; num_rsp; num_rsp--, info++) { | 2353 | for (; num_rsp; num_rsp--, info++) { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index dbc248f27b1b..4542396fc856 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2149,3 +2149,9 @@ int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name) | |||
2149 | 2149 | ||
2150 | return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL); | 2150 | return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL); |
2151 | } | 2151 | } |
2152 | |||
2153 | int mgmt_discovering(u16 index, u8 discovering) | ||
2154 | { | ||
2155 | return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering, | ||
2156 | sizeof(discovering), NULL); | ||
2157 | } | ||