Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision 1889786ac51344d84ebf4538a72c2fe2038adf17)
+++ uspace/lib/usbhid/src/hidparser.c	(revision 14e7959c5e98d9217bebc9f3b2e14b76213fe913)
@@ -31,5 +31,5 @@
  */
 /** @file
- * HID report descriptor and report data parser implementation.
+ * USB HID report data parser implementation.
  */
 #include <usb/hid/hidparser.h>
@@ -41,14 +41,18 @@
 #include <assert.h>
 
-
+/*---------------------------------------------------------------------------*/
 /*
  * Data translation private functions
  */
 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
-//inline size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset);
+
 int usb_hid_translate_data(usb_hid_report_field_t *item, const uint8_t *data);
-uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, int32_t value);
+
+uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 
+	int32_t value);
+
 int usb_pow(int a, int b);
 
+/*---------------------------------------------------------------------------*/
 
 // TODO: tohle ma bejt asi jinde
@@ -56,16 +60,16 @@
 {
 	switch(b) {
-		case 0:
-			return 1;
-			break;
-		case 1:
-			return a;
-			break;
-		default:
-			return a * usb_pow(a, b-1);
-			break;
-	}
-}
-
+	case 0:
+		return 1;
+		break;
+	case 1:
+		return a;
+		break;
+	default:
+		return a * usb_pow(a, b-1);
+		break;
+	}
+}
+/*---------------------------------------------------------------------------*/
 
 /** Returns size of report of specified report id and type in items
@@ -93,5 +97,5 @@
 	}
 }
-
+/*---------------------------------------------------------------------------*/
 
 /** Parse and act upon a HID report.
@@ -103,6 +107,6 @@
  * @return Error code.
  */ 
-int usb_hid_parse_report(const usb_hid_report_t *report,  
-    const uint8_t *data, size_t size, uint8_t *report_id)
+int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 
+	size_t size, uint8_t *report_id)
 {
 	link_t *list_item;
@@ -139,13 +143,13 @@
 				item->value = usb_hid_translate_data(item, data);
 		
-				item->usage = USB_HID_EXTENDED_USAGE(item->usages[item->value - item->physical_minimum]);
-				item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]);				
+				item->usage = USB_HID_EXTENDED_USAGE(
+					item->usages[item->value - item->physical_minimum]);
+				item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(
+					item->usages[item->value - item->physical_minimum]);				
 
 				usb_hid_report_set_last_item (item->collection_path, 
-				                              USB_HID_TAG_CLASS_GLOBAL,
-				                              item->usage_page);
+					USB_HID_TAG_CLASS_GLOBAL, item->usage_page);
 				usb_hid_report_set_last_item (item->collection_path, 
-				                              USB_HID_TAG_CLASS_LOCAL,
-				                              item->usage);
+				    USB_HID_TAG_CLASS_LOCAL, item->usage);
 				
 			}
@@ -162,4 +166,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Translate data from the report as specified in report descriptor item
@@ -167,5 +172,4 @@
  * @param item Report descriptor item with definition of translation
  * @param data Data to translate
- * @param j Index of processed field in report descriptor item
  * @return Translated data
  */
@@ -240,5 +244,6 @@
 }
 
-/*** OUTPUT API **/
+/*---------------------------------------------------------------------------*/
+/* OUTPUT API */
 
 /** 
@@ -250,5 +255,6 @@
  * @return Returns allocated output buffer for specified output
  */
-uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id)
+uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 
+	uint8_t report_id)
 {
 	if(report == NULL) {
@@ -260,6 +266,9 @@
 	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);
-		if((report_des->report_id == report_id) && (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)){
+		report_des = list_get_instance(report_it, 
+			usb_hid_report_description_t, link);
+		
+		if((report_des->report_id == report_id) && 
+			(report_des->type == USB_HID_REPORT_TYPE_OUTPUT)){
 			break;
 		}
@@ -303,6 +312,6 @@
  * @return Error code
  */
-int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id,
-                                    uint8_t *buffer, size_t size)
+int usb_hid_report_output_translate(usb_hid_report_t *report, 
+	uint8_t report_id, uint8_t *buffer, size_t size)
 {
 	link_t *item;	
@@ -320,8 +329,8 @@
 	}
 
-	usb_log_debug("OUTPUT BUFFER: %s\n", usb_debug_str_buffer(buffer,size, 0));
-	
 	usb_hid_report_description_t *report_des;
-	report_des = usb_hid_report_find_description (report, report_id, USB_HID_REPORT_TYPE_OUTPUT);
+	report_des = usb_hid_report_find_description (report, report_id, 
+		USB_HID_REPORT_TYPE_OUTPUT);
+	
 	if(report_des == NULL){
 		return EINVAL;
@@ -333,10 +342,10 @@
 		report_item = list_get_instance(item, usb_hid_report_field_t, link);
 
-		usb_log_debug("OUTPUT ITEM usage(%x), value(%x)\n", report_item->usage, report_item->value);
-		
 		if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) {
 					
 			// array
-			value = usb_hid_translate_data_reverse(report_item, report_item->value);
+			value = usb_hid_translate_data_reverse(report_item, 
+				report_item->value);
+
 			offset = report_item->offset;
 			length = report_item->size;
@@ -344,5 +353,7 @@
 		else {
 			// variable item
-			value  = usb_hid_translate_data_reverse(report_item, report_item->value);
+			value  = usb_hid_translate_data_reverse(report_item, 
+				report_item->value);
+
 			offset = report_item->offset;
 			length = report_item->size;
@@ -353,5 +364,6 @@
 		if((offset/8) == ((offset+length-1)/8)) {
 			// je to v jednom bytu
-			if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) {
+			if(((size_t)(offset/8) >= size) || 
+				((size_t)(offset+length-1)/8) >= size) {
 				break; // TODO ErrorCode
 			}
@@ -379,5 +391,6 @@
 					
 					value = value >> (length - ((offset + length) % 8));
-					value = value & ((1 << (length - ((offset + length) % 8))) - 1);
+					value = value & 
+						((1 << (length - ((offset + length) % 8))) - 1);
 				
 					mask = (1 << (length - ((offset + length) % 8))) - 1;
@@ -396,9 +409,8 @@
 	}
 	
-	usb_log_debug("OUTPUT BUFFER: %s\n", usb_debug_str_buffer(buffer,size, 0));
-
 	return EOK;
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Translate given data for putting them into the outoput report
@@ -407,5 +419,6 @@
  * @return ranslated value
  */
-uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, int value)
+uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 
+	int value)
 {
 	int ret=0;
@@ -431,6 +444,10 @@
 	}
 
-	ret = ((value - item->physical_minimum) * resolution) + item->logical_minimum;
-	usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), ret(%x)\n", value, resolution, item->physical_minimum, item->logical_minimum, ret);
+	ret = ((value - item->physical_minimum) * resolution) + 
+		item->logical_minimum;
+
+	usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), \
+		ret(%x)\n", value, resolution, item->physical_minimum, 
+		item->logical_minimum, ret);
 	
 	if((item->logical_minimum < 0) || (item->logical_maximum < 0)){
@@ -440,5 +457,13 @@
 }
 
-usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item)
+/*---------------------------------------------------------------------------*/
+/**
+ * Clones given state table
+ *
+ * @param item State table to clone
+ * @return Pointer to the cloned item
+ */
+usb_hid_report_item_t *usb_hid_report_item_clone(
+	const usb_hid_report_item_t *item)
 {
 	usb_hid_report_item_t *new_report_item;
@@ -453,11 +478,25 @@
 }
 
-
+/*---------------------------------------------------------------------------*/
+/**
+ * Function for sequence walking through the report. Returns next field in the
+ * report or the first one when no field is given.
+ *
+ * @param report Searched report structure
+ * @param field Current field. If NULL is given, the first one in the report
+ * is returned. Otherwise the next one i nthe list is returned.
+ * @param path Usage path specifying which fields wa are interested in. 
+ * @param flags Flags defining mode of usage paths comparison
+ * @param type Type of report we search.
+ * @retval NULL if no field is founded
+ * @retval Pointer to the founded report structure when founded
+ */
 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 
