Index: uspace/drv/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.c	(revision faa44e5822a62f097605f7e1a86f8019bcb3872e)
+++ uspace/drv/usbhid/kbd/kbddev.c	(revision 4fe3b6d8a9632b4191c8e88471849f92bd765912)
@@ -252,7 +252,6 @@
 	sysarg_t method = IPC_GET_IMETHOD(*icall);
 	
-	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
-	
-	if (hid_dev == NULL || hid_dev->data == NULL) {
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
+	if (kbd_dev == NULL) {
 		usb_log_debug("default_connection_handler: "
 		    "Missing parameter.\n");
@@ -260,8 +259,4 @@
 		return;
 	}
-	
-	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
 
 	if (method == IPC_M_CONNECT_TO_ME) {
@@ -313,9 +308,9 @@
 	usb_hid_report_field_t *field = usb_hid_report_get_sibling(
 	    hid_dev->report, NULL, kbd_dev->led_path, 
-	    USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY | USB_HID_PATH_COMPARE_END,
+	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
 	    USB_HID_REPORT_TYPE_OUTPUT);
 	
-	while (field != NULL) {
-
+	while (field != NULL) {		
+		
 		if ((field->usage == USB_HID_LED_NUM_LOCK) 
 		    && (kbd_dev->mods & KM_NUM_LOCK)){
@@ -334,6 +329,7 @@
 		
 		field = usb_hid_report_get_sibling(hid_dev->report, field,
-		    kbd_dev->led_path, USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 
-		    | USB_HID_PATH_COMPARE_END, USB_HID_REPORT_TYPE_OUTPUT);
+		    kbd_dev->led_path,  
+	    	USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
+			USB_HID_REPORT_TYPE_OUTPUT);
 	}
 	
@@ -662,12 +658,10 @@
  *     usb_hid_parse_report().
  */
-static void usb_kbd_process_data(usb_hid_dev_t *hid_dev,
+static void usb_kbd_process_data(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev,
                                  uint8_t *buffer, size_t actual_size)
 {
 	assert(hid_dev->report != NULL);
 	assert(hid_dev != NULL);
-	assert(hid_dev->data != NULL);
-	
-	usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
+	assert(kbd_dev != NULL);
 
 	usb_log_debug("Calling usb_hid_parse_report() with "
@@ -774,8 +768,9 @@
 /*----------------------------------------------------------------------------*/
 
-static int usb_kbd_create_function(usb_hid_dev_t *hid_dev)
+static int usb_kbd_create_function(usb_hid_dev_t *hid_dev, usb_kbd_t *kbd_dev)
 {
 	assert(hid_dev != NULL);
 	assert(hid_dev->usb_dev != NULL);
+	assert(kbd_dev != NULL);
 	
 	/* Create the function exposed under /dev/devices. */
@@ -792,6 +787,6 @@
 	 * to the DDF function.
 	 */
-	fun->ops = &hid_dev->ops;
-	fun->driver_data = hid_dev;   // TODO: maybe change to hid_dev->data
+	fun->ops = &kbd_dev->ops;
+	fun->driver_data = kbd_dev;
 
 	int rc = ddf_fun_bind(fun);
@@ -840,5 +835,5 @@
  * @return Other value inherited from function usbhid_dev_init().
  */
-int usb_kbd_init(usb_hid_dev_t *hid_dev)
+int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
 {
 	usb_log_debug("Initializing HID/KBD structure...\n");
@@ -865,7 +860,6 @@
 	usb_hid_report_path_set_report_id(path, 0);
 	
-	kbd_dev->key_count = usb_hid_report_input_length(
-	    hid_dev->report, path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
+	kbd_dev->key_count = usb_hid_report_size(
+	    hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 
 	usb_hid_report_path_free(path);
 	
@@ -908,7 +902,6 @@
 	    kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
 	
-	kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report, 
-	    kbd_dev->led_path, 
-	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);
+	kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report, 
+	    0, USB_HID_REPORT_TYPE_OUTPUT);
 	
 	usb_log_debug("Output report size (in items): %zu\n", 
@@ -955,8 +948,9 @@
 	
 	// save the KBD device structure into the HID device structure
-	hid_dev->data = kbd_dev;
+	//hid_dev->data = kbd_dev;
+	*data = kbd_dev;
 	
 	// set handler for incoming calls
-	hid_dev->ops.default_handler = default_connection_handler;
+	kbd_dev->ops.default_handler = default_connection_handler;
 	
 	/*
@@ -983,5 +977,5 @@
 	
 	usb_log_debug("Creating KBD function...\n");
-	int rc = usb_kbd_create_function(hid_dev);
+	int rc = usb_kbd_create_function(hid_dev, kbd_dev);
 	if (rc != EOK) {
 		usb_kbd_free(&kbd_dev);
@@ -994,14 +988,17 @@
 /*----------------------------------------------------------------------------*/
 
-bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, uint8_t *buffer,
-     size_t buffer_size)
-{
-	if (hid_dev == NULL || buffer == NULL) {
+bool usb_kbd_polling_callback(usb_hid_dev_t *hid_dev, void *data, 
+     uint8_t *buffer, size_t buffer_size)
+{
+	if (hid_dev == NULL || buffer == NULL || data == NULL) {
 		// do not continue polling (???)
 		return false;
 	}
 	
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
+	assert(kbd_dev != NULL);
+	
 	// TODO: add return value from this function
-	usb_kbd_process_data(hid_dev, buffer, buffer_size);
+	usb_kbd_process_data(hid_dev, kbd_dev, buffer, buffer_size);
 	
 	return true;
@@ -1066,5 +1063,5 @@
 /*----------------------------------------------------------------------------*/
 
-void usb_kbd_deinit(usb_hid_dev_t *hid_dev)
+void usb_kbd_deinit(usb_hid_dev_t *hid_dev, void *data)
 {
 	if (hid_dev == NULL) {
@@ -1072,11 +1069,10 @@
 	}
 	
-	if (hid_dev->data != NULL) {
-		usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data;
+	if (data != NULL) {
+		usb_kbd_t *kbd_dev = (usb_kbd_t *)data;
 		if (usb_kbd_is_initialized(kbd_dev)) {
 			usb_kbd_mark_unusable(kbd_dev);
 		} else {
 			usb_kbd_free(&kbd_dev);
-			hid_dev->data = NULL;
 		}
 	}
