Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision bd0823961a0f6a8024c1e6eda91ee7ae3987e746)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision 1029397040420ea0b52bc419fa0feadc8a35de9e)
@@ -88,8 +88,8 @@
  * @retval NULL If some error occurs
  */
-usb_hid_report_path_t *usb_hid_report_path_try_insert(
-		usb_hid_report_t *report, usb_hid_report_path_t *cmp_path) {
-	
-	link_t *path_it = report->collection_paths.next;
+usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report,
+    usb_hid_report_path_t *cmp_path)
+{
+	link_t *path_it = report->collection_paths.head.next;
 	usb_hid_report_path_t *path = NULL;
 	
@@ -98,20 +98,20 @@
 	}
 	
-	while(path_it != &report->collection_paths) {
+	while(path_it != &report->collection_paths.head) {
 		path = list_get_instance(path_it, usb_hid_report_path_t,
-				link);
+				cpath_link);
 		
 		if(usb_hid_report_compare_usage_path(path, cmp_path,
 					USB_HID_PATH_COMPARE_STRICT) == EOK){
 			break;
-		}			
+		}
 		path_it = path_it->next;
 	}
-	if(path_it == &report->collection_paths) {
+	if(path_it == &report->collection_paths.head) {
 		path = usb_hid_report_path_clone(cmp_path);
 		if(path == NULL) {
 			return NULL;
 		}
-		list_append(&path->link, &report->collection_paths);					
+		list_append(&path->cpath_link, &report->collection_paths);
 		report->collection_paths_count++;
 
@@ -120,5 +120,5 @@
 	else {
 		return list_get_instance(path_it, usb_hid_report_path_t,
-				link); 
+				cpath_link); 
 	}
 }
@@ -192,5 +192,5 @@
 
 		memset(field, 0, sizeof(usb_hid_report_field_t));
-		list_initialize(&field->link);
+		link_initialize(&field->ritems_link);
 
 		/* fill the attributes */		
@@ -291,13 +291,13 @@
 			}
 
-			list_initialize (&report_des->link);
+			link_initialize (&report_des->reports_link);
 			list_initialize (&report_des->report_items);
 
-			list_append(&report_des->link, &report->reports);
+			list_append(&report_des->reports_link, &report->reports);
 			report->report_count++;
 		}
 
 		/* append this field to the end of founded report list */
-		list_append (&field->link, &report_des->report_items);
+		list_append(&field->ritems_link, &report_des->report_items);
 		
 		/* update the sizes */
@@ -333,10 +333,9 @@
 	}
 
-	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des = NULL;
 	
-	while(report_it != &report->reports) {
+	list_foreach(report->reports, report_it) {
 		report_des = list_get_instance(report_it,
-				usb_hid_report_description_t, link);
+				usb_hid_report_description_t, reports_link);
 
 		// if report id not set, return the first of the type
@@ -345,6 +344,4 @@
 			return report_des;
 		}
-		
-		report_it = report_it->next;
 	}
 
@@ -377,7 +374,9 @@
 	size_t offset_output=0;
 	size_t offset_feature=0;
-
-	link_t stack;
-	list_initialize(&stack);	
+	
+	link_t *item_link;
+
+	list_t stack;
+	list_initialize(&stack);
 
 	/* parser structure initialization*/
@@ -391,5 +390,5 @@
 	}
 	memset(report_item, 0, sizeof(usb_hid_report_item_t));
-	list_initialize(&(report_item->link));	
+	link_initialize(&(report_item->link));
 
 	/* usage path context initialization */
@@ -493,17 +492,18 @@
 			case USB_HID_REPORT_TAG_POP:
 				// restore current state from stack
