Index: uspace/drv/usbkbd/conv.h
===================================================================
--- uspace/drv/usbkbd/conv.h	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/conv.h	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -34,10 +34,10 @@
  */
 
-#ifndef USBHID_CONV_H_
-#define USBHID_CONV_H_
+#ifndef USB_KBD_CONV_H_
+#define USB_KBD_CONV_H_
 
 unsigned int usbhid_parse_scancode(int scancode);
 
-#endif /* USBHID_CONV_H_ */
+#endif /* USB_KBD_CONV_H_ */
 
 /**
Index: uspace/drv/usbkbd/hiddev.c
===================================================================
--- uspace/drv/usbkbd/hiddev.c	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ 	(revision )
@@ -1,463 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbhid
- * @{
- */
-/**
- * @file
- * Generic USB HID device structure and API.
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <ddf/driver.h>
-
-#include <usb/dp.h>
-#include <usb/debug.h>
-#include <usb/request.h>
-#include <usb/descriptor.h>
-#include <usb/classes/hid.h>
-#include <usb/pipes.h>
-
-#include "hiddev.h"
-
-/*----------------------------------------------------------------------------*/
-/* Non-API functions                                                          */
-/*----------------------------------------------------------------------------*/
-/**
- * Retreives HID Report descriptor from the device.
- *
- * This function first parses the HID descriptor from the Interface descriptor
- * to get the size of the Report descriptor and then requests the Report 
- * descriptor from the device.
- *
- * @param hid_dev HID device structure.
- * @param config_desc Full configuration descriptor (including all nested
- *                    descriptors).
- * @param config_desc_size Size of the full configuration descriptor (in bytes).
- * @param iface_desc Pointer to the interface descriptor inside the full
- *                   configuration descriptor (@a config_desc) for the interface
- *                   assigned with this device (@a hid_dev).
- *
- * @retval EOK if successful.
- * @retval ENOENT if no HID descriptor could be found.
- * @retval EINVAL if the HID descriptor  or HID report descriptor have different
- *                size than expected.
- * @retval ENOMEM if some allocation failed.
- * @return Other value inherited from function usb_request_get_descriptor().
- *
- * @sa usb_request_get_descriptor()
- */
-static int usbhid_dev_get_report_descriptor(usbhid_dev_t *hid_dev, 
-    uint8_t *config_desc, size_t config_desc_size, uint8_t *iface_desc)
-{
-	assert(hid_dev != NULL);
-	assert(config_desc != NULL);
-	assert(config_desc_size != 0);
-	assert(iface_desc != NULL);
-	
-	usb_dp_parser_t parser =  {
-		.nesting = usb_dp_standard_descriptor_nesting
-	};
-	
-	usb_dp_parser_data_t parser_data = {
-		.data = config_desc,
-		.size = config_desc_size,
-		.arg = NULL
-	};
-	
-	/*
-	 * First nested descriptor of interface descriptor.
-	 */
-	uint8_t *d = 
-	    usb_dp_get_nested_descriptor(&parser, &parser_data, iface_desc);
-	
-	/*
-	 * Search through siblings until the HID descriptor is found.
-	 */
-	while (d != NULL && *(d + 1) != USB_DESCTYPE_HID) {
-		d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 
-		    iface_desc, d);
-	}
-	
-	if (d == NULL) {
-		usb_log_fatal("No HID descriptor found!\n");
-		return ENOENT;
-	}
-	
-	if (*d != sizeof(usb_standard_hid_descriptor_t)) {
-		usb_log_fatal("HID descriptor hass wrong size (%u, expected %u"
-		    ")\n", *d, sizeof(usb_standard_hid_descriptor_t));
-		return EINVAL;
-	}
-	
-	usb_standard_hid_descriptor_t *hid_desc = 
-	    (usb_standard_hid_descriptor_t *)d;
-	
-	uint16_t length =  hid_desc->report_desc_info.length;
-	size_t actual_size = 0;
-
-	/*
-	 * Allocate space for the report descriptor.
-	 */
-	hid_dev->report_desc = (uint8_t *)malloc(length);
-	if (hid_dev->report_desc == NULL) {
-		usb_log_fatal("Failed to allocate space for Report descriptor."
-		    "\n");
-		return ENOMEM;
-	}
-	
-	usb_log_debug("Getting Report descriptor, expected size: %u\n", length);
-	
-	/*
-	 * Get the descriptor from the device.
-	 */
-	int rc = usb_request_get_descriptor(&hid_dev->ctrl_pipe,
-	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE,
-	    USB_DESCTYPE_HID_REPORT, 0,
-	    hid_dev->iface, hid_dev->report_desc, length, &actual_size);
-
-	if (rc != EOK) {
-		return rc;
-	}
-
-	if (actual_size != length) {
-		free(hid_dev->report_desc);
-		hid_dev->report_desc = NULL;
-		usb_log_fatal("Report descriptor has wrong size (%u, expected "
-		    "%u)\n", actual_size, length);
-		return EINVAL;
-	}
-	
-	hid_dev->report_desc_size = length;
-	
-	usb_log_debug("Done.\n");
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Retreives descriptors from the device, initializes pipes and stores 
- * important information from descriptors.
- *
- * Initializes the polling pipe described by the given endpoint description
- * (@a poll_ep_desc).
- * 
- * Information retreived from descriptors and stored in the HID device structure:
- *    - Assigned interface number (the interface controlled by this instance of
- *                                 the driver)
- *    - Polling interval (from the interface descriptor)
- *    - Report descriptor
- *
- * @param hid_dev HID device structure to be initialized.
- * @param poll_ep_desc Description of the polling (Interrupt In) endpoint
- *                     that has to be present in the device in order to
- *                     successfuly initialize the structure.
- *
- * @sa usb_pipe_initialize_from_configuration(), 
- *     usbhid_dev_get_report_descriptor()
- */
-static int usbhid_dev_process_descriptors(usbhid_dev_t *hid_dev, 
-    usb_endpoint_description_t *poll_ep_desc) 
-{
-	assert(hid_dev != NULL);
-	
-	usb_log_debug("Processing descriptors...\n");
-	
-	int rc;
-
-	uint8_t *descriptors = NULL;
-	size_t descriptors_size;
-	rc = usb_request_get_full_configuration_descriptor_alloc(
-	    &hid_dev->ctrl_pipe, 0, (void **) &descriptors, &descriptors_size);
-	if (rc != EOK) {
-		usb_log_error("Failed to retrieve config descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	/*
-	 * Initialize the interrupt in endpoint.
-	 */
-	usb_endpoint_mapping_t endpoint_mapping[1] = {
-		{
-			.pipe = &hid_dev->poll_pipe,
-			.description = poll_ep_desc,
-			.interface_no =
-			    usb_device_get_assigned_interface(hid_dev->device)
-		}
-	};
-	
-	rc = usb_pipe_initialize_from_configuration(
-	    endpoint_mapping, 1, descriptors, descriptors_size,
-	    &hid_dev->wire);
-	
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize poll pipe: %s.\n",
-		    str_error(rc));
-		free(descriptors);
-		return rc;
-	}
-	
-	if (!endpoint_mapping[0].present) {
-		usb_log_warning("Not accepting device.\n");
-		free(descriptors);
-		return EREFUSED;  // probably not very good return value
-	}
-	
-	usb_log_debug("Accepted device. Saving interface, and getting Report"
-	    " descriptor.\n");
-	
-	/*
-	 * Save assigned interface number.
-	 */
-	if (endpoint_mapping[0].interface_no < 0) {
-		usb_log_error("Bad interface number.\n");
-		free(descriptors);
-		return EINVAL;
-	}
-	
-	hid_dev->iface = endpoint_mapping[0].interface_no;
-	
-	assert(endpoint_mapping[0].interface != NULL);
-	
-	/*
-	 * Save polling interval
-	 */
-	hid_dev->poll_interval = endpoint_mapping[0].descriptor->poll_interval;
-	assert(hid_dev->poll_interval > 0);
-	
-	rc = usbhid_dev_get_report_descriptor(hid_dev,
-	    descriptors, descriptors_size,
-	    (uint8_t *)endpoint_mapping[0].interface);
-	
-	free(descriptors);
-	
-	if (rc != EOK) {
-		usb_log_warning("Problem with getting Report descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	rc = usb_hid_parse_report_descriptor(hid_dev->parser, 
-	    hid_dev->report_desc, hid_dev->report_desc_size);
-	if (rc != EOK) {
-		usb_log_warning("Problem parsing Report descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	usb_hid_descriptor_print(hid_dev->parser);
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-/* API functions                                                              */
-/*----------------------------------------------------------------------------*/
-/**
- * Creates new uninitialized HID device structure.
- *
- * @return Pointer to the new HID device structure, or NULL if an error occured.
- */
-usbhid_dev_t *usbhid_dev_new(void)
-{
-	usbhid_dev_t *dev = 
-	    (usbhid_dev_t *)malloc(sizeof(usbhid_dev_t));
-
-	if (dev == NULL) {
-		usb_log_fatal("No memory!\n");
-		return NULL;
-	}
-	
-	memset(dev, 0, sizeof(usbhid_dev_t));
-	
-	dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
-	    usb_hid_report_parser_t)));
-	if (dev->parser == NULL) {
-		usb_log_fatal("No memory!\n");
-		free(dev);
-		return NULL;
-	}
-	
-	dev->initialized = 0;
-	
-	return dev;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Properly destroys the HID device structure.
- *
- * @note Currently does not clean-up the used pipes, as there are no functions
- *       offering such functionality.
- * 
- * @param hid_dev Pointer to the structure to be destroyed.
- */
-void usbhid_dev_free(usbhid_dev_t **hid_dev)
-{
-	if (hid_dev == NULL || *hid_dev == NULL) {
-		return;
-	}
-	
-	// free the report descriptor
-	if ((*hid_dev)->report_desc != NULL) {
-		free((*hid_dev)->report_desc);
-	}
-	// destroy the parser
-	if ((*hid_dev)->parser != NULL) {
-		usb_hid_free_report_parser((*hid_dev)->parser);
-	}
-	
-	// TODO: cleanup pipes
-	
-	free(*hid_dev);
-	*hid_dev = NULL;
-}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Initializes HID device structure.
- *
- * @param hid_dev HID device structure to be initialized.
- * @param dev DDF device representing the HID device.
- * @param poll_ep_desc Description of the polling (Interrupt In) endpoint
- *                     that has to be present in the device in order to
- *                     successfuly initialize the structure.
- *
- * @retval EOK if successful.
- * @retval EINVAL if some argument is missing.
- * @return Other value inherited from one of functions 
- *         usb_device_connection_initialize_from_device(),
- *         usb_pipe_initialize_default_control(),
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usbhid_dev_process_descriptors().
- *
- * @sa usbhid_dev_process_descriptors()
- */
-int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev, 
-    usb_endpoint_description_t *poll_ep_desc)
-{
-	usb_log_debug("Initializing HID device structure.\n");
-	
-	if (hid_dev == NULL) {
-		usb_log_error("Failed to init HID device structure: no "
-		    "structure given.\n");
-		return EINVAL;
-	}
-	
-	if (dev == NULL) {
-		usb_log_error("Failed to init HID device structure: no device"
-		    " given.\n");
-		return EINVAL;
-	}
-	
-	if (poll_ep_desc == NULL) {
-		usb_log_error("No poll endpoint description given.\n");
-		return EINVAL;
-	}
-	
-	hid_dev->device = dev;
-	
-	int rc;
-
-	/*
-	 * Initialize the backing connection to the host controller.
-	 */
-	rc = usb_device_connection_initialize_from_device(&hid_dev->wire, dev);
-	if (rc != EOK) {
-		usb_log_error("Problem initializing connection to device: %s."
-		    "\n", str_error(rc));
-		return rc;
-	}
-
-	/*
-	 * Initialize device pipes.
-	 */
-	rc = usb_pipe_initialize_default_control(&hid_dev->ctrl_pipe,
-	    &hid_dev->wire);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize default control pipe: %s."
-		    "\n", str_error(rc));
-		return rc;
-	}
-	rc = usb_pipe_probe_default_control(&hid_dev->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_error("Probing default control pipe failed: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	/*
-	 * Initialize the report parser.
-	 */
-	rc = usb_hid_parser_init(hid_dev->parser);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize report parser.\n");
-		return rc;
-	}
-
-	/*
-	 * Get descriptors, parse descriptors and save endpoints.
-	 */
-	rc = usb_pipe_start_session(&hid_dev->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_error("Failed to start session on the control pipe: %s"
-		    ".\n", str_error(rc));
-		return rc;
-	}
-	
-	rc = usbhid_dev_process_descriptors(hid_dev, poll_ep_desc);
-	if (rc != EOK) {
-		/* TODO: end session?? */
-		usb_pipe_end_session(&hid_dev->ctrl_pipe);
-		usb_log_error("Failed to process descriptors: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	rc = usb_pipe_end_session(&hid_dev->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_warning("Failed to start session on the control pipe: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-	
-	hid_dev->initialized = 1;
-	usb_log_debug("HID device structure initialized.\n");
-	
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/drv/usbkbd/hiddev.h
===================================================================
--- uspace/drv/usbkbd/hiddev.h	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ 	(revision )
@@ -1,107 +1,0 @@
-/*
- * Copyright (c) 2011 Lubos Slovak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbhid
- * @{
- */
-/** @file
- * Generic USB HID device structure and API.
- *
- * @todo Add function for parsing report - this is generic HID function, not
- *       keyboard-specific, as the report parser is also generic.
- * @todo Add function for polling as that is also a generic HID process.
- * @todo Add interrupt in pipe to the structure.
- */
-
-#ifndef USBHID_HIDDEV_H_
-#define USBHID_HIDDEV_H_
-
-#include <stdint.h>
-
-#include <ddf/driver.h>
-
-#include <usb/classes/hid.h>
-#include <usb/pipes.h>
-#include <usb/classes/hidparser.h>
-
-/*----------------------------------------------------------------------------*/
-
-/**
- * USB/HID device type.
- *
- * Holds a reference to DDF device structure, and HID-specific data, such 
- * as information about used pipes (one Control pipe and one Interrupt In pipe),
- * polling interval, assigned interface number, Report descriptor and a
- * reference to the Report parser used to parse incoming reports and composing
- * outgoing reports.
- */
-typedef struct {
-	/** DDF device representing the controlled HID device. */
-	ddf_dev_t *device;
-
-	/** Physical connection to the device. */
-	usb_device_connection_t wire;
-	/** USB pipe corresponding to the default Control endpoint. */
-	usb_pipe_t ctrl_pipe;
-	/** USB pipe corresponding to the Interrupt In (polling) pipe. */
-	usb_pipe_t poll_pipe;
-	
-	/** Polling interval retreived from the Interface descriptor. */
-	short poll_interval;
-	
-	/** Interface number assigned to this device. */
-	uint16_t iface;
-	
-	/** Report descriptor. */
-	uint8_t *report_desc;
-
-	size_t report_desc_size;
-
-	/** HID Report parser. */
-	usb_hid_report_parser_t *parser;
-	
-	/** State of the structure (for checking before use). */
-	int initialized;
-} usbhid_dev_t;
-
-/*----------------------------------------------------------------------------*/
-
-usbhid_dev_t *usbhid_dev_new(void);
-
-void usbhid_dev_free(usbhid_dev_t **hid_dev);
-
-int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev,
-    usb_endpoint_description_t *poll_ep_desc);
-
-/*----------------------------------------------------------------------------*/
-
-#endif /* USBHID_HIDDEV_H_ */
-
-/**
- * @}
- */
Index: uspace/drv/usbkbd/kbddev.c
===================================================================
--- uspace/drv/usbkbd/kbddev.c	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/kbddev.c	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -55,4 +55,5 @@
 #include <usb/classes/hidut.h>
 #include <usb/classes/hidreq.h>
+#include <usb/classes/hidreport.h>
 
 #include <usb/devdrv.h>
@@ -88,4 +89,6 @@
 /** Delay between two repeats of a pressed key when auto-repeating. */
 static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000;
+
+/*----------------------------------------------------------------------------*/
 
 /** Keyboard polling endpoint description for boot protocol class. */
@@ -99,26 +102,26 @@
 };
 
-/** General keyboard polling endpoint description. */
-//static usb_endpoint_description_t general_poll_endpoint_description = {
-//	.transfer_type = USB_TRANSFER_INTERRUPT,
-//	.direction = USB_DIRECTION_IN,
-//	.interface_class = USB_CLASS_HID,
-//	.flags = 0
-//};
-
 /* Array of endpoints expected on the device, NULL terminated. */
 usb_endpoint_description_t 
-    *usbhid_kbd_endpoints[USBHID_KBD_POLL_EP_COUNT + 1] = {
+    *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {
 	&boot_poll_endpoint_description,
-//	&general_poll_endpoint_description,
 	NULL
 };
 
-
-typedef enum usbhid_kbd_flags {
-	USBHID_KBD_STATUS_UNINITIALIZED = 0,
-	USBHID_KBD_STATUS_INITIALIZED = 1,
-	USBHID_KBD_STATUS_TO_DESTROY = -1
-} usbhid_kbd_flags;
+/*----------------------------------------------------------------------------*/
+
+enum {
+	BOOT_REPORT_DESCRIPTOR_SIZE = 0
+};
+
+static const uint8_t BOOT_REPORT_DESCRIPTOR[BOOT_REPORT_DESCRIPTOR_SIZE] = {};
+
+/*----------------------------------------------------------------------------*/
+
+typedef enum usb_kbd_flags {
+	USB_KBD_STATUS_UNINITIALIZED = 0,
+	USB_KBD_STATUS_INITIALIZED = 1,
+	USB_KBD_STATUS_TO_DESTROY = -1
+} usb_kbd_flags;
 
 /*----------------------------------------------------------------------------*/
@@ -153,14 +156,14 @@
 
 typedef enum usbhid_lock_code {
-	USBHID_LOCK_NUM = 0x53,
-	USBHID_LOCK_CAPS = 0x39,
-	USBHID_LOCK_SCROLL = 0x47,
-	USBHID_LOCK_COUNT = 3
+	USB_KBD_LOCK_NUM = 0x53,
+	USB_KBD_LOCK_CAPS = 0x39,
+	USB_KBD_LOCK_SCROLL = 0x47,
+	USB_KBD_LOCK_COUNT = 3
 } usbhid_lock_code;
 
-static const usbhid_lock_code usbhid_lock_codes[USBHID_LOCK_COUNT] = {
-	USBHID_LOCK_NUM,
-	USBHID_LOCK_CAPS,
-	USBHID_LOCK_SCROLL
+static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = {
+	USB_KBD_LOCK_NUM,
+	USB_KBD_LOCK_CAPS,
+	USB_KBD_LOCK_SCROLL
 };
 
@@ -190,5 +193,5 @@
 	sysarg_t method = IPC_GET_IMETHOD(*icall);
 	
-	usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)fun->driver_data;
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
 	assert(kbd_dev != NULL);
 
@@ -224,5 +227,5 @@
  * @param kbd_dev Keyboard device structure.
  */
-static void usbhid_kbd_set_led(usbhid_kbd_t *kbd_dev) 
+static void usb_kbd_set_led(usb_kbd_t *kbd_dev) 
 {
 	uint8_t buffer[BOOTP_BUFFER_OUT_SIZE];
@@ -282,5 +285,5 @@
  * @param key Key code of the key according to HID Usage Tables.
  */
-void usbhid_kbd_push_ev(usbhid_kbd_t *kbd_dev, int type, unsigned int key)
+void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned int key)
 {
 	console_event_t ev;
@@ -332,5 +335,5 @@
 			/* Update keyboard lock indicator lights. */
 			if (kbd_dev->lock_keys != locks_old) {
-				usbhid_kbd_set_led(kbd_dev);
+				usb_kbd_set_led(kbd_dev);
 			}
 		} else {
@@ -380,49 +383,6 @@
 
 /*----------------------------------------------------------------------------*/
-/**
- * Checks if modifiers were pressed or released and generates key events.
- *
- * @param kbd_dev Keyboard device structure.
- * @param modifiers Bitmap of modifiers.
- *
- * @sa usbhid_kbd_push_ev()
- */
-//static void usbhid_kbd_check_modifier_changes(usbhid_kbd_t *kbd_dev, 
-//    const uint8_t *key_codes, size_t count)
-//{
-//	/*
-//	 *  why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK
-//	 *       both as modifiers and as keyUSB_HID_LOCK_COUNTs with their own scancodes???
-//	 *
-//	 * modifiers should be sent as normal keys to usbhid_parse_scancode()!!
-//	 * so maybe it would be better if I received it from report parser in 
-//	 * that way
-//	 */
-	
-//	int i;
-//	for (i = 0; i < count; ++i) {
-//		if ((modifiers & usb_hid_modifiers_consts[i]) &&
-//		    !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
-//			// modifier pressed
-//			if (usbhid_modifiers_keycodes[i] != 0) {
-//				usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, 
-//				    usbhid_modifiers_keycodes[i]);
-//			}
-//		} else if (!(modifiers & usb_hid_modifiers_consts[i]) &&
-//		    (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {
-//			// modifier released
-//			if (usbhid_modifiers_keycodes[i] != 0) {
-//				usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, 
-//				    usbhid_modifiers_keycodes[i]);
-//			}
-//		}	// no change
-//	}
-	
-//	kbd_dev->modifiers = modifiers;
-//}
-
-/*----------------------------------------------------------------------------*/
-
-static inline int usbhid_kbd_is_lock(unsigned int key_code) 
+
+static inline int usb_kbd_is_lock(unsigned int key_code) 
 {
 	return (key_code == KC_NUM_LOCK
@@ -436,7 +396,7 @@
  *
  * An event is created only when key is pressed or released. Besides handling
- * the events (usbhid_kbd_push_ev()), the auto-repeat fibril is notified about
- * key presses and releases (see usbhid_kbd_repeat_start() and 
- * usbhid_kbd_repeat_stop()).
+ * the events (usb_kbd_push_ev()), the auto-repeat fibril is notified about
+ * key presses and releases (see usb_kbd_repeat_start() and 
+ * usb_kbd_repeat_stop()).
  *
  * @param kbd_dev Keyboard device structure.
@@ -445,7 +405,7 @@
  * @param count Number of key codes in report (size of the report).
  *
- * @sa usbhid_kbd_push_ev(), usbhid_kbd_repeat_start(), usbhid_kbd_repeat_stop()
- */
-static void usbhid_kbd_check_key_changes(usbhid_kbd_t *kbd_dev, 
+ * @sa usb_kbd_push_ev(), usb_kbd_repeat_start(), usb_kbd_repeat_stop()
+ */
+static void usb_kbd_check_key_changes(usb_kbd_t *kbd_dev, 
     const uint8_t *key_codes, size_t count)
 {
@@ -488,8 +448,8 @@
 			// not found, i.e. the key was released
 			key = usbhid_parse_scancode(kbd_dev->keys[j]);
-			if (!usbhid_kbd_is_lock(key)) {
-				usbhid_kbd_repeat_stop(kbd_dev, key);
+			if (!usb_kbd_is_lock(key)) {
+				usb_kbd_repeat_stop(kbd_dev, key);
 			}
-			usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, key);
+			usb_kbd_push_ev(kbd_dev, KEY_RELEASE, key);
 			usb_log_debug2("Key released: %d\n", key);
 		} else {
@@ -513,7 +473,7 @@
 			usb_log_debug2("Key pressed: %d (keycode: %d)\n", key,
 			    key_codes[i]);
-			usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key);
-			if (!usbhid_kbd_is_lock(key)) {
-				usbhid_kbd_repeat_start(kbd_dev, key);
+			usb_kbd_push_ev(kbd_dev, KEY_PRESS, key);
+			if (!usb_kbd_is_lock(key)) {
+				usb_kbd_repeat_start(kbd_dev, key);
 			}
 		} else {
@@ -545,7 +505,7 @@
  *            structure representing the keyboard.
  *
- * @sa usbhid_kbd_check_key_changes(), usbhid_kbd_check_modifier_changes()
- */
-static void usbhid_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
+ * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes()
+ */
+static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
     uint8_t modifiers, void *arg)
 {
@@ -556,5 +516,5 @@
 	}
 	
-	usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg;
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)arg;
 	assert(kbd_dev != NULL);
 
@@ -568,6 +528,6 @@
 	}
 	
-	///usbhid_kbd_check_modifier_changes(kbd_dev, key_codes, count);
-	usbhid_kbd_check_key_changes(kbd_dev, key_codes, count);
+	///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count);
+	usb_kbd_check_key_changes(kbd_dev, key_codes, count);
 }
 
@@ -580,5 +540,5 @@
  * This function uses the HID report parser to translate the data received from
  * the device into generic USB HID key codes and into generic modifiers bitmap.
- * The parser then calls the given callback (usbhid_kbd_process_keycodes()).
+ * The parser then calls the given callback (usb_kbd_process_keycodes()).
  *
  * @note Currently, only the boot protocol is supported.
@@ -588,11 +548,11 @@
  * @param actual_size Size of the data from keyboard (report size) in bytes.
  *
- * @sa usbhid_kbd_process_keycodes(), usb_hid_boot_keyboard_input_report(),
+ * @sa usb_kbd_process_keycodes(), usb_hid_boot_keyboard_input_report(),
  *     usb_hid_parse_report().
  */
-static void usbhid_kbd_process_data(usbhid_kbd_t *kbd_dev,
+static void usb_kbd_process_data(usb_kbd_t *kbd_dev,
                                     uint8_t *buffer, size_t actual_size)
 {
-	assert(kbd_dev->initialized == USBHID_KBD_STATUS_INITIALIZED);
+	assert(kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
 	assert(kbd_dev->parser != NULL);
 	
@@ -601,5 +561,5 @@
 	        sizeof(usb_hid_report_in_callbacks_t));
 	
-	callbacks->keyboard = usbhid_kbd_process_keycodes;
+	callbacks->keyboard = usb_kbd_process_keycodes;
 
 	usb_log_debug("Calling usb_hid_parse_report() with "
@@ -621,287 +581,9 @@
 /*----------------------------------------------------------------------------*/
 
-static void usbhid_kbd_mark_unusable(usbhid_kbd_t *kbd_dev)
-{
-	kbd_dev->initialized = USBHID_KBD_STATUS_TO_DESTROY;
-}
-
-/*----------------------------------------------------------------------------*/
-/* HID/KBD polling                                                            */
-/*----------------------------------------------------------------------------*/
-/**
- * Main keyboard polling function.
- *
- * This function uses the Interrupt In pipe of the keyboard to poll for events.
- * The keyboard is initialized in a way that it reports only when a key is 
- * pressed or released, so there is no actual need for any sleeping between
- * polls (see usbhid_kbd_try_add_device() or usbhid_kbd_init()).
- *
- * @param kbd_dev Initialized keyboard structure representing the device to 
- *                poll.
- *
- * @sa usbhid_kbd_process_data()
- */
-//static void usbhid_kbd_poll(usbhid_kbd_t *kbd_dev)
-//{
-//	int rc, sess_rc;
-//	uint8_t buffer[BOOTP_BUFFER_SIZE];
-//	size_t actual_size;
-	
-//	usb_log_debug("Polling keyboard...\n");
-	
-//	if (!kbd_dev->initialized) {
-//		usb_log_error("HID/KBD device not initialized!\n");
-//		return;
-//	}
-	
-//	assert(kbd_dev->hid_dev != NULL);
-//	assert(kbd_dev->hid_dev->initialized);
-
-//	while (true) {
-//		sess_rc = usb_pipe_start_session(
-//		    &kbd_dev->hid_dev->poll_pipe);
-//		if (sess_rc != EOK) {
-//			usb_log_warning("Failed to start a session: %s.\n",
-//			    str_error(sess_rc));
-//			break;
-//		}
-
-//		rc = usb_pipe_read(&kbd_dev->hid_dev->poll_pipe, 
-//		    buffer, BOOTP_BUFFER_SIZE, &actual_size);
-		
-//		sess_rc = usb_pipe_end_session(
-//		    &kbd_dev->hid_dev->poll_pipe);
-
-//		if (rc != EOK) {
-//			usb_log_warning("Error polling the keyboard: %s.\n",
-//			    str_error(rc));
-//			break;
-//		}
-
-//		if (sess_rc != EOK) {
-//			usb_log_warning("Error closing session: %s.\n",
-//			    str_error(sess_rc));
-//			break;
-//		}
-
-//		/*
-//		 * If the keyboard answered with NAK, it returned no data.
-//		 * This implies that no change happened since last query.
-//		 */
-//		if (actual_size == 0) {
-//			usb_log_debug("Keyboard returned NAK\n");
-//			continue;
-//		}
-
-//		/*
-//		 * TODO: Process pressed keys.
-//		 */
-//		usb_log_debug("Calling usbhid_kbd_process_data()\n");
-//		usbhid_kbd_process_data(kbd_dev, buffer, actual_size);
-		
-//		// disabled for now, no reason to sleep
-//		//async_usleep(kbd_dev->hid_dev->poll_interval);
-//	}
-//}
-
-/*----------------------------------------------------------------------------*/
-/**
- * Function executed by the main driver fibril.
- *
- * Just starts polling the keyboard for events.
- * 
- * @param arg Initialized keyboard device structure (of type usbhid_kbd_t) 
- *            representing the device.
- *
- * @retval EOK if the fibril finished polling the device.
- * @retval EINVAL if no device was given in the argument.
- *
- * @sa usbhid_kbd_poll()
- *
- * @todo Change return value - only case when the fibril finishes is in case
- *       of some error, so the error should probably be propagated from function
- *       usbhid_kbd_poll() to here and up.
- */
-//static int usbhid_kbd_fibril(void *arg)
-//{
-//	if (arg == NULL) {
-//		usb_log_error("No device!\n");
-//		return EINVAL;
-//	}
-	
-//	usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg;
-
-//	usbhid_kbd_poll(kbd_dev);
-	
-//	// as there is another fibril using this device, so we must leave the
-//	// structure to it, but mark it for destroying.
-//	usbhid_kbd_mark_unusable(kbd_dev);
-//	// at the end, properly destroy the KBD structure
-////	usbhid_kbd_free(&kbd_dev);
-////	assert(kbd_dev == NULL);
-
-//	return EOK;
-//}
-
-static int usbhid_dev_get_report_descriptor(usbhid_kbd_t *kbd_dev)
-{
-	assert(kbd_dev != NULL);
-	assert(kbd_dev->usb_dev != NULL);
-	assert(kbd_dev->usb_dev->interface_no >= 0);
-	
-	usb_dp_parser_t parser =  {
-		.nesting = usb_dp_standard_descriptor_nesting
-	};
-	
-	usb_dp_parser_data_t parser_data = {
-		.data = kbd_dev->usb_dev->descriptors.configuration,
-		.size = kbd_dev->usb_dev->descriptors.configuration_size,
-		.arg = NULL
-	};
-	
-	/*
-	 * First nested descriptor of the configuration descriptor.
-	 */
-	uint8_t *d = 
-	    usb_dp_get_nested_descriptor(&parser, &parser_data, 
-	    kbd_dev->usb_dev->descriptors.configuration);
-	
-	/*
-	 * Find the interface descriptor corresponding to our interface number.
-	 */
-	int i = 0;
-	while (d != NULL && i < kbd_dev->usb_dev->interface_no) {
-		d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 
-		    kbd_dev->usb_dev->descriptors.configuration, d);
-	}
-	
-	if (d == NULL) {
-		usb_log_fatal("The %. interface descriptor not found!\n",
-		    kbd_dev->usb_dev->interface_no);
-		return ENOENT;
-	}
-	
-	/*
-	 * First nested descriptor of the interface descriptor.
-	 */
-	uint8_t *iface_desc = d;
-	d = usb_dp_get_nested_descriptor(&parser, &parser_data, iface_desc);
-	
-	/*
-	 * Search through siblings until the HID descriptor is found.
-	 */
-	while (d != NULL && *(d + 1) != USB_DESCTYPE_HID) {
-		d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 
-		    iface_desc, d);
-	}
-	
-	if (d == NULL) {
-		usb_log_fatal("No HID descriptor found!\n");
-		return ENOENT;
-	}
-	
-	if (*d != sizeof(usb_standard_hid_descriptor_t)) {
-		usb_log_fatal("HID descriptor hass wrong size (%u, expected %u"
-		    ")\n", *d, sizeof(usb_standard_hid_descriptor_t));
-		return EINVAL;
-	}
-	
-	usb_standard_hid_descriptor_t *hid_desc = 
-	    (usb_standard_hid_descriptor_t *)d;
-	
-	uint16_t length =  hid_desc->report_desc_info.length;
-	size_t actual_size = 0;
-	
-	/*
-	 * Start session for the control transfer.
-	 */
-	int sess_rc = usb_pipe_start_session(&kbd_dev->usb_dev->ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
-
-	/*
-	 * Allocate space for the report descriptor.
-	 */
-	kbd_dev->report_desc = (uint8_t *)malloc(length);
-	if (kbd_dev->report_desc == NULL) {
-		usb_log_fatal("Failed to allocate space for Report descriptor."
-		    "\n");
-		return ENOMEM;
-	}
-	
-	usb_log_debug("Getting Report descriptor, expected size: %u\n", length);
-	
-	/*
-	 * Get the descriptor from the device.
-	 */
-	int rc = usb_request_get_descriptor(&kbd_dev->usb_dev->ctrl_pipe,
-	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE,
-	    USB_DESCTYPE_HID_REPORT, 0, kbd_dev->usb_dev->interface_no,
-	    kbd_dev->report_desc, length, &actual_size);
-
-	if (rc != EOK) {
-		free(kbd_dev->report_desc);
-		kbd_dev->report_desc = NULL;
-		return rc;
-	}
-
-	if (actual_size != length) {
-		free(kbd_dev->report_desc);
-		kbd_dev->report_desc = NULL;
-		usb_log_fatal("Report descriptor has wrong size (%u, expected "
-		    "%u)\n", actual_size, length);
-		return EINVAL;
-	}
-	
-	/*
-	 * End session for the control transfer.
-	 */
-	sess_rc = usb_pipe_end_session(&kbd_dev->usb_dev->ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to end a session: %s.\n",
-		    str_error(sess_rc));
-		free(kbd_dev->report_desc);
-		kbd_dev->report_desc = NULL;
-		return sess_rc;
-	}
-	
-	kbd_dev->report_desc_size = length;
-	
-	usb_log_debug("Done.\n");
-	
-	return EOK;
-}
-
-/*----------------------------------------------------------------------------*/
-
-static int usbhid_kbd_process_report_descriptor(usbhid_kbd_t *kbd_dev)
-{
-	int rc = usbhid_dev_get_report_descriptor(kbd_dev);
-	
-	if (rc != EOK) {
-		usb_log_warning("Problem with getting Report descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	rc = usb_hid_parse_report_descriptor(kbd_dev->parser, 
-	    kbd_dev->report_desc, kbd_dev->report_desc_size);
-	if (rc != EOK) {
-		usb_log_warning("Problem parsing Report descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	
-	usb_hid_descriptor_print(kbd_dev->parser);
-	
-	/*
-	 * TODO: if failed, try to parse the boot report descriptor.
-	 */
-	
-	return EOK;
-}
+static void usb_kbd_mark_unusable(usb_kbd_t *kbd_dev)
+{
+	kbd_dev->initialized = USB_KBD_STATUS_TO_DESTROY;
+}
+
 
 /*----------------------------------------------------------------------------*/
@@ -912,13 +594,13 @@
  *
  * The structure returned by this function is not initialized. Use 
- * usbhid_kbd_init() to initialize it prior to polling.
+ * usb_kbd_init() to initialize it prior to polling.
  *
  * @return New uninitialized structure for representing a USB/HID keyboard or
  *         NULL if not successful (memory error).
  */
-usbhid_kbd_t *usbhid_kbd_new(void)
-{
-	usbhid_kbd_t *kbd_dev = 
-	    (usbhid_kbd_t *)malloc(sizeof(usbhid_kbd_t));
+usb_kbd_t *usb_kbd_new(void)
+{
+	usb_kbd_t *kbd_dev = 
+	    (usb_kbd_t *)malloc(sizeof(usb_kbd_t));
 
 	if (kbd_dev == NULL) {
@@ -927,5 +609,5 @@
 	}
 	
-	memset(kbd_dev, 0, sizeof(usbhid_kbd_t));
+	memset(kbd_dev, 0, sizeof(usb_kbd_t));
 	
 	kbd_dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof(
@@ -938,5 +620,5 @@
 	
 	kbd_dev->console_phone = -1;
-	kbd_dev->initialized = USBHID_KBD_STATUS_UNINITIALIZED;
+	kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
 	
 	return kbd_dev;
@@ -964,5 +646,5 @@
  * @return Other value inherited from function usbhid_dev_init().
  */
-int usbhid_kbd_init(usbhid_kbd_t *kbd_dev, usb_device_t *dev)
+int usb_kbd_init(usb_kbd_t *kbd_dev, usb_device_t *dev)
 {
 	int rc;
@@ -982,5 +664,5 @@
 	}
 	
-	if (kbd_dev->initialized == USBHID_KBD_STATUS_INITIALIZED) {
+	if (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED) {
 		usb_log_warning("Keyboard structure already initialized.\n");
 		return EINVAL;
@@ -996,5 +678,5 @@
 //	}
 	
-//	assert(kbd_dev->hid_dev->initialized == USBHID_KBD_STATUS_INITIALIZED);
+//	assert(kbd_dev->hid_dev->initialized == USB_KBD_STATUS_INITIALIZED);
 	
 	// save the size of the report (boot protocol report by default)
@@ -1012,8 +694,25 @@
 	
 	/* Get the report descriptor and parse it. */
-	rc = usbhid_kbd_process_report_descriptor(kbd_dev);
+	rc = usb_hid_process_report_descriptor(kbd_dev->usb_dev, 
+	    kbd_dev->parser);
 	if (rc != EOK) {
-		usb_log_warning("Could not process report descriptor.\n");
-		return rc;
+		usb_log_warning("Could not process report descriptor, "
+		    "falling back to boot protocol.\n");
+		rc = usb_hid_parse_report_descriptor(kbd_dev->parser, 
+		    BOOT_REPORT_DESCRIPTOR, BOOT_REPORT_DESCRIPTOR_SIZE);
+		if (rc != EOK) {
+			usb_log_error("Failed to parse boot report descriptor:"
+			    " %s.\n", str_error(rc));
+			return rc;
+		}
+		
+		rc = usbhid_req_set_protocol(&kbd_dev->usb_dev->ctrl_pipe, 
+		    kbd_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
+		
+		if (rc != EOK) {
+			usb_log_warning("Failed to set boot protocol to the "
+			    "device: %s\n", str_error(rc));
+			return rc;
+		}
 	}
 	
@@ -1056,18 +755,13 @@
 	
 	/*
-	 * Set boot protocol.
 	 * Set LEDs according to initial setup.
 	 * Set Idle rate
 	 */
-	//assert(kbd_dev->hid_dev != NULL);
-	//assert(kbd_dev->hid_dev->initialized);
-	//usbhid_req_set_protocol(kbd_dev->hid_dev, USB_HID_PROTOCOL_BOOT);
-	
-	usbhid_kbd_set_led(kbd_dev);
+	usb_kbd_set_led(kbd_dev);
 	
 	usbhid_req_set_idle(&kbd_dev->usb_dev->ctrl_pipe, 
 	    kbd_dev->usb_dev->interface_no, IDLE_RATE);
 	
-	kbd_dev->initialized = USBHID_KBD_STATUS_INITIALIZED;
+	kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
 	usb_log_debug("HID/KBD device structure initialized.\n");
 	
@@ -1077,5 +771,5 @@
 /*----------------------------------------------------------------------------*/
 
-bool usbhid_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
+bool usb_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
      size_t buffer_size, void *arg)
 {
@@ -1085,8 +779,8 @@
 	}
 	
-	usbhid_kbd_t *kbd_dev = (usbhid_kbd_t *)arg;
+	usb_kbd_t *kbd_dev = (usb_kbd_t *)arg;
 	
 	// TODO: add return value from this function
-	usbhid_kbd_process_data(kbd_dev, buffer, buffer_size);
+	usb_kbd_process_data(kbd_dev, buffer, buffer_size);
 	
 	return true;
@@ -1095,5 +789,5 @@
 /*----------------------------------------------------------------------------*/
 
-void usbhid_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
+void usb_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
      void *arg)
 {
@@ -1102,21 +796,21 @@
 	}
 	
-	usbhid_kbd_t *kbd = (usbhid_kbd_t *)arg;
-	
-	usbhid_kbd_mark_unusable(kbd);
-}
-
-/*----------------------------------------------------------------------------*/
-
-int usbhid_kbd_is_initialized(const usbhid_kbd_t *kbd_dev)
-{
-	return (kbd_dev->initialized == USBHID_KBD_STATUS_INITIALIZED);
-}
-
-/*----------------------------------------------------------------------------*/
-
-int usbhid_kbd_is_ready_to_destroy(const usbhid_kbd_t *kbd_dev)
-{
-	return (kbd_dev->initialized == USBHID_KBD_STATUS_TO_DESTROY);
+	usb_kbd_t *kbd = (usb_kbd_t *)arg;
+	
+	usb_kbd_mark_unusable(kbd);
+}
+
+/*----------------------------------------------------------------------------*/
+
+int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev)
+{
+	return (kbd_dev->initialized == USB_KBD_STATUS_INITIALIZED);
+}
+
+/*----------------------------------------------------------------------------*/
+
+int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev)
+{
+	return (kbd_dev->initialized == USB_KBD_STATUS_TO_DESTROY);
 }
 
@@ -1127,5 +821,5 @@
  * @param kbd_dev Pointer to the structure to be destroyed.
  */
-void usbhid_kbd_free(usbhid_kbd_t **kbd_dev)
+void usb_kbd_free(usb_kbd_t **kbd_dev)
 {
 	if (kbd_dev == NULL || *kbd_dev == NULL) {
Index: uspace/drv/usbkbd/kbddev.h
===================================================================
--- uspace/drv/usbkbd/kbddev.h	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/kbddev.h	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -34,6 +34,6 @@
  */
 
-#ifndef USBHID_KBDDEV_H_
-#define USBHID_KBDDEV_H_
+#ifndef USB_KBDDEV_H_
+#define USB_KBDDEV_H_
 
 #include <stdint.h>
@@ -62,5 +62,5 @@
  *       being device-specific.
  */
-typedef struct usbhid_kbd_t {
+typedef struct usb_kbd_t {
 	/** Structure holding generic USB device information. */
 	//usbhid_dev_t *hid_dev;
@@ -84,5 +84,5 @@
 	
 	/** Information for auto-repeat of keys. */
-	usbhid_kbd_repeat_t repeat;
+	usb_kbd_repeat_t repeat;
 	
 	/** Mutex for accessing the information about auto-repeat. */
@@ -105,14 +105,14 @@
 	 */
 	int initialized;
-} usbhid_kbd_t;
+} usb_kbd_t;
 
 /*----------------------------------------------------------------------------*/
 
 enum {
-	USBHID_KBD_POLL_EP_NO = 0,
-	USBHID_KBD_POLL_EP_COUNT = 1
+	USB_KBD_POLL_EP_NO = 0,
+	USB_KBD_POLL_EP_COUNT = 1
 };
 
-usb_endpoint_description_t *usbhid_kbd_endpoints[USBHID_KBD_POLL_EP_COUNT + 1];
+usb_endpoint_description_t *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1];
 
 ddf_dev_ops_t keyboard_ops;
@@ -120,23 +120,23 @@
 /*----------------------------------------------------------------------------*/
 
-usbhid_kbd_t *usbhid_kbd_new(void);
+usb_kbd_t *usb_kbd_new(void);
 
-int usbhid_kbd_init(usbhid_kbd_t *kbd_dev, usb_device_t *dev);
+int usb_kbd_init(usb_kbd_t *kbd_dev, usb_device_t *dev);
 
-bool usbhid_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
+bool usb_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
      size_t buffer_size, void *arg);
 
-void usbhid_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
+void usb_kbd_polling_ended_callback(usb_device_t *dev, bool reason, 
      void *arg);
 
-int usbhid_kbd_is_initialized(const usbhid_kbd_t *kbd_dev);
+int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev);
 
-int usbhid_kbd_is_ready_to_destroy(const usbhid_kbd_t *kbd_dev);
+int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev);
 
-void usbhid_kbd_free(usbhid_kbd_t **kbd_dev);
+void usb_kbd_free(usb_kbd_t **kbd_dev);
 
-void usbhid_kbd_push_ev(usbhid_kbd_t *kbd_dev, int type, unsigned int key);
+void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned int key);
 
-#endif /* USBHID_KBDDEV_H_ */
+#endif /* USB_KBDDEV_H_ */
 
 /**
Index: uspace/drv/usbkbd/kbdrepeat.c
===================================================================
--- uspace/drv/usbkbd/kbdrepeat.c	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/kbdrepeat.c	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -62,5 +62,5 @@
  * 
  * If the currently repeated key is not pressed any more (
- * usbhid_kbd_repeat_stop() was called), it stops repeating it and starts 
+ * usb_kbd_repeat_stop() was called), it stops repeating it and starts 
  * checking again.
  *
@@ -70,5 +70,5 @@
  * @param kbd Keyboard device structure.
  */
-static void usbhid_kbd_repeat_loop(usbhid_kbd_t *kbd)
+static void usb_kbd_repeat_loop(usb_kbd_t *kbd)
 {
 	unsigned int delay = 0;
@@ -78,7 +78,7 @@
 	while (true) {
 		// check if the kbd structure is usable
-		if (!usbhid_kbd_is_initialized(kbd)) {
-			if (usbhid_kbd_is_ready_to_destroy(kbd)) {
-				usbhid_kbd_free(&kbd);
+		if (!usb_kbd_is_initialized(kbd)) {
+			if (usb_kbd_is_ready_to_destroy(kbd)) {
+				usb_kbd_free(&kbd);
 				assert(kbd == NULL);
 			}
@@ -92,5 +92,5 @@
 				usb_log_debug2("Repeating key: %u.\n", 
 				    kbd->repeat.key_repeated);
-				usbhid_kbd_push_ev(kbd, KEY_PRESS, 
+				usb_kbd_push_ev(kbd, KEY_PRESS, 
 				    kbd->repeat.key_repeated);
 				delay = kbd->repeat.delay_between;
@@ -127,5 +127,5 @@
  * @retval EINVAL if no argument is supplied.
  */
-int usbhid_kbd_repeat_fibril(void *arg)
+int usb_kbd_repeat_fibril(void *arg)
 {
 	usb_log_debug("Autorepeat fibril spawned.\n");
@@ -136,7 +136,7 @@
 	}
 	
-	usbhid_kbd_t *kbd = (usbhid_kbd_t *)arg;
+	usb_kbd_t *kbd = (usb_kbd_t *)arg;
 	
-	usbhid_kbd_repeat_loop(kbd);
+	usb_kbd_repeat_loop(kbd);
 	
 	return EOK;
@@ -154,5 +154,5 @@
  * @param key Key to start repeating.
  */
-void usbhid_kbd_repeat_start(usbhid_kbd_t *kbd, unsigned int key)
+void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
 {
 	fibril_mutex_lock(kbd->repeat_mtx);
@@ -172,5 +172,5 @@
  * @param key Key to stop repeating.
  */
-void usbhid_kbd_repeat_stop(usbhid_kbd_t *kbd, unsigned int key)
+void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
 {
 	fibril_mutex_lock(kbd->repeat_mtx);
Index: uspace/drv/usbkbd/kbdrepeat.h
===================================================================
--- uspace/drv/usbkbd/kbdrepeat.h	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/kbdrepeat.h	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -34,8 +34,8 @@
  */
 
-#ifndef USBHID_KBDREPEAT_H_
-#define USBHID_KBDREPEAT_H_
+#ifndef USB_KBDREPEAT_H_
+#define USB_KBDREPEAT_H_
 
-struct usbhid_kbd_t;
+struct usb_kbd_t;
 
 /*----------------------------------------------------------------------------*/
@@ -52,15 +52,15 @@
 	/** Delay between repeats in microseconds. */
 	unsigned int delay_between;
-} usbhid_kbd_repeat_t;
+} usb_kbd_repeat_t;
 
 /*----------------------------------------------------------------------------*/
 
-int usbhid_kbd_repeat_fibril(void *arg);
+int usb_kbd_repeat_fibril(void *arg);
 
-void usbhid_kbd_repeat_start(struct usbhid_kbd_t *kbd, unsigned int key);
+void usb_kbd_repeat_start(struct usb_kbd_t *kbd, unsigned int key);
 
-void usbhid_kbd_repeat_stop(struct usbhid_kbd_t *kbd, unsigned int key);
+void usb_kbd_repeat_stop(struct usb_kbd_t *kbd, unsigned int key);
 
-#endif /* USBHID_KBDREPEAT_H_ */
+#endif /* USB_KBDREPEAT_H_ */
 
 /**
Index: uspace/drv/usbkbd/layout.h
===================================================================
--- uspace/drv/usbkbd/layout.h	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/layout.h	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -36,6 +36,6 @@
  */
 
-#ifndef USBHID_LAYOUT_H_
-#define USBHID_LAYOUT_H_
+#ifndef USB_KBD_LAYOUT_H_
+#define USB_KBD_LAYOUT_H_
 
 #include <sys/types.h>
Index: uspace/drv/usbkbd/main.c
===================================================================
--- uspace/drv/usbkbd/main.c	(revision 476b71ff0be15aa5fefa460a7911a8e4948455f2)
+++ uspace/drv/usbkbd/main.c	(revision 252e30c70fdb8f44e392d95865ed60d1c24eaf41)
@@ -70,8 +70,8 @@
  * @retval EOK if successful.
  * @retval ENOMEM if there
- * @return Other error code inherited from one of functions usbhid_kbd_init(),
+ * @return Other error code inherited from one of functions usb_kbd_init(),
  *         ddf_fun_bind() and ddf_fun_add_to_class().
  *
- * @sa usbhid_kbd_fibril(), usbhid_kbd_repeat_fibril()
+ * @sa usb_kbd_fibril(), usb_kbd_repeat_fibril()
  */
 static int usbhid_try_add_device(usb_device_t *dev)
@@ -90,5 +90,5 @@
 	usb_log_debug("Initializing USB/HID KBD device...\n");
 	
-	usbhid_kbd_t *kbd_dev = usbhid_kbd_new();
+	usb_kbd_t *kbd_dev = usb_kbd_new();
 	if (kbd_dev == NULL) {
 		usb_log_error("Error while creating USB/HID KBD device "
@@ -98,10 +98,10 @@
 	}
 	
-	int rc = usbhid_kbd_init(kbd_dev, dev);
+	int rc = usb_kbd_init(kbd_dev, dev);
 	
 	if (rc != EOK) {
 		usb_log_error("Failed to initialize USB/HID KBD device.\n");
 		ddf_fun_destroy(kbd_fun);
-		usbhid_kbd_free(&kbd_dev);
+		usb_kbd_free(&kbd_dev);
 		return rc;
 	}	
@@ -122,5 +122,5 @@
 		// TODO: Can / should I destroy the DDF function?
 		ddf_fun_destroy(kbd_fun);
-		usbhid_kbd_free(&kbd_dev);
+		usb_kbd_free(&kbd_dev);
 		return rc;
 	}
@@ -133,5 +133,5 @@
 		// TODO: Can / should I destroy the DDF function?
 		ddf_fun_destroy(kbd_fun);
-		usbhid_kbd_free(&kbd_dev);
+		usb_kbd_free(&kbd_dev);
 		return rc;
 	}
@@ -140,5 +140,5 @@
 	 * Create new fibril for handling this keyboard
 	 */
-	//fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev);
+	//fid_t fid = fibril_create(usb_kbd_fibril, kbd_dev);
 	
 	/* Start automated polling function.
@@ -148,11 +148,11 @@
        rc = usb_device_auto_poll(dev,
 	   /* Index of the polling pipe. */
-	   USBHID_KBD_POLL_EP_NO,
+	   USB_KBD_POLL_EP_NO,
 	   /* Callback when data arrives. */
-	   usbhid_kbd_polling_callback,
+	   usb_kbd_polling_callback,
 	   /* How much data to request. */
-	   dev->pipes[USBHID_KBD_POLL_EP_NO].pipe->max_packet_size,
+	   dev->pipes[USB_KBD_POLL_EP_NO].pipe->max_packet_size,
 	   /* Callback when the polling ends. */
-	   usbhid_kbd_polling_ended_callback,
+	   usb_kbd_polling_ended_callback,
 	   /* Custom argument. */
 	   kbd_dev);
@@ -169,5 +169,5 @@
 	 * Create new fibril for auto-repeat
 	 */
-	fid_t fid = fibril_create(usbhid_kbd_repeat_fibril, kbd_dev);
+	fid_t fid = fibril_create(usb_kbd_repeat_fibril, kbd_dev);
 	if (fid == 0) {
 		usb_log_error("Failed to start fibril for KBD auto-repeat");
@@ -233,5 +233,5 @@
         .name = NAME,
         .ops = &usbhid_driver_ops,
-        .endpoints = usbhid_kbd_endpoints
+        .endpoints = usb_kbd_endpoints
 };
 
