Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision 17d15426edd0cb31ae06c5d1aa73c489515743e9)
+++ uspace/app/mkbd/main.c	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -71,5 +71,5 @@
 		usb_hid_free_report(*report);
 		*report = NULL;
-		printf("usb_hid_report_init() failed.\n");
+		//printf("usb_hid_report_init() failed.\n");
 		return rc;
 	}
@@ -82,5 +82,5 @@
 		usb_hid_free_report(*report);
 		*report = NULL;
-		printf("usbhid_dev_get_report_descriptor_length() failed.\n");
+		//printf("usbhid_dev_get_report_descriptor_length() failed.\n");
 		return rc;
 	}
@@ -89,5 +89,5 @@
 		usb_hid_free_report(*report);
 		*report = NULL;
-		printf("usbhid_dev_get_report_descriptor_length() returned 0.\n");
+		//printf("usbhid_dev_get_report_descriptor_length() returned 0.\n");
 		return EINVAL;	// TODO: other error code?
 	}
@@ -108,5 +108,5 @@
 		*report = NULL;
 		free(desc);
-		printf("usbhid_dev_get_report_descriptor() failed.\n");
+		//printf("usbhid_dev_get_report_descriptor() failed.\n");
 		return rc;
 	}
@@ -116,6 +116,6 @@
 		*report = NULL;
 		free(desc);
-		printf("usbhid_dev_get_report_descriptor() returned wrong size:"
-		    " %zu, expected: %zu.\n", actual_size, report_desc_size);
+//		printf("usbhid_dev_get_report_descriptor() returned wrong size:"
+//		    " %zu, expected: %zu.\n", actual_size, report_desc_size);
 		return EINVAL;	// TODO: other error code?
 	}
@@ -128,5 +128,5 @@
 	if (rc != EOK) {
 		free(desc);
-		printf("usb_hid_parse_report_descriptor() failed.\n");
+//		printf("usb_hid_parse_report_descriptor() failed.\n");
 		return rc;
 	}
@@ -213,12 +213,10 @@
 	
 	char *devpath = argv[1];
-	//const char *devpath = "/hw/pci0/00:06.0/ohci-rh/usb00_a2/HID1/hid";
-	
-	int rc;
 	
 	devman_handle_t dev_handle = 0;
-	rc = devman_device_get_handle(devpath, &dev_handle, 0);
-	if (rc != EOK) {
-		printf("Failed to get handle from devman: %s.\n",
+	
+	int rc = usb_resolve_device_handle(devpath, NULL, NULL, &dev_handle);
+	if (rc != EOK) {
+		printf("Device not found or not of USB kind: %s.\n",
 		    str_error(rc));
 		return rc;
Index: uspace/doc/main_usb.h
===================================================================
--- uspace/doc/main_usb.h	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
+++ uspace/doc/main_usb.h	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -0,0 +1,26 @@
+/**
+ @mainpage USB support for HelenOS
+
+This is reference manual for USB subsystem for HelenOS.
+
+HelenOS is a microkernel operating system where most of the functionality
+is provided by userspace tasks rather than system calls.
+This includes file system service, networking and also device drivers.
+
+USB is a standard for communication between host computers and computer
+peripherals.
+The advantage of USB over other kinds of connection between a computer
+and a peripheral is its flexibility.
+USB supports plugging and unplugging of devices without need to turn
+off any of the components.
+The data flow model is designed to accommodate together peripherals
+with different transfer characteristics.
+
+Adding support for USB devices to HelenOS shall improve the usability
+of the system in general even if the support concerns only USB 1.1 and
+the only peripheral drivers are for keyboards and mice.
+
+This reference documentation can be found also on-line at homepage
+of HelenOS USB project at http://helenos-usb.sourceforge.net/
+
+*/
Index: uspace/drv/usbhid/usbhid.c
===================================================================
--- uspace/drv/usbhid/usbhid.c	(revision 17d15426edd0cb31ae06c5d1aa73c489515743e9)
+++ uspace/drv/usbhid/usbhid.c	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -78,18 +78,21 @@
 	}
 	
+	assert(hid_dev->subdriver_count >= 0);
+	
 	// set the init callback
-	hid_dev->subdrivers[0].init = usb_kbd_init;
+	hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_kbd_init;
 	
 	// set the polling callback
-	hid_dev->subdrivers[0].poll = usb_kbd_polling_callback;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll = 
+	    usb_kbd_polling_callback;
 	
 	// set the polling ended callback
-	hid_dev->subdrivers[0].poll_end = NULL;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
 	
 	// set the deinit callback
-	hid_dev->subdrivers[0].deinit = usb_kbd_deinit;
+	hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_kbd_deinit;
 	
 	// set subdriver count
-	hid_dev->subdriver_count = 1;
+	++hid_dev->subdriver_count;
 	
 	return EOK;
@@ -108,18 +111,21 @@
 	}
 	
+	assert(hid_dev->subdriver_count >= 0);
+	
 	// set the init callback
-	hid_dev->subdrivers[0].init = usb_mouse_init;
+	hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_mouse_init;
 	
 	// set the polling callback
-	hid_dev->subdrivers[0].poll = usb_mouse_polling_callback;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll = 
+	    usb_mouse_polling_callback;
 	
 	// set the polling ended callback
-	hid_dev->subdrivers[0].poll_end = NULL;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
 	
 	// set the deinit callback
-	hid_dev->subdrivers[0].deinit = usb_mouse_deinit;
+	hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_mouse_deinit;
 	
 	// set subdriver count
-	hid_dev->subdriver_count = 1;
+	++hid_dev->subdriver_count;
 	
 	return EOK;
@@ -138,18 +144,22 @@
 	}
 	