-				if(list_empty (&stack)) {
+				item_link = list_first(&stack);
+				if (item_link == NULL) {
 					return EINVAL;
 				}
 				free(report_item);
-						
-				report_item = list_get_instance(stack.next, 
+				
+				report_item = list_get_instance(item_link,
 				    usb_hid_report_item_t, link);
-					
+				
 				usb_hid_report_usage_path_t *tmp_usage_path;
 				tmp_usage_path = list_get_instance(
-				    report_item->usage_path->link.prev, 
-				    usb_hid_report_usage_path_t, link);
-					
+				    report_item->usage_path->cpath_link.prev,
+				    usb_hid_report_usage_path_t, rpath_items_link);
+				
 				usb_hid_report_set_last_item(usage_path, 
 				    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
@@ -513,5 +513,5 @@
 
 				usb_hid_report_path_free(report_item->usage_path);
-				list_remove (stack.next);
+				list_remove (item_link);
 					
 				break;
@@ -609,7 +609,7 @@
 
 		/* store collection atributes */
-		path_item = list_get_instance(usage_path->head.prev, 
-			usb_hid_report_usage_path_t, link);
-		path_item->flags = *data;	
+		path_item = list_get_instance(list_first(&usage_path->items),
+			usb_hid_report_usage_path_t, rpath_items_link);
+		path_item->flags = *data;
 			
 		/* set last item */
@@ -900,35 +900,32 @@
  * @return void
  */
-void usb_hid_descriptor_print_list(link_t *head)
+void usb_hid_descriptor_print_list(list_t *list)
 {
 	usb_hid_report_field_t *report_item;
-	link_t *item;
-
-
-	if(head == NULL || list_empty(head)) {
+
+	if(list == NULL || list_empty(list)) {
 	    usb_log_debug("\tempty\n");
 	    return;
 	}
-        
-	for(item = head->next; item != head; item = item->next) {
-                
-		report_item = list_get_instance(item, usb_hid_report_field_t, 
-				link);
+
+        list_foreach(*list, item) {
+		report_item = list_get_instance(item, usb_hid_report_field_t,
+				ritems_link);
 
 		usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
 		usb_log_debug("\t\tSIZE: %zu\n", report_item->size);
-		usb_log_debug("\t\tLOGMIN: %d\n", 
+		usb_log_debug("\t\tLOGMIN: %d\n",
 			report_item->logical_minimum);
-		usb_log_debug("\t\tLOGMAX: %d\n", 
-			report_item->logical_maximum);		
-		usb_log_debug("\t\tPHYMIN: %d\n", 
-			report_item->physical_minimum);		
-		usb_log_debug("\t\tPHYMAX: %d\n", 
-			report_item->physical_maximum);				
-		usb_log_debug("\t\ttUSAGEMIN: %X\n", 
+		usb_log_debug("\t\tLOGMAX: %d\n",
+			report_item->logical_maximum);
+		usb_log_debug("\t\tPHYMIN: %d\n",
+			report_item->physical_minimum);
+		usb_log_debug("\t\tPHYMAX: %d\n",
+			report_item->physical_maximum);
+		usb_log_debug("\t\ttUSAGEMIN: %X\n",
 			report_item->usage_minimum);
 		usb_log_debug("\t\tUSAGEMAX: %X\n",
 			       report_item->usage_maximum);
-		usb_log_debug("\t\tUSAGES COUNT: %zu\n", 
+		usb_log_debug("\t\tUSAGES COUNT: %zu\n",
 			report_item->usages_count);
 
@@ -936,8 +933,8 @@
 		usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage);
 		usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page);
-		
+
 		usb_hid_print_usage_path(report_item->collection_path);
 
-		usb_log_debug("\n");		
+		usb_log_debug("\n");
 
 	}
@@ -958,22 +955,19 @@
 	}
 
-	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des;
 
-	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, 
-			usb_hid_report_description_t, link);
+	list_foreach(report->reports, report_it) {
+		report_des = list_get_instance(report_it,
+			usb_hid_report_description_t, reports_link);
 		usb_log_debug("Report ID: %d\n", report_des->report_id);
 		usb_log_debug("\tType: %d\n", report_des->type);
-		usb_log_debug("\tLength: %zu\n", report_des->bit_length);		
+		usb_log_debug("\tLength: %zu\n", report_des->bit_length);
 		usb_log_debug("\tB Size: %zu\n",
-			usb_hid_report_byte_size(report, 
-				report_des->report_id, 
+			usb_hid_report_byte_size(report,
+				report_des->report_id,
 				report_des->type));
-		usb_log_debug("\tItems: %zu\n", report_des->item_length);		
+		usb_log_debug("\tItems: %zu\n", report_des->item_length);
 
 		usb_hid_descriptor_print_list(&report_des->report_items);
-
-		report_it = report_it->next;
 	}
 }
@@ -983,25 +977,25 @@
  * Releases whole linked list of report items
  *
- * @param head Head of list of report descriptor items (usb_hid_report_item_t)
+ * @param list List of report descriptor items (usb_hid_report_item_t)
  * @return void
  */
-void usb_hid_free_report_list(link_t *head)
+void usb_hid_free_report_list(list_t *list)
 {
-	return; 
-	
-	usb_hid_report_item_t *report_item;
+	return; /* XXX What's this? */
+	
+/*	usb_hid_report_item_t *report_item;
 	link_t *next;
 	
-	if(head == NULL || list_empty(head)) {		
+	if(list == NULL || list_empty(list)) {
 	    return;
 	}
 	
-	next = head->next;
-	while(next != head) {
-	
-	    report_item = list_get_instance(next, usb_hid_report_item_t, link);
+	next = list->head.next;
+	while (next != &list->head) {
+		report_item = list_get_instance(next, usb_hid_report_item_t,
+		    rpath_items_link);
 
 		while(!list_empty(&report_item->usage_path->link)) {
-		    usb_hid_report_remove_last_item(report_item->usage_path);
+			usb_hid_report_remove_last_item(report_item->usage_path);
 		}
 
@@ -1013,5 +1007,5 @@
 	
 	return;
-	
+	*/
 }
 /*---------------------------------------------------------------------------*/
@@ -1029,10 +1023,13 @@
 
 	// free collection paths
+	link_t *path_link;
 	usb_hid_report_path_t *path;
 	while(!list_empty(&report->collection_paths)) {
-		path = list_get_instance(report->collection_paths.next, 
-				usb_hid_report_path_t, link);
-
-		usb_hid_report_path_free(path);		
+		path_link = list_first(&report->collection_paths);
+		path = list_get_instance(path_link,
+		    usb_hid_report_path_t, cpath_link);
+
+		list_remove(path_link);
+		usb_hid_report_path_free(path);
 	}
 	
@@ -1041,15 +1038,15 @@
 	usb_hid_report_field_t *field;
 	while(!list_empty(&report->reports)) {
-		report_des = list_get_instance(report->reports.next, 
-				usb_hid_report_description_t, link);
-
-		list_remove(&report_des->link);
+		report_des = list_get_instance(list_first(&report->reports),
+				usb_hid_report_description_t, reports_link);
+
+		list_remove(&report_des->reports_link);
 		
 		while(!list_empty(&report_des->report_items)) {
 			field = list_get_instance(
-				report_des->report_items.next, 
-				usb_hid_report_field_t, link);
-
-			list_remove(&field->link);
+			    list_first(&report_des->report_items),
+			    usb_hid_report_field_t, ritems_link);
+
+			list_remove(&field->ritems_link);
 
 			free(field);
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision bd0823961a0f6a8024c1e6eda91ee7ae3987e746)
+++ uspace/lib/usbhid/src/hidparser.c	(revision 1029397040420ea0b52bc419fa0feadc8a35de9e)
@@ -135,5 +135,4 @@
 	size_t size, uint8_t *report_id)
 {
-	link_t *list_item;
 	usb_hid_report_field_t *item;
 
@@ -161,9 +160,7 @@
 
 	/* read data */
-	list_item = report_des->report_items.next;	   
-	while(list_item != &(report_des->report_items)) {
-
+	list_foreach(report_des->report_items, list_item) {
 		item = list_get_instance(list_item, usb_hid_report_field_t, 
-				link);
+				ritems_link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
@@ -200,5 +197,4 @@
 			}			
 		}
-		list_item = list_item->next;
 	}
 	
@@ -310,16 +306,14 @@
 	}
 
-	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des = NULL;
-	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, 
-			usb_hid_report_description_t, link);
+
+	list_foreach(report->reports, report_it) {
+		report_des = list_get_instance(report_it,
+			usb_hid_report_description_t, reports_link);
 		
-		if((report_des->report_id == report_id) && 
+		if((report_des->report_id == report_id) &&
 			(report_des->type == USB_HID_REPORT_TYPE_OUTPUT)){
 			break;
 		}
-
-		report_it = report_it->next;
 	}
 
@@ -362,5 +356,4 @@
 	uint8_t report_id, uint8_t *buffer, size_t size)
 {
-	link_t *item;	
 	int32_t value=0;
 	int offset;
@@ -384,8 +377,9 @@
 	}
 
-	usb_hid_report_field_t *report_item;	
-	item = report_des->report_items.next;	
-	while(item != &report_des->report_items) {
-		report_item = list_get_instance(item, usb_hid_report_field_t, link);
+	usb_hid_report_field_t *report_item;
+
+	list_foreach(report_des->report_items, item) {
+		report_item = list_get_instance(item, usb_hid_report_field_t,
+		    ritems_link);
 
 		value = usb_hid_translate_data_reverse(report_item, 
@@ -449,6 +443,4 @@
 		// reset value
 		report_item->value = 0;
-		
-		item = item->next;
 	}
 	
@@ -550,13 +542,13 @@
 
 	if(field == NULL){
-		field_it = report_des->report_items.next;
-	}
-	else {
-		field_it = field->link.next;
-	}
-
-	while(field_it != &report_des->report_items) {
+		field_it = report_des->report_items.head.next;
+	}
+	else {
+		field_it = field->ritems_link.next;
+	}
+
+	while(field_it != &report_des->report_items.head) {
 		field = list_get_instance(field_it, usb_hid_report_field_t, 
-			link);
+			ritems_link);
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
@@ -611,14 +603,14 @@
 		}
 		else {
-			report_it = report_des->link.next;
+			report_it = report_des->reports_link.next;
 		}	
 	}
 	else {
-		report_it = report->reports.next;
-	}
-
-	while(report_it != &report->reports) {
+		report_it = report->reports.head.next;
+	}
+
+	while(report_it != &report->reports.head) {
 		report_des = list_get_instance(report_it, 
-			usb_hid_report_description_t, link);
+			usb_hid_report_description_t, reports_link);
 
 		if(report_des->type == type){
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision bd0823961a0f6a8024c1e6eda91ee7ae3987e746)
+++ uspace/lib/usbhid/src/hidpath.c	(revision 1029397040420ea0b52bc419fa0feadc8a35de9e)
@@ -81,5 +81,5 @@
 		return ENOMEM;
 	}
