Index: uspace/drv/usbhid/usbhid.c
===================================================================
--- uspace/drv/usbhid/usbhid.c	(revision dcb7d7cd6753bc17b6e14b5b93793cb4b97abc4d)
+++ uspace/drv/usbhid/usbhid.c	(revision b9e3aa3fe40f91fd4973778e5692861a1f04b7f9)
@@ -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;
@@ -249,5 +259,5 @@
 	}
 	
-	usb_log_debug("Size of the input report: %zuB\n", size);
+	usb_log_debug("Size of the input report: %zu\n", size);
 	usb_hid_report_path_free(usage_path);
 	
@@ -401,8 +411,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);
@@ -534,4 +546,5 @@
 		    hid_dev->subdriver_count);
 		//usb_hid_free(&hid_dev);
+		
 	} else {
 		bool ok = false;
@@ -560,9 +573,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;
@@ -587,31 +605,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;