+	assert(hid_dev->subdriver_count >= 0);
+	
 	// set the init callback
-	hid_dev->subdrivers[0].init = usb_generic_hid_init;
+	hid_dev->subdrivers[hid_dev->subdriver_count].init =
+	    usb_generic_hid_init;
 	
 	// set the polling callback
-	hid_dev->subdrivers[0].poll = usb_generic_hid_polling_callback;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll = 
+	    usb_generic_hid_polling_callback;
 	
 	// set the polling ended callback
-	hid_dev->subdrivers[0].poll_end = NULL;
+	hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
 	
 	// set the deinit callback
-	hid_dev->subdrivers[0].deinit = NULL;
+	hid_dev->subdrivers[hid_dev->subdriver_count].deinit = NULL;
 	
 	// set subdriver count
-	hid_dev->subdriver_count = 1;
+	++hid_dev->subdriver_count;
 	
 	return EOK;
@@ -196,8 +206,8 @@
 	}
 	
-	if (mapping->report_id >= 0) {
-		usb_hid_report_path_set_report_id(usage_path, 
-		    mapping->report_id);
-	}
+//	if (mapping->report_id >= 0) {
+//		usb_hid_report_path_set_report_id(usage_path, 
+//		    mapping->report_id);
+//	}
 	
 	assert(hid_dev->report != NULL);
@@ -206,18 +216,69 @@
 //	size_t size = usb_hid_report_size(hid_dev->report, 0, 
 //	    USB_HID_REPORT_TYPE_INPUT);
-	size_t size = 0;
-	usb_hid_report_field_t *field = usb_hid_report_get_sibling (hid_dev->report,
-		NULL, usage_path, mapping->compare, USB_HID_REPORT_TYPE_INPUT);
-	while(field != NULL) {
-		size++;
-		field = usb_hid_report_get_sibling (hid_dev->report,
-					field, usage_path, mapping->compare, 
-		            USB_HID_REPORT_TYPE_INPUT);
-	}
-	
-	usb_log_debug("Size of the input report: %zuB\n", size);
+//	size_t size = 0;
+	
+	bool matches = false;
+
+//	usb_hid_report_description_t *report_des = 
+//		usb_hid_report_find_description(hid_dev->report,
+//		mapping->report_id, USB_HID_REPORT_TYPE_INPUT);
+	uint8_t report_id = mapping->report_id;
+
+	/*while(report_des != NULL)*/do {
+
+//		if((mapping->report_id) == 0 && (report_des->report_id != 0)) {
+//			usb_hid_report_path_set_report_id(usage_path,
+//				report_des->report_id);
+//		}
+					     
+		usb_log_debug("Trying report id %u\n", report_id);
+		
+		if (report_id != 0) {
+			usb_hid_report_path_set_report_id(usage_path,
+				report_id);
+		}
+
+		usb_hid_report_field_t *field = usb_hid_report_get_sibling(
+		    hid_dev->report,
+		    NULL, usage_path, mapping->compare, 
+		    USB_HID_REPORT_TYPE_INPUT);
+		
+		usb_log_debug("Field: %p\n", field);
+
+		if (field != NULL) {
+//			size++;
+//			field = usb_hid_report_get_sibling(hid_dev->report,
+//			    field, usage_path, mapping->compare, 
+//			    USB_HID_REPORT_TYPE_INPUT);
+			matches = true;
+			break;
+		}
+		
+		report_id = usb_hid_get_next_report_id(
+		    hid_dev->report, report_id,
+		    USB_HID_REPORT_TYPE_INPUT);
+
+//		if((mapping->report_id == 0) && (report_des->report_id != 0)) {
+//			uint8_t report_id = usb_hid_get_next_report_id(
+//				hid_dev->report, report_des->report_id,
+//			        USB_HID_REPORT_TYPE_INPUT);
+
+//			if(report_id == 0) {
+//				break;
+//			}
+
+//	 		report_des = usb_hid_report_find_description(
+//				hid_dev->report, report_id, 
+//				USB_HID_REPORT_TYPE_INPUT);
+//		}
+//		else {
+//			break;
+//		}
+	} while (!matches && report_id != 0);
+	
+//	usb_log_debug("Size of the input report: %zu\n", size);
 	usb_hid_report_path_free(usage_path);
 	
