diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_core.c | 31 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 2 |
2 files changed, 18 insertions, 15 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 845da3ee56a0..feeea4df2529 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -357,15 +357,11 @@ struct hci_dev *hci_dev_get(int index) | |||
357 | /* ---- Inquiry support ---- */ | 357 | /* ---- Inquiry support ---- */ |
358 | static void inquiry_cache_flush(struct hci_dev *hdev) | 358 | static void inquiry_cache_flush(struct hci_dev *hdev) |
359 | { | 359 | { |
360 | struct inquiry_cache *cache = &hdev->inq_cache; | 360 | struct inquiry_entry *p, *n; |
361 | struct inquiry_entry *next = cache->list, *e; | ||
362 | |||
363 | BT_DBG("cache %p", cache); | ||
364 | 361 | ||
365 | cache->list = NULL; | 362 | list_for_each_entry_safe(p, n, &hdev->inq_cache.list, list) { |
366 | while ((e = next)) { | 363 | list_del(&p->list); |
367 | next = e->next; | 364 | kfree(p); |
368 | kfree(e); | ||
369 | } | 365 | } |
370 | } | 366 | } |
371 | 367 | ||
@@ -376,10 +372,12 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b | |||
376 | 372 | ||
377 | BT_DBG("cache %p, %s", cache, batostr(bdaddr)); | 373 | BT_DBG("cache %p, %s", cache, batostr(bdaddr)); |
378 | 374 | ||
379 | for (e = cache->list; e; e = e->next) | 375 | list_for_each_entry(e, &cache->list, list) { |
380 | if (!bacmp(&e->data.bdaddr, bdaddr)) | 376 | if (!bacmp(&e->data.bdaddr, bdaddr)) |
381 | break; | 377 | return e; |
382 | return e; | 378 | } |
379 | |||
380 | return NULL; | ||
383 | } | 381 | } |
384 | 382 | ||
385 | void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) | 383 | void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) |
@@ -396,8 +394,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data) | |||
396 | if (!ie) | 394 | if (!ie) |
397 | return; | 395 | return; |
398 | 396 | ||
399 | ie->next = cache->list; | 397 | list_add(&ie->list, &cache->list); |
400 | cache->list = ie; | ||
401 | } | 398 | } |
402 | 399 | ||
403 | memcpy(&ie->data, data, sizeof(*data)); | 400 | memcpy(&ie->data, data, sizeof(*data)); |
@@ -412,15 +409,21 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) | |||
412 | struct inquiry_entry *e; | 409 | struct inquiry_entry *e; |
413 | int copied = 0; | 410 | int copied = 0; |
414 | 411 | ||
415 | for (e = cache->list; e && copied < num; e = e->next, copied++) { | 412 | list_for_each_entry(e, &cache->list, list) { |
416 | struct inquiry_data *data = &e->data; | 413 | struct inquiry_data *data = &e->data; |
414 | |||
415 | if (copied >= num) | ||
416 | break; | ||
417 | |||
417 | bacpy(&info->bdaddr, &data->bdaddr); | 418 | bacpy(&info->bdaddr, &data->bdaddr); |
418 | info->pscan_rep_mode = data->pscan_rep_mode; | 419 | info->pscan_rep_mode = data->pscan_rep_mode; |
419 | info->pscan_period_mode = data->pscan_period_mode; | 420 | info->pscan_period_mode = data->pscan_period_mode; |
420 | info->pscan_mode = data->pscan_mode; | 421 | info->pscan_mode = data->pscan_mode; |
421 | memcpy(info->dev_class, data->dev_class, 3); | 422 | memcpy(info->dev_class, data->dev_class, 3); |
422 | info->clock_offset = data->clock_offset; | 423 | info->clock_offset = data->clock_offset; |
424 | |||
423 | info++; | 425 | info++; |
426 | copied++; | ||
424 | } | 427 | } |
425 | 428 | ||
426 | BT_DBG("cache %p, copied %d", cache, copied); | 429 | BT_DBG("cache %p, copied %d", cache, copied); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 521095614235..ed9cceeec7be 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -388,7 +388,7 @@ static int inquiry_cache_show(struct seq_file *f, void *p) | |||
388 | 388 | ||
389 | hci_dev_lock(hdev); | 389 | hci_dev_lock(hdev); |
390 | 390 | ||
391 | for (e = cache->list; e; e = e->next) { | 391 | list_for_each_entry(e, &cache->list, list) { |
392 | struct inquiry_data *data = &e->data; | 392 | struct inquiry_data *data = &e->data; |
393 | seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", | 393 | seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", |
394 | batostr(&data->bdaddr), | 394 | batostr(&data->bdaddr), |