};
struct inquiry_entry {
- struct inquiry_entry *next;
+ struct list_head list;
__u32 timestamp;
struct inquiry_data data;
};
struct inquiry_cache {
+ struct list_head list;
__u32 timestamp;
- struct inquiry_entry *list;
};
struct hci_conn_hash {
static inline void inquiry_cache_init(struct hci_dev *hdev)
{
- struct inquiry_cache *c = &hdev->inq_cache;
- c->list = NULL;
+ INIT_LIST_HEAD(&hdev->inq_cache.list);
}
static inline int inquiry_cache_empty(struct hci_dev *hdev)
{
- struct inquiry_cache *c = &hdev->inq_cache;
- return c->list == NULL;
+ return list_empty(&hdev->inq_cache.list);
}
static inline long inquiry_cache_age(struct hci_dev *hdev)
/* ---- Inquiry support ---- */
static void inquiry_cache_flush(struct hci_dev *hdev)
{
- struct inquiry_cache *cache = &hdev->inq_cache;
- struct inquiry_entry *next = cache->list, *e;
-
- BT_DBG("cache %p", cache);
+ struct inquiry_entry *p, *n;
- cache->list = NULL;
- while ((e = next)) {
- next = e->next;
- kfree(e);
+ list_for_each_entry_safe(p, n, &hdev->inq_cache.list, list) {
+ list_del(&p->list);
+ kfree(p);
}
}
BT_DBG("cache %p, %s", cache, batostr(bdaddr));
- for (e = cache->list; e; e = e->next)
+ list_for_each_entry(e, &cache->list, list) {
if (!bacmp(&e->data.bdaddr, bdaddr))
- break;
- return e;
+ return e;
+ }
+
+ return NULL;
}
void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data)
if (!ie)
return;
- ie->next = cache->list;
- cache->list = ie;
+ list_add(&ie->list, &cache->list);
}
memcpy(&ie->data, data, sizeof(*data));
struct inquiry_entry *e;
int copied = 0;
- for (e = cache->list; e && copied < num; e = e->next, copied++) {
+ list_for_each_entry(e, &cache->list, list) {
struct inquiry_data *data = &e->data;
+
+ if (copied >= num)
+ break;
+
bacpy(&info->bdaddr, &data->bdaddr);
info->pscan_rep_mode = data->pscan_rep_mode;
info->pscan_period_mode = data->pscan_period_mode;
info->pscan_mode = data->pscan_mode;
memcpy(info->dev_class, data->dev_class, 3);
info->clock_offset = data->clock_offset;
+
info++;
+ copied++;
}
BT_DBG("cache %p, copied %d", cache, copied);