aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-07-01 08:11:20 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-03 11:42:53 -0400
commitaf58925ca6175695e502fa792f43a946f7474765 (patch)
treef0e50a2398cbf7a2f04ccb4d2be9115d1ed310fa /net
parent42bd6a56ed1ab4b2cb50f4d4e674874da9b47f46 (diff)
Bluetooth: Provide flags parameter direct to mgmt_device_found
Providing the flags parameter directly to mgmt_device_found function makes the core simpler and more readable. With this it becomes a lot easier to add new flags in the future. This also changes hci_inquiry_cache_update to just return that flags needed for mgmt_device_found since that is its only use for the two return parameters anyway. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_core.c24
-rw-r--r--net/bluetooth/hci_event.c48
-rw-r--r--net/bluetooth/mgmt.c10
3 files changed, 45 insertions, 37 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 237963d5473c..0aa392406629 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -35,6 +35,7 @@
35#include <net/bluetooth/bluetooth.h> 35#include <net/bluetooth/bluetooth.h>
36#include <net/bluetooth/hci_core.h> 36#include <net/bluetooth/hci_core.h>
37#include <net/bluetooth/l2cap.h> 37#include <net/bluetooth/l2cap.h>
38#include <net/bluetooth/mgmt.h>
38 39
39#include "smp.h" 40#include "smp.h"
40 41
@@ -1970,22 +1971,24 @@ void hci_inquiry_cache_update_resolve(struct hci_dev *hdev,
1970 list_add(&ie->list, pos); 1971 list_add(&ie->list, pos);
1971} 1972}
1972 1973
1973bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, 1974u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
1974 bool name_known, bool *ssp) 1975 bool name_known)
1975{ 1976{
1976 struct discovery_state *cache = &hdev->discovery; 1977 struct discovery_state *cache = &hdev->discovery;
1977 struct inquiry_entry *ie; 1978 struct inquiry_entry *ie;
1979 u32 flags = 0;
1978 1980
1979 BT_DBG("cache %p, %pMR", cache, &data->bdaddr); 1981 BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
1980 1982
1981 hci_remove_remote_oob_data(hdev, &data->bdaddr); 1983 hci_remove_remote_oob_data(hdev, &data->bdaddr);
1982 1984
1983 *ssp = data->ssp_mode; 1985 if (!data->ssp_mode)
1986 flags |= MGMT_DEV_FOUND_LEGACY_PAIRING;
1984 1987
1985 ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr); 1988 ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr);
1986 if (ie) { 1989 if (ie) {
1987 if (ie->data.ssp_mode) 1990 if (!ie->data.ssp_mode)
1988 *ssp = true; 1991 flags |= MGMT_DEV_FOUND_LEGACY_PAIRING;
1989 1992
1990 if (ie->name_state == NAME_NEEDED && 1993 if (ie->name_state == NAME_NEEDED &&
1991 data->rssi != ie->data.rssi) { 1994 data->rssi != ie->data.rssi) {
@@ -1998,8 +2001,10 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
1998 2001
1999 /* Entry not in the cache. Add new one. */ 2002 /* Entry not in the cache. Add new one. */
2000 ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC); 2003 ie = kzalloc(sizeof(struct inquiry_entry), GFP_ATOMIC);
2001 if (!ie) 2004 if (!ie) {
2002 return false; 2005 flags |= MGMT_DEV_FOUND_CONFIRM_NAME;
2006 goto done;
2007 }
2003 2008
2004 list_add(&ie->all, &cache->all); 2009 list_add(&ie->all, &cache->all);
2005 2010
@@ -2022,9 +2027,10 @@ update:
2022 cache->timestamp = jiffies; 2027 cache->timestamp = jiffies;
2023 2028
2024 if (ie->name_state == NAME_NOT_KNOWN) 2029 if (ie->name_state == NAME_NOT_KNOWN)
2025 return false; 2030 flags |= MGMT_DEV_FOUND_CONFIRM_NAME;
2026 2031
2027 return true; 2032done:
2033 return flags;
2028} 2034}
2029 2035
2030static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) 2036static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ea155183c1d6..a4854a5d9298 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1132,7 +1132,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
1132 1132
1133 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, 1133 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
1134 d->last_adv_addr_type, NULL, 1134 d->last_adv_addr_type, NULL,
1135 d->last_adv_rssi, 0, 1, 1135 d->last_adv_rssi, 0,
1136 d->last_adv_data, 1136 d->last_adv_data,
1137 d->last_adv_data_len, NULL, 0); 1137 d->last_adv_data_len, NULL, 0);
1138 } 1138 }
@@ -1965,7 +1965,7 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
1965 hci_dev_lock(hdev); 1965 hci_dev_lock(hdev);
1966 1966
1967 for (; num_rsp; num_rsp--, info++) { 1967 for (; num_rsp; num_rsp--, info++) {
1968 bool name_known, ssp; 1968 u32 flags;
1969 1969
1970 bacpy(&data.bdaddr, &info->bdaddr); 1970 bacpy(&data.bdaddr, &info->bdaddr);
1971 data.pscan_rep_mode = info->pscan_rep_mode; 1971 data.pscan_rep_mode = info->pscan_rep_mode;
@@ -1976,10 +1976,10 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
1976 data.rssi = 0x00; 1976 data.rssi = 0x00;
1977 data.ssp_mode = 0x00; 1977 data.ssp_mode = 0x00;
1978 1978
1979 name_known = hci_inquiry_cache_update(hdev, &data, false, &ssp); 1979 flags = hci_inquiry_cache_update(hdev, &data, false);
1980
1980 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, 1981 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
1981 info->dev_class, 0, !name_known, ssp, NULL, 1982 info->dev_class, 0, flags, NULL, 0, NULL, 0);
1982 0, NULL, 0);
1983 } 1983 }
1984 1984
1985 hci_dev_unlock(hdev); 1985 hci_dev_unlock(hdev);
@@ -3257,7 +3257,6 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
3257{ 3257{
3258 struct inquiry_data data; 3258 struct inquiry_data data;
3259 int num_rsp = *((__u8 *) skb->data); 3259 int num_rsp = *((__u8 *) skb->data);
3260 bool name_known, ssp;
3261 3260
3262 BT_DBG("%s num_rsp %d", hdev->name, num_rsp); 3261 BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
3263 3262
@@ -3274,6 +3273,8 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
3274 info = (void *) (skb->data + 1); 3273 info = (void *) (skb->data + 1);
3275 3274
3276 for (; num_rsp; num_rsp--, info++) { 3275 for (; num_rsp; num_rsp--, info++) {
3276 u32 flags;
3277
3277 bacpy(&data.bdaddr, &info->bdaddr); 3278 bacpy(&data.bdaddr, &info->bdaddr);
3278 data.pscan_rep_mode = info->pscan_rep_mode; 3279 data.pscan_rep_mode = info->pscan_rep_mode;
3279 data.pscan_period_mode = info->pscan_period_mode; 3280 data.pscan_period_mode = info->pscan_period_mode;
@@ -3283,16 +3284,18 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
3283 data.rssi = info->rssi; 3284 data.rssi = info->rssi;
3284 data.ssp_mode = 0x00; 3285 data.ssp_mode = 0x00;
3285 3286
3286 name_known = hci_inquiry_cache_update(hdev, &data, 3287 flags = hci_inquiry_cache_update(hdev, &data, false);
3287 false, &ssp); 3288
3288 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, 3289 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
3289 info->dev_class, info->rssi, 3290 info->dev_class, info->rssi,
3290 !name_known, ssp, NULL, 0, NULL, 0); 3291 flags, NULL, 0, NULL, 0);
3291 } 3292 }
3292 } else { 3293 } else {
3293 struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); 3294 struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
3294 3295
3295 for (; num_rsp; num_rsp--, info++) { 3296 for (; num_rsp; num_rsp--, info++) {
3297 u32 flags;
3298
3296 bacpy(&data.bdaddr, &info->bdaddr); 3299 bacpy(&data.bdaddr, &info->bdaddr);
3297 data.pscan_rep_mode = info->pscan_rep_mode; 3300 data.pscan_rep_mode = info->pscan_rep_mode;
3298 data.pscan_period_mode = info->pscan_period_mode; 3301 data.pscan_period_mode = info->pscan_period_mode;
@@ -3301,11 +3304,12 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
3301 data.clock_offset = info->clock_offset; 3304 data.clock_offset = info->clock_offset;
3302 data.rssi = info->rssi; 3305 data.rssi = info->rssi;
3303 data.ssp_mode = 0x00; 3306 data.ssp_mode = 0x00;
3304 name_known = hci_inquiry_cache_update(hdev, &data, 3307
3305 false, &ssp); 3308 flags = hci_inquiry_cache_update(hdev, &data, false);
3309
3306 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, 3310 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
3307 info->dev_class, info->rssi, 3311 info->dev_class, info->rssi,
3308 !name_known, ssp, NULL, 0, NULL, 0); 3312 flags, NULL, 0, NULL, 0);
3309 } 3313 }
3310 } 3314 }
3311 3315
@@ -3472,7 +3476,8 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,
3472 hci_dev_lock(hdev); 3476 hci_dev_lock(hdev);
3473 3477
3474 for (; num_rsp; num_rsp--, info++) { 3478 for (; num_rsp; num_rsp--, info++) {
3475 bool name_known, ssp; 3479 u32 flags;
3480 bool name_known;
3476 3481
3477 bacpy(&data.bdaddr, &info->bdaddr); 3482 bacpy(&data.bdaddr, &info->bdaddr);
3478 data.pscan_rep_mode = info->pscan_rep_mode; 3483 data.pscan_rep_mode = info->pscan_rep_mode;
@@ -3490,12 +3495,13 @@ static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,
3490 else 3495 else
3491 name_known = true; 3496 name_known = true;
3492 3497
3493 name_known = hci_inquiry_cache_update(hdev, &data, name_known, 3498 flags = hci_inquiry_cache_update(hdev, &data, name_known);
3494 &ssp); 3499
3495 eir_len = eir_get_length(info->data, sizeof(info->data)); 3500 eir_len = eir_get_length(info->data, sizeof(info->data));
3501
3496 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00, 3502 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
3497 info->dev_class, info->rssi, !name_known, 3503 info->dev_class, info->rssi,
3498 ssp, info->data, eir_len, NULL, 0); 3504 flags, info->data, eir_len, NULL, 0);
3499 } 3505 }
3500 3506
3501 hci_dev_unlock(hdev); 3507 hci_dev_unlock(hdev);
@@ -4226,7 +4232,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
4226 } 4232 }
4227 4233
4228 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, 4234 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
4229 rssi, 0, 1, data, len, NULL, 0); 4235 rssi, 0, data, len, NULL, 0);
4230 return; 4236 return;
4231 } 4237 }
4232 4238
@@ -4243,7 +4249,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
4243 if (!match) 4249 if (!match)
4244 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, 4250 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
4245 d->last_adv_addr_type, NULL, 4251 d->last_adv_addr_type, NULL,
4246 d->last_adv_rssi, 0, 1, 4252 d->last_adv_rssi, 0,
4247 d->last_adv_data, 4253 d->last_adv_data,
4248 d->last_adv_data_len, NULL, 0); 4254 d->last_adv_data_len, NULL, 0);
4249 4255
@@ -4261,7 +4267,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
4261 */ 4267 */
4262 clear_pending_adv_report(hdev); 4268 clear_pending_adv_report(hdev);
4263 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL, 4269 mgmt_device_found(hdev, bdaddr, LE_LINK, bdaddr_type, NULL,
4264 rssi, 0, 1, data, len, NULL, 0); 4270 rssi, 0, data, len, NULL, 0);
4265 return; 4271 return;
4266 } 4272 }
4267 4273
@@ -4270,7 +4276,7 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
4270 * sending a merged device found event. 4276 * sending a merged device found event.
4271 */ 4277 */
4272 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK, 4278 mgmt_device_found(hdev, &d->last_adv_addr, LE_LINK,
4273 d->last_adv_addr_type, NULL, rssi, 0, 1, 4279 d->last_adv_addr_type, NULL, rssi, 0,
4274 d->last_adv_data, d->last_adv_data_len, data, len); 4280 d->last_adv_data, d->last_adv_data_len, data, len);
4275 clear_pending_adv_report(hdev); 4281 clear_pending_adv_report(hdev);
4276} 4282}
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c6e9b551242b..336a2311bdca 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6233,9 +6233,8 @@ void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
6233} 6233}
6234 6234
6235void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 6235void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
6236 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, 6236 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
6237 u8 ssp, u8 *eir, u16 eir_len, u8 *scan_rsp, 6237 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
6238 u8 scan_rsp_len)
6239{ 6238{
6240 char buf[512]; 6239 char buf[512];
6241 struct mgmt_ev_device_found *ev = (void *) buf; 6240 struct mgmt_ev_device_found *ev = (void *) buf;
@@ -6263,10 +6262,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
6263 } 6262 }
6264 6263
6265 ev->rssi = rssi; 6264 ev->rssi = rssi;
6266 if (cfm_name) 6265 ev->flags = cpu_to_le32(flags);
6267 ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME);
6268 if (!ssp)
6269 ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING);
6270 6266
6271 if (eir_len > 0) 6267 if (eir_len > 0)
6272 memcpy(ev->eir, eir, eir_len); 6268 memcpy(ev->eir, eir, eir_len);