struct list_head tlist;
int ret;
- tlist.next = tlist.prev = &tlist;
+ INIT_LIST_HEAD(&tlist);
spin_lock_irq(&catas_lock);
list_splice_init(&catas_list, &tlist);
spin_unlock_irq(&catas_lock);
{
iter->icm = icm;
iter->chunk = list_empty(&icm->chunk_list) ?
- NULL : list_entry(icm->chunk_list.next,
+ NULL : list_entry(icm->chunk_list.Flink,
struct mlx4_icm_chunk, list);
iter->page_idx = 0;
}
static inline void mlx4_icm_next(struct mlx4_icm_iter *iter)
{
if (++iter->page_idx >= iter->chunk->nsg) {
- if (iter->chunk->list.next == &iter->icm->chunk_list) {
+ if (iter->chunk->list.Flink == &iter->icm->chunk_list) {
iter->chunk = NULL;
return;
}
- iter->chunk = list_entry(iter->chunk->list.next,
+ iter->chunk = list_entry(iter->chunk->list.Flink,
struct mlx4_icm_chunk, list);
iter->page_idx = 0;
}
if (list_empty(&fmr_list))\r
goto done;\r
\r
- p_ib_fmr = list_entry(fmr_list.next, struct ib_fmr, list);\r
+ p_ib_fmr = list_entry(fmr_list.Flink, struct ib_fmr, list);\r
err = p_ib_fmr->device->unmap_fmr(&fmr_list);\r
status = errno_to_iberr(err);\r
\r
+#pragma once
-// taken from list.h
+////////////////////////////////////////////////////////
+//
+// TYPES
+//
+////////////////////////////////////////////////////////
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
+// Use the type, defined in wdm.h
+#define list_head _LIST_ENTRY
-/*
-* Simple doubly linked list implementation.
-*
-* Some of the internal functions ("__xxx") are useful when
-* manipulating whole lists rather than single entries, as
-* sometimes we already know the next/prev entries and we can
-* generate better code by using them directly rather than
-* using the generic single-entry routines.
-*/
-struct list_head {
- struct list_head *next, *prev;
-};
+////////////////////////////////////////////////////////
+//
+// MACROS
+//
+////////////////////////////////////////////////////////
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
+// Define and initialize a list header
#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) \
- (ptr)->next = (ptr); (ptr)->prev = (ptr)
-
-
-/*
-* Insert a new entry between two known consecutive entries.
-*
-* This is only for internal list manipulation where we know
-* the prev/next entries already!
-*/
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-/**
-* list_add - add a new entry
-* @new: new entry to be added
-* @head: list head to add it after
-*
-* Insert a new entry after the specified head.
-* This is good for implementing stacks.
-*/
-static inline void list_add(struct list_head *new, struct list_head *head)
+ struct list_head name = { &(name), &(name) }
+
+// Initialize a list header
+#define INIT_LIST_HEAD(ptr) InitializeListHead(ptr)
+
+// Get to the beginning of the struct for this list entry
+#define list_entry(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
+
+// Iterate over list of 'list_els' of given 'type'
+#define list_for_each_entry(list_el, head, member, type) \
+ for ( list_el = list_entry((head)->Flink, type, member); \
+ &list_el->member != (head); \
+ list_el = list_entry(list_el->member.Flink, type, member))
+
+// Iterate backwards over list of 'list_els' of given 'type'
+#define list_for_each_entry_reverse(list_el, head, member, type) \
+ for (list_el = list_entry((head)->Blink, type, member); \
+ &list_el->member != (head); \
+ list_el = list_entry(list_el->member.Blink, type, member))
+
+// Iterate over list of given type safe against removal of list entry
+#define list_for_each_entry_safe(list_el, tmp_list_el, head, member,type, tmp_type) \
+ for (list_el = list_entry((head)->Flink, type, member), \
+ tmp_list_el = list_entry(list_el->member.Flink, type, member); \
+ &list_el->member != (head); \
+ list_el = tmp_list_el, \
+ tmp_list_el = list_entry(tmp_list_el->member.Flink, tmp_type, member))
+
+
+////////////////////////////////////////////////////////
+//
+// FUNCTIONS
+//
+////////////////////////////////////////////////////////
+
+// Insert a new entry after the specified head.
+static inline void list_add(struct list_head *new_entry, struct list_head *head)
{
- __list_add(new, head, head->next);
+ InsertHeadList( head, new_entry );
}
-/**
-* list_add_tail - add a new entry
-* @new: new entry to be added
-* @head: list head to add it before
-*
-* Insert a new entry before the specified head.
-* This is useful for implementing queues.
-*/
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+// Insert a new entry before the specified head.
+static inline void list_add_tail(struct list_head *new_entry, struct list_head *head)
{
- __list_add(new, head->prev, head);
+ InsertTailList( head, new_entry );
}
- /*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
- /**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
- * in an undefined state.
- */
+// Deletes entry from list.
static inline void list_del(struct list_head *entry)
{
- __list_del(entry->prev, entry->next);
- entry->next = LIST_POISON1;
- entry->prev = LIST_POISON2;
+ RemoveEntryList( entry );
}
-/**
-* list_empty - tests whether a list is empty
-* @head: the list to test.
-*/
+// Tests whether a list is empty
static inline int list_empty(const struct list_head *head)
{
- return head->next == head;
+ return IsListEmpty( head );
}
- static inline void __list_splice(struct list_head *list,
- struct list_head *head)
- {
- struct list_head *first = list->next;
- struct list_head *last = list->prev;
- struct list_head *at = head->next;
-
- first->prev = head;
- head->next = first;
-
- last->next = at;
- at->prev = last;
- }
-
- /**
- * list_splice_init - join two lists and reinitialise the emptied list.
- * @list: the new list to add.
- * @head: the place to add it in the first list.
- *
- * The list at @list is reinitialised
- */
- static inline void list_splice_init(struct list_head *list,
- struct list_head *head)
- {
- if (!list_empty(list)) {
- __list_splice(list, head);
- INIT_LIST_HEAD(list);
- }
- }
-
- /**
- * list_entry - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry - iterate over list of given type
-* @pos: the type * to use as a loop counter.
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-*/
-#define list_for_each_entry(pos, head, member,type) \
- for (pos = list_entry((head)->next, type, member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_reverse - iterate backwards over list of given type.
-* @pos: the type * to use as a loop counter.
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-*/
-#define list_for_each_entry_reverse(pos, head, member,type) \
- for (pos = list_entry((head)->prev, type, member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.prev, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
-* @pos: the type * to use as a loop counter.
-* @n: another type * to use as temporary storage
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-* @type_n: typeof(*n)
-*/
-#define list_for_each_entry_safe(pos, n, head, member,type,type_n) \
- for (pos = list_entry((head)->next, type, member), \
- n = list_entry(pos->member.next, type, member); \
- &pos->member != (head); \
- pos = n, n = list_entry(n->member.next, type_n, member))
+// Insert src_list into dst_list and reinitialise the emptied src_list.
+static inline void list_splice_init(struct list_head *src_list,
+ struct list_head *dst_list)
+{
+ if (!list_empty(src_list)) {
+ struct list_head *first = src_list->Flink;
+ struct list_head *last = src_list->Blink;
+ struct list_head *at = dst_list->Flink;
+
+ first->Blink = dst_list;
+ dst_list->Flink = first;
+
+ last->Flink = at;
+ at->Blink = last;
+
+ INIT_LIST_HEAD(src_list);
+ }
+}
#ifndef MT_LIST_H
#define MT_LIST_H
-// taken from list.h
+/* Use the type, defined in wdm.h */
+#define list_head _LIST_ENTRY
-/*
- * These are non-NULL pointers that will result in page faults
- * under normal circumstances, used to verify that nobody uses
- * non-initialized list entries.
- */
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
+/* Define and initialize a list header */
+#define LIST_HEAD(name) \
+ struct list_head name = { &(name), &(name) }
-/*
-* Simple doubly linked list implementation.
-*
-* Some of the internal functions ("__xxx") are useful when
-* manipulating whole lists rather than single entries, as
-* sometimes we already know the next/prev entries and we can
-* generate better code by using them directly rather than
-* using the generic single-entry routines.
-*/
+/* Initialize a list header */
+#define INIT_LIST_HEAD(ptr) InitializeListHead(ptr)
-struct list_head {
- struct list_head *next, *prev;
-};
+/* Get to the beginning of the struct for this list entry */
+#define list_entry(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
+/* Iterate over list of 'list_els' of given 'type' */
+#define list_for_each_entry(list_el, head, member, type) \
+ for ( list_el = list_entry((head)->Flink, type, member); \
+ &list_el->member != (head); \
+ list_el = list_entry(list_el->member.Flink, type, member))
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
+/* Iterate backwards over list of 'list_els' of given 'type' */
+#define list_for_each_entry_reverse(list_el, head, member, type) \
+ for (list_el = list_entry((head)->Blink, type, member); \
+ &list_el->member != (head); \
+ list_el = list_entry(list_el->member.Blink, type, member))
-#define INIT_LIST_HEAD(ptr) \
- (ptr)->next = (ptr); (ptr)->prev = (ptr)
+/* Iterate over list of given type safe against removal of list entry */
+#define list_for_each_entry_safe(list_el, tmp_list_el, head, member,type, tmp_type) \
+ for (list_el = list_entry((head)->Flink, type, member), \
+ tmp_list_el = list_entry(list_el->member.Flink, type, member); \
+ &list_el->member != (head); \
+ list_el = tmp_list_el, \
+ tmp_list_el = list_entry(tmp_list_el->member.Flink, tmp_type, member))
-/*
-* Insert a new entry between two known consecutive entries.
-*
-* This is only for internal list manipulation where we know
-* the prev/next entries already!
-*/
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
+/* Insert a new entry after the specified head. */
+static inline void list_add(struct list_head *new_entry, struct list_head *head)
{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
+ InsertHeadList( head, new_entry );
}
-/**
-* list_add - add a new entry
-* @new: new entry to be added
-* @head: list head to add it after
-*
-* Insert a new entry after the specified head.
-* This is good for implementing stacks.
-*/
-static inline void list_add(struct list_head *new, struct list_head *head)
+/* Insert a new entry before the specified head. */
+static inline void list_add_tail(struct list_head *new_entry, struct list_head *head)
{
- __list_add(new, head, head->next);
+ InsertTailList( head, new_entry );
}
-/**
-* list_add_tail - add a new entry
-* @new: new entry to be added
-* @head: list head to add it before
-*
-* Insert a new entry before the specified head.
-* This is useful for implementing queues.
-*/
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
+/* Deletes entry from list. */
+static inline void list_del(struct list_head *entry)
{
- __list_add(new, head->prev, head);
+ RemoveEntryList( entry );
}
- /*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
- static inline void __list_del(struct list_head * prev, struct list_head * next)
- {
- next->prev = prev;
- prev->next = next;
- }
-
- /**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
- * in an undefined state.
- */
- static inline void list_del(struct list_head *entry)
- {
- __list_del(entry->prev, entry->next);
- entry->next = LIST_POISON1;
- entry->prev = LIST_POISON2;
- }
-
-/**
-* list_empty - tests whether a list is empty
-* @head: the list to test.
-*/
+/* Tests whether a list is empty */
static inline int list_empty(const struct list_head *head)
{
- return head->next == head;
+ return IsListEmpty( head );
}
- /**
- * list_entry - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry - iterate over list of given type
-* @pos: the type * to use as a loop counter.
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-*/
-#define list_for_each_entry(pos, head, member,type) \
- for (pos = list_entry((head)->next, type, member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_reverse - iterate backwards over list of given type.
-* @pos: the type * to use as a loop counter.
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-*/
-#define list_for_each_entry_reverse(pos, head, member,type) \
- for (pos = list_entry((head)->prev, type, member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.prev, type, member))
-
-
-//leo: macro changed out of unportable operator typeof
-/**
-* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
-* @pos: the type * to use as a loop counter.
-* @n: another type * to use as temporary storage
-* @head: the head for your list.
-* @member: the name of the list_struct within the struct.
-* @type: typeof(*pos)
-* @type_n: typeof(*n)
-*/
-#define list_for_each_entry_safe(pos, n, head, member,type,type_n) \
- for (pos = list_entry((head)->next, type, member), \
- n = list_entry(pos->member.next, type, member); \
- &pos->member != (head); \
- pos = n, n = list_entry(n->member.next, type_n, member))
-
#endif
if (list_empty(fmr_list))
return 0;
- fmr = list_entry(fmr_list->next, struct ib_fmr, list);
+ fmr = list_entry(fmr_list->Flink, struct ib_fmr, list);
return fmr->device->unmap_fmr(fmr_list);
}
{
iter->icm = icm;
iter->chunk = list_empty(&icm->chunk_list) ?
- NULL : list_entry(icm->chunk_list.next,
+ NULL : list_entry(icm->chunk_list.Flink,
struct mthca_icm_chunk, list);
iter->page_idx = 0;
}
static inline void mthca_icm_next(struct mthca_icm_iter *iter)
{
if (++iter->page_idx >= iter->chunk->nsg) {
- if (iter->chunk->list.next == &iter->icm->chunk_list) {
+ if (iter->chunk->list.Flink == &iter->icm->chunk_list) {
iter->chunk = NULL;
return;
}
- iter->chunk = list_entry(iter->chunk->list.next,
+ iter->chunk = list_entry(iter->chunk->list.Flink,
struct mthca_icm_chunk, list);
iter->page_idx = 0;
}