Index: kernel/generic/include/adt/list.h
===================================================================
--- kernel/generic/include/adt/list.h	(revision 7a0359b903311f67678b4a0a3ebbcf0daf6eab38)
+++ kernel/generic/include/adt/list.h	(revision 98e4507eeee6c14eda56b4240fbe1aaba31e91b8)
@@ -41,6 +41,6 @@
 /** Doubly linked list head and link type. */
 typedef struct link {
-	struct link *prev;	/**< Pointer to the previous item in the list. */
-	struct link *next;	/**< Pointer to the next item in the list. */
+	struct link *prev;  /**< Pointer to the previous item in the list. */
+	struct link *next;  /**< Pointer to the next item in the list. */
 } link_t;
 
@@ -48,7 +48,18 @@
  *
  * @param name Name of the new statically allocated list.
+ *
  */
 #define LIST_INITIALIZE(name) \
-	link_t name = { .prev = &name, .next = &name }
+	link_t name = { \
+		.prev = &name, \
+		.next = &name \
+	}
+
+#define list_get_instance(link, type, member) \
+	((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
+
+#define list_foreach(list, iterator) \
+	for (link_t *iterator = (list).next; \
+	    iterator != &(list); iterator = iterator->next)
 
 /** Initialize doubly-linked circular list link
@@ -57,4 +68,5 @@
  *
  * @param link Pointer to link_t structure to be initialized.
+ *
  */
 NO_TRACE static inline void link_initialize(link_t *link)
@@ -68,10 +80,11 @@
  * Initialize doubly-linked circular list.
  *
- * @param head Pointer to link_t structure representing head of the list.
- */
-NO_TRACE static inline void list_initialize(link_t *head)
-{
-	head->prev = head;
-	head->next = head;
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+NO_TRACE static inline void list_initialize(link_t *list)
+{
+	list->prev = list;
+	list->next = list;
 }
 
@@ -81,12 +94,13 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param head Pointer to link_t structure representing head of the list.
- */
-NO_TRACE static inline void list_prepend(link_t *link, link_t *head)
-{
-	link->next = head->next;
-	link->prev = head;
-	head->next->prev = link;
-	head->next = link;
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+NO_TRACE static inline void list_prepend(link_t *link, link_t *list)
+{
+	link->next = list->next;
+	link->prev = list;
+	list->next->prev = link;
+	list->next = link;
 }
 
@@ -96,12 +110,29 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param head Pointer to link_t structure representing head of the list.
- */
-NO_TRACE static inline void list_append(link_t *link, link_t *head)
-{
-	link->prev = head->prev;
-	link->next = head;
-	head->prev->next = link;
-	head->prev = link;
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+NO_TRACE static inline void list_append(link_t *link, link_t *list)
+{
+	link->prev = list->prev;
+	link->next = list;
+	list->prev->next = link;
+	list->prev = link;
+}
+
+/** Insert item before another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_before(link_t *link, link_t *list)
+{
+	list_append(link, list);
+}
+
+/** Insert item after another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_after(link_t *link, link_t *list)
+{
+	list_prepend(list, link);
 }
 
@@ -110,6 +141,7 @@
  * Remove item from doubly-linked circular list.
  *
- * @param link 	Pointer to link_t structure to be removed from the list it is
- * 		contained in.
+ * @param link Pointer to link_t structure to be removed from the list
+ *             it is contained in.
+ *
  */
 NO_TRACE static inline void list_remove(link_t *link)
@@ -124,11 +156,24 @@
  * Query emptiness of doubly-linked circular list.
  *
- * @param head Pointer to link_t structure representing head of the list.
- */
-NO_TRACE static inline bool list_empty(link_t *head)
-{
-	return head->next == head ? true : false;
-}
-
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+NO_TRACE static inline int list_empty(link_t *list)
+{
+	return (list->next == list);
+}
+
+/** Get head item of a list.
+ *
+ * @param list Pointer to link_t structure representing the list.
+ *
+ * @return Head item of the list.
+ * @return NULL if the list is empty.
+ *
+ */
+static inline link_t *list_head(link_t *list)
+{
+	return ((list->next == list) ? NULL : list->next);
+}
 
 /** Split or concatenate headless doubly-linked circular list
@@ -139,29 +184,30 @@
  * concatenates splitted lists and splits concatenated lists.
  *
- * @param part1	Pointer to link_t structure leading the first (half of the
- *		headless) list.
- * @param part2	Pointer to link_t structure leading the second (half of the
- *		headless) list. 
+ * @param part1 Pointer to link_t structure leading the first
+ *              (half of the headless) list.
+ * @param part2 Pointer to link_t structure leading the second
+ *              (half of the headless) list.
+ *
  */
 NO_TRACE static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
 {
-	link_t *hlp;
-
 	part1->prev->next = part2;
-	part2->prev->next = part1;	
-	hlp = part1->prev;
+	part2->prev->next = part1;
+	
+	link_t *hlp = part1->prev;
+	
 	part1->prev = part2->prev;
 	part2->prev = hlp;
 }
 
-
 /** Split headless doubly-linked circular list
  *
  * Split headless doubly-linked circular list.
  *
- * @param part1	Pointer to link_t structure leading the first half of the
- *		headless list.
- * @param part2	Pointer to link_t structure leading the second half of the
- *		headless list. 
+ * @param part1 Pointer to link_t structure leading
+ *              the first half of the headless list.
+ * @param part2 Pointer to link_t structure leading
+ *              the second half of the headless list.
+ *
  */
 NO_TRACE static inline void headless_list_split(link_t *part1, link_t *part2)
@@ -174,6 +220,9 @@
  * Concatenate two headless doubly-linked circular lists.
  *
- * @param part1 Pointer to link_t structure leading the first headless list.
- * @param part2 Pointer to link_t structure leading the second headless list.
+ * @param part1 Pointer to link_t structure leading
+ *              the first headless list.
+ * @param part2 Pointer to link_t structure leading
+ *              the second headless list.
+ *
  */
 NO_TRACE static inline void headless_list_concat(link_t *part1, link_t *part2)
@@ -182,9 +231,30 @@
 }
 
-#define list_get_instance(link, type, member) \
-	((type *)(((uint8_t *)(link)) - ((uint8_t *)&(((type *)NULL)->member))))
-
-extern bool list_member(const link_t *link, const link_t *head);
-extern void list_concat(link_t *head1, link_t *head2);
+/** Get n-th item of a list.
+ *
+ * @param list Pointer to link_t structure representing the list.
+ * @param n    Item number (indexed from zero).
+ *
+ * @return n-th item of the list.
+ * @return NULL if no n-th item found.
+ *
+ */
+static inline link_t *list_nth(link_t *list, unsigned int n)
+{
+	unsigned int cnt = 0;
+	
+	list_foreach(*list, link) {
+		if (cnt == n)
+			return link;
+		
+		cnt++;
+	}
+	
+	return NULL;
+}
+
+extern int list_member(const link_t *, const link_t *);
+extern void list_concat(link_t *, link_t *);
+extern unsigned int list_count(const link_t *);
 
 #endif