-	list_initialize(&item->link);
+	link_initialize(&item->rpath_items_link);
 
 	item->usage = usage;
@@ -87,5 +87,5 @@
 	item->flags = 0;
 	
-	list_append (&item->link, &usage_path->head);
+	list_append (&item->rpath_items_link, &usage_path->items);
 	usage_path->depth++;
 	return EOK;
@@ -100,10 +100,12 @@
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path)
 {
+	link_t *item_link;
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){
-		item = list_get_instance(usage_path->head.prev, 
-		                         usb_hid_report_usage_path_t, link);		
-		list_remove(usage_path->head.prev);
+	if(!list_empty(&usage_path->items)){
+		item_link = list_last(&usage_path->items);
+		item = list_get_instance(item_link,
+		    usb_hid_report_usage_path_t, rpath_items_link);
+		list_remove(item_link);
 		usage_path->depth--;
 		free(item);
@@ -122,7 +124,7 @@
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){	
-		item = list_get_instance(usage_path->head.prev, 
-			usb_hid_report_usage_path_t, link);
+	if(!list_empty(&usage_path->items)){
+		item = list_get_instance(list_last(&usage_path->items),
+			usb_hid_report_usage_path_t, rpath_items_link);
 
 		memset(item, 0, sizeof(usb_hid_report_usage_path_t));
@@ -145,7 +147,7 @@
 	usb_hid_report_usage_path_t *item;
 	
-	if(!list_empty(&usage_path->head)){	
-		item = list_get_instance(usage_path->head.prev, 
-		                         usb_hid_report_usage_path_t, link);
+	if(!list_empty(&usage_path->items)){
+		item = list_get_instance(list_last(&usage_path->items),
+		     usb_hid_report_usage_path_t, rpath_items_link);
 
 		switch(tag) {
@@ -173,16 +175,13 @@
 	usb_log_debug("\tLENGTH: %d\n", path->depth);
 
-	link_t *item = path->head.next;
 	usb_hid_report_usage_path_t *path_item;
-	while(item != &path->head) {
-
-		path_item = list_get_instance(item, usb_hid_report_usage_path_t, 
-			link);
+
+	list_foreach(path->items, item) {
+		path_item = list_get_instance(item, usb_hid_report_usage_path_t,
+			rpath_items_link);
 
 		usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
 		usb_log_debug("\tUSAGE: %X\n", path_item->usage);
-		usb_log_debug("\tFLAGS: %d\n", path_item->flags);		
-		
-       	item = item->next;
+		usb_log_debug("\tFLAGS: %d\n", path_item->flags);
 	}
 }
@@ -233,14 +232,13 @@
 		}
 
-		report_link = report_path->head.next;
-		path_link = path->head.next;
-		path_item = list_get_instance(path_link, 
-			usb_hid_report_usage_path_t, link);
-
-		while(report_link != &report_path->head) {
-			report_item = list_get_instance(report_link, 
-				usb_hid_report_usage_path_t, link);
+		path_link = list_first(&path->items);
+		path_item = list_get_instance(path_link,
+			usb_hid_report_usage_path_t, rpath_items_link);
+
+		list_foreach(report_path->items, report_link) {
+			report_item = list_get_instance(report_link,
+				usb_hid_report_usage_path_t, rpath_items_link);
 				
-			if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+			if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
 				path_item->usage_page)){
 					
@@ -257,6 +255,4 @@
 				}
 			}
-
-			report_link = report_link->next;
 		}
 
@@ -273,15 +269,15 @@
 	case USB_HID_PATH_COMPARE_BEGIN:
 	
-		report_link = report_path->head.next;
-		path_link = path->head.next;
+		report_link = report_path->items.head.next;
+		path_link = path->items.head.next;
 			
-		while((report_link != &report_path->head) && 
-		      (path_link != &path->head)) {
+		while((report_link != &report_path->items.head) && 
+		      (path_link != &path->items.head)) {
 					  
 			report_item = list_get_instance(report_link, 
-				usb_hid_report_usage_path_t, link);
+				usb_hid_report_usage_path_t, rpath_items_link);
 					  
 			path_item = list_get_instance(path_link,
-       				usb_hid_report_usage_path_t, link);
+       				usb_hid_report_usage_path_t, rpath_items_link);
 
 			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
@@ -297,10 +293,10 @@
 			}
 			
-				}
+		}
 
 		if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
-			(path_link == &path->head)) || 
-		   ((report_link == &report_path->head) && 
-			(path_link == &path->head))) {
+			(path_link == &path->items.head)) || 
+		   ((report_link == &report_path->items.head) && 
+			(path_link == &path->items.head))) {
 				
 			return EOK;
@@ -314,19 +310,19 @@
 	case USB_HID_PATH_COMPARE_END:
 
-		report_link = report_path->head.prev;
-		path_link = path->head.prev;
-
-		if(list_empty(&path->head)){
+		report_link = report_path->items.head.prev;
+		path_link = path->items.head.prev;
+
+		if(list_empty(&path->items)){
 			return EOK;
 		}
 			
-		while((report_link != &report_path->head) && 
-		      (path_link != &path->head)) {
+		while((report_link != &report_path->items.head) && 
+		      (path_link != &path->items.head)) {
 						  
-			report_item = list_get_instance(report_link, 
-				usb_hid_report_usage_path_t, link);
+			report_item = list_get_instance(report_link,
+				usb_hid_report_usage_path_t, rpath_items_link);
 
 			path_item = list_get_instance(path_link, 
-				usb_hid_report_usage_path_t, link);		
+				usb_hid_report_usage_path_t, rpath_items_link);
 						  
 			if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
@@ -343,5 +339,5 @@
 		}
 
-		if(path_link == &path->head) {
+		if(path_link == &path->items.head) {
 			return EOK;
 		}
@@ -373,6 +369,6 @@
 		path->depth = 0;
 		path->report_id = 0;
-		list_initialize(&path->link);
-		list_initialize(&path->head);
+		link_initialize(&path->cpath_link);
+		list_initialize(&path->items);
 		return path;
 	}
@@ -388,9 +384,9 @@
 void usb_hid_report_path_free(usb_hid_report_path_t *path)
 {
-	while(!list_empty(&path->head)){
+	while(!list_empty(&path->items)){
 		usb_hid_report_remove_last_item(path);
 	}
 
-	list_remove(&path->link);
+	assert_link_not_used(&path->cpath_link);
 	free(path);
 }
@@ -406,5 +402,4 @@
 	usb_hid_report_path_t *usage_path)
 {
-	link_t *path_link;
 	usb_hid_report_usage_path_t *path_item;
 	usb_hid_report_usage_path_t *new_path_item;
@@ -417,12 +412,11 @@
 	new_usage_path->report_id = usage_path->report_id;
 	
-	if(list_empty(&usage_path->head)){
+	if(list_empty(&usage_path->items)){
 		return new_usage_path;
 	}
 
-	path_link = usage_path->head.next;
-	while(path_link != &usage_path->head) {
-		path_item = list_get_instance(path_link, 
-			usb_hid_report_usage_path_t, link);
+	list_foreach(usage_path->items, path_link) {
+		path_item = list_get_instance(path_link,
+			usb_hid_report_usage_path_t, rpath_items_link);
 
 		new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
@@ -431,13 +425,12 @@
 		}
 		
-		list_initialize (&new_path_item->link);		
+		link_initialize(&new_path_item->rpath_items_link);
 		new_path_item->usage_page = path_item->usage_page;
 		new_path_item->usage = path_item->usage;		
 		new_path_item->flags = path_item->flags;		
 		
-		list_append(&new_path_item->link, &new_usage_path->head);
+		list_append(&new_path_item->rpath_items_link,
+		    &new_usage_path->items);
 		new_usage_path->depth++;
-
-		path_link = path_link->next;
 	}
 