-							usb_hid_report_field_t *field, 
-                            usb_hid_report_path_t *path, int flags, 
-                            usb_hid_report_type_t type)
-{
-	usb_hid_report_description_t *report_des = usb_hid_report_find_description (report, path->report_id, type);
+	usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, 
+	usb_hid_report_type_t type)
+{
+	usb_hid_report_description_t *report_des = usb_hid_report_find_description(
+		report, path->report_id, type);
+
 	link_t *field_it;
 	
@@ -467,5 +506,4 @@
 
 	if(field == NULL){
-		// vezmu prvni co mathuje podle path!!
 		field_it = report_des->report_items.next;
 	}
@@ -478,7 +516,11 @@
 
 		if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
-			usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
-			if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK){
-				usb_hid_report_remove_last_item (field->collection_path);
+			usb_hid_report_path_append_item (field->collection_path, 
+				field->usage_page, field->usage);
+
+			if(usb_hid_report_compare_usage_path(field->collection_path, path, 
+				flags) == EOK){
+
+				usb_hid_report_remove_last_item(field->collection_path);
 				return field;
 			}
@@ -491,5 +533,17 @@
 }
 
-uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type)
+/*---------------------------------------------------------------------------*/
+/**
+ * Returns nonzero (report_id) number if there is report of given type and
+ * have the specified report_id in report structure
+ *
+ * @param report_id Searched report id
+ * @param type Type of searched report
+ * @param report Report structure inwhich we search
+ * @retval 0 if report structure is null or there is no specified report
+ * @retval report_id otherwise
+ */
+uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, 
+	uint8_t report_id, usb_hid_report_type_t type)
 {
 	if(report == NULL){
@@ -501,5 +555,6 @@
 	
 	if(report_id == 0) {
-		report_it = usb_hid_report_find_description (report, report_id, type)->link.next;		
+		report_it = usb_hid_report_find_description(report, report_id, 
+			type)->link.next;		
 	}
 	else {
@@ -508,5 +563,7 @@
 
 	while(report_it != &report->reports) {
-		report_des = list_get_instance(report_it, usb_hid_report_description_t, link);
+		report_des = list_get_instance(report_it, usb_hid_report_description_t,
+			link);
+
 		if(report_des->type == type){
 			return report_des->report_id;
@@ -517,4 +574,13 @@
 }
 
+/*---------------------------------------------------------------------------*/
+/**
+ * Reset all local items in given state table
+ *
+ * @param report_item State table containing current state of report
+ * descriptor parsing
+ *
+ * @return void
+ */
 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item)
 {
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision 1889786ac51344d84ebf4538a72c2fe2038adf17)
+++ uspace/lib/usbhid/src/hidpath.c	(revision 14e7959c5e98d9217bebc9f3b2e14b76213fe913)
@@ -41,8 +41,27 @@
 #include <assert.h>
 
-
-#define USB_HID_SAME_USAGE(usage1, usage2)	((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
-#define USB_HID_SAME_USAGE_PAGE(page1, page2)	((page1 == page2) || (page1 == 0) || (page2 == 0))
-
+/*---------------------------------------------------------------------------*/
+/**
+ * Compares two usages if they are same or not or one of the usages is not
+ * set.
+ *
+ * @param usage1
+ * @param usage2
+ * @return boolean
+ */
+#define USB_HID_SAME_USAGE(usage1, usage2)		\
+	((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
+
+/**
+ * Compares two usage pages if they are same or not or one of them is not set.
+ *
+ * @param page1
+ * @param page2
+ * @return boolean
+ */
+#define USB_HID_SAME_USAGE_PAGE(page1, page2)	\
+	((page1 == page2) || (page1 == 0) || (page2 == 0))
+
+/*---------------------------------------------------------------------------*/
 /**
  * Appends one item (couple of usage_path and usage) into the usage path
@@ -73,4 +92,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Removes last item from the usage path structure
@@ -91,4 +111,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Nulls last item of the usage path structure.
@@ -102,9 +123,12 @@
 	
 	if(!list_empty(&usage_path->head)){	
-		item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
+		item = list_get_instance(usage_path->head.prev, 
+			usb_hid_report_usage_path_t, link);
+
 		memset(item, 0, sizeof(usb_hid_report_usage_path_t));
 	}
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Modifies last item of usage path structure by given usage page or usage
@@ -137,5 +161,11 @@
 }
 
-
+/*---------------------------------------------------------------------------*/
+/**
+ *
+ *
+ *
+ *
+ */
 void usb_hid_print_usage_path(usb_hid_report_path_t *path)
 {
@@ -147,13 +177,16 @@
 	while(item != &path->head) {
 
-		path_item = list_get_instance(item, usb_hid_report_usage_path_t, link);
+		path_item = list_get_instance(item, usb_hid_report_usage_path_t, 
+			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;
-	}
-}
-
+       	item = item->next;
+	}
+}
+
+/*---------------------------------------------------------------------------*/
 /**
  * Compares two usage paths structures
@@ -198,15 +231,20 @@
 			}
 
-			// projit skrz cestu a kdyz nekde sedi tak vratim EOK
-			// dojduli az za konec tak nnesedi
 			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);
+			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);
-				if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page)){
+				report_item = list_get_instance(report_link, 
+					usb_hid_report_usage_path_t, link);
+				
+				if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+					path_item->usage_page)){
+					
 					if(only_page == 0){
-						if(USB_HID_SAME_USAGE(report_item->usage, path_item->usage)) {
+						if(USB_HID_SAME_USAGE(report_item->usage, 
+							path_item->usage)) {
+							
 							return EOK;
 						}
@@ -238,14 +276,13 @@
 						  
 					report_item = list_get_instance(report_link, 
-					                                usb_hid_report_usage_path_t, 
-					                                link);
+                    	usb_hid_report_usage_path_t, link);
 						  
 					path_item = list_get_instance(path_link, 
-					                              usb_hid_report_usage_path_t, 
-					                              link);		
-
-					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) || 
-					   ((only_page == 0) && 
-					    !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
+                    	usb_hid_report_usage_path_t, link);		
+
+					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+						path_item->usage_page) || ((only_page == 0) && 
+					    !USB_HID_SAME_USAGE(report_item->usage, 
+						path_item->usage))) {
 							
 						   return 1;
@@ -257,6 +294,9 @@
 				}
 
-				if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && (path_link == &path->head)) || 
-				   ((report_link == &report_path->head) && (path_link == &path->head))) {
+				if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 
+					(path_link == &path->head)) || 
+				   ((report_link == &report_path->head) && 
+					(path_link == &path->head))) {
+					
 					return EOK;
 				}
@@ -280,13 +320,14 @@
 						  
 					report_item = list_get_instance(report_link, 
-					                                usb_hid_report_usage_path_t, 
-					                                link);
+						usb_hid_report_usage_path_t, link);
+
 					path_item = list_get_instance(path_link, 
-					                              usb_hid_report_usage_path_t, 
-					                              link);		
+						usb_hid_report_usage_path_t, link);		
 						  
-					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) || 
-					   ((only_page == 0) && 
-					    !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
+					if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 
+						path_item->usage_page) || ((only_page == 0) && 
+					    !USB_HID_SAME_USAGE(report_item->usage, 
+						path_item->usage))) {
+						
 							return 1;
 					} else {
@@ -311,4 +352,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Allocates and initializes new usage path structure.
@@ -332,4 +374,5 @@
 }
 
+/*---------------------------------------------------------------------------*/
 /**
  * Releases given usage path structure.
@@ -348,5 +391,5 @@
 }
 
-
+/*---------------------------------------------------------------------------*/
 /**
  * Clone content of given usage path to the new one
@@ -355,5 +398,6 @@
  * @return New copy of given usage path structure
  */
-usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path)
+usb_hid_report_path_t *usb_hid_report_path_clone(
+	usb_hid_report_path_t *usage_path)
 {
 	link_t *path_link;
@@ -374,5 +418,5 @@
 	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, 
+		path_item = list_get_instance(path_link, usb_hid_report_usage_path_t,
 		                              link);
 		new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
@@ -395,5 +439,5 @@
 }
 
-
+/*---------------------------------------------------------------------------*/
 /**
  * Sets report id in usage path structure
@@ -403,5 +447,6 @@
  * @return Error code
  */
-int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id)
+int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 
+	uint8_t report_id)
 {
 	if(path == NULL){