-	return (size > 0);
+	return matches;
 }
 
@@ -368,8 +429,10 @@
 	
 	do {
+		usb_log_debug("Getting size of the report.\n");
 		size = usb_hid_report_byte_size(hid_dev->report, report_id, 
 		    USB_HID_REPORT_TYPE_INPUT);
 		usb_log_debug("Report ID: %u, size: %zu\n", report_id, size);
 		max_size = (size > max_size) ? size : max_size;
+		usb_log_debug("Getting next report ID\n");
 		report_id = usb_hid_get_next_report_id(hid_dev->report, 
 		    report_id, USB_HID_REPORT_TYPE_INPUT);
@@ -501,4 +564,5 @@
 		    hid_dev->subdriver_count);
 		//usb_hid_free(&hid_dev);
+		
 	} else {
 		bool ok = false;
@@ -527,9 +591,14 @@
 	}
 	
-	// save max input report size and allocate space for the report
-	rc = usb_hid_init_report(hid_dev);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize input report buffer.\n");
-	}
+	
+	if (rc == EOK) {
+		// save max input report size and allocate space for the report
+		rc = usb_hid_init_report(hid_dev);
+		if (rc != EOK) {
+			usb_log_error("Failed to initialize input report buffer"
+			    ".\n");
+		}
+	}
+	
 	
 	return rc;
@@ -554,31 +623,11 @@
 	usb_log_debug("Max input report size: %zu, buffer size: %zu\n",
 	    hid_dev->max_input_report_size, buffer_size);
-	assert(hid_dev->max_input_report_size >= buffer_size);
-	
-//	if (/*!allocated*/
-//	    /*|| *//*hid_dev->input_report_size < buffer_size*/) {
-//		uint8_t *input_old = hid_dev->input_report;
-//		uint8_t *input_new = (uint8_t *)malloc(buffer_size);
-		
-//		if (input_new == NULL) {
-//			usb_log_error("Failed to allocate space for input "
-//			    "buffer. This event may not be reported\n");
-//			memset(hid_dev->input_report, 0, 
-//			    hid_dev->input_report_size);
-//		} else {
-//			memcpy(input_new, input_old, 
-//			    hid_dev->input_report_size);
-//			hid_dev->input_report = input_new;
-//			if (allocated) {
-//				free(input_old);
-//			}
-//			usb_hid_new_report();
-//		}
-//	}
-	
-	/*! @todo This should probably be atomic. */
-	memcpy(hid_dev->input_report, buffer, buffer_size);
-	hid_dev->input_report_size = buffer_size;
-	usb_hid_new_report(hid_dev);
+	//assert(hid_dev->max_input_report_size >= buffer_size);
+	if (hid_dev->max_input_report_size >= buffer_size) {
+		/*! @todo This should probably be atomic. */
+		memcpy(hid_dev->input_report, buffer, buffer_size);
+		hid_dev->input_report_size = buffer_size;
+		usb_hid_new_report(hid_dev);
+	}
 	
 	bool cont = false;
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision 17d15426edd0cb31ae06c5d1aa73c489515743e9)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -329,4 +329,8 @@
 		usb_hid_report_type_t type) {
 
+	if(report == NULL) {
+		return NULL;
+	}
+
 	link_t *report_it = report->reports.next;
 	usb_hid_report_description_t *report_des = NULL;
@@ -336,5 +340,6 @@
 				usb_hid_report_description_t, link);
 
-		if((report_des->report_id == report_id) && 
+		// if report id not set, return the first of the type
+		if(((report_des->report_id == report_id) || (report_id == 0)) && 
 		   (report_des->type == type)) { 
 			return report_des;
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision 17d15426edd0cb31ae06c5d1aa73c489515743e9)
+++ uspace/lib/usbhid/src/hidparser.c	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -605,6 +605,12 @@
 	
 	if(report_id > 0) {
-		report_it = usb_hid_report_find_description(report, report_id, 
-			type)->link.next;		
+		report_des = usb_hid_report_find_description(report, report_id, 
+			type);
+		if(report_des == NULL) {
+			return 0;
+		}
+		else {
+			report_it = report_des->link.next;
+		}	
 	}
 	else {
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision 17d15426edd0cb31ae06c5d1aa73c489515743e9)
+++ uspace/lib/usbhid/src/hidpath.c	(revision 3ae26a871b6387993c7a7a3a0ad6c7856b2f45e6)
@@ -211,5 +211,7 @@
 
 	if(report_path->report_id != path->report_id) {
-		return 1;
+		if(path->report_id != 0) {
+			return 1;
+		}
 	}
 
