Index: .bzrignore
===================================================================
--- .bzrignore	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ .bzrignore	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -7,4 +7,8 @@
 *.map
 *.disasm
+*.lo
+*.la
+*.so.*
+*.so0
 _link.ld
 ./*.iso
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/Makefile.common	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -131,4 +131,9 @@
 	endif
 endif
+# Build static whenever we use libusb because that library uses 
+# thread local variables
+ifneq ($(findstring usb, $(LIBS)),)
+	STATIC_BUILD = y
+endif
 
 ifeq ($(STATIC_BUILD), y)
Index: uspace/app/lsusb/main.c
===================================================================
--- uspace/app/lsusb/main.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/app/lsusb/main.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -45,5 +45,5 @@
 #include <devmap.h>
 #include <usb/dev/hub.h>
-#include <usb/host.h>
+#include <usb/hc.h>
 
 #define NAME "lsusb"
Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/app/mkbd/main.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -45,6 +45,5 @@
 #include <devmap.h>
 #include <usb/dev/hub.h>
-#include <usb/host.h>
-#include <usb/driver.h>
+#include <usb/hc.h>
 #include <usb/dev/pipes.h>
 
@@ -173,5 +172,5 @@
 		/* Try to get its address. */
 		if (!addr_found) {
-			addr = usb_device_get_assigned_address(dev_handle);
+			addr = usb_hc_get_address_by_handle(dev_handle);
 			if (addr >= 0) {
 				addr_found = true;
Index: uspace/app/usbinfo/main.c
===================================================================
--- uspace/app/usbinfo/main.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/app/usbinfo/main.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -43,122 +43,7 @@
 #include <devman.h>
 #include <devmap.h>
-#include <usb/dev/hc.h>
+#include <usb/hc.h>
 #include <usb/dev/pipes.h>
-#include <usb/host.h>
-#include <usb/driver.h>
 #include "usbinfo.h"
-
-static bool try_parse_class_and_address(const char *path,
-    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
-{
-	size_t class_index;
-	size_t address;
-	int rc;
-	char *ptr;
-
-	rc = str_size_t(path, &ptr, 10, false, &class_index);
-	if (rc != EOK) {
-		return false;
-	}
-	if ((*ptr == ':') || (*ptr == '.')) {
-		ptr++;
-	} else {
-		return false;
-	}
-	rc = str_size_t(ptr, NULL, 10, true, &address);
-	if (rc != EOK) {
-		return false;
-	}
-	rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
-	if (rc != EOK) {
-		return false;
-	}
-	if (out_device_address != NULL) {
-		*out_device_address = (usb_address_t) address;
-	}
-	return true;
-}
-
-static bool resolve_hc_handle_and_dev_addr(const char *devpath,
-    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
-{
-	int rc;
-
-	/* Hack for QEMU to save-up on typing ;-). */
-	if (str_cmp(devpath, "qemu") == 0) {
-		devpath = "/hw/pci0/00:01.2/uhci-rh/usb00_a1";
-	}
-
-	/* Hack for virtual keyboard. */
-	if (str_cmp(devpath, "virt") == 0) {
-		devpath = "/virt/usbhc/usb00_a1/usb00_a2";
-	}
-
-	if (try_parse_class_and_address(devpath,
-	    out_hc_handle, out_device_address)) {
-		return true;
-	}
-
-	char *path = str_dup(devpath);
-	if (path == NULL) {
-		return ENOMEM;
-	}
-
-	devman_handle_t hc = 0;
-	bool hc_found = false;
-	usb_address_t addr = 0;
-	bool addr_found = false;
-
-	/* Remove suffixes and hope that we will encounter device node. */
-	while (str_length(path) > 0) {
-		/* Get device handle first. */
-		devman_handle_t dev_handle;
-		rc = devman_device_get_handle(path, &dev_handle, 0);
-		if (rc != EOK) {
-			free(path);
-			return false;
-		}
-
-		/* Try to find its host controller. */
-		if (!hc_found) {
-			rc = usb_hc_find(dev_handle, &hc);
-			if (rc == EOK) {
-				hc_found = true;
-			}
-		}
-		/* Try to get its address. */
-		if (!addr_found) {
-			addr = usb_device_get_assigned_address(dev_handle);
-			if (addr >= 0) {
-				addr_found = true;
-			}
-		}
-
-		/* Speed-up. */
-		if (hc_found && addr_found) {
-			break;
-		}
-
-		/* Remove the last suffix. */
-		char *slash_pos = str_rchr(path, '/');
-		if (slash_pos != NULL) {
-			*slash_pos = 0;
-		}
-	}
-
-	free(path);
-
-	if (hc_found && addr_found) {
-		if (out_hc_handle != NULL) {
-			*out_hc_handle = hc;
-		}
-		if (out_device_address != NULL) {
-			*out_device_address = addr;
-		}
-		return true;
-	} else {
-		return false;
-	}
-}
 
 static void print_usage(char *app_name)
@@ -300,7 +185,7 @@
 		devman_handle_t hc_handle = 0;
 		usb_address_t dev_addr = 0;
-		bool found = resolve_hc_handle_and_dev_addr(devpath,
-		    &hc_handle, &dev_addr);
-		if (!found) {
+		int rc = usb_resolve_device_handle(devpath,
+		    &hc_handle, &dev_addr, NULL);
+		if (rc != EOK) {
 			fprintf(stderr, NAME ": device `%s' not found "
 			    "or not of USB kind, skipping.\n",
Index: uspace/drv/uhci-rhd/port.h
===================================================================
--- uspace/drv/uhci-rhd/port.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/drv/uhci-rhd/port.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -38,5 +38,5 @@
 #include <fibril.h>
 #include <ddf/driver.h>
-#include <usb/dev/hc.h> /* usb_hc_connection_t */
+#include <usb/hc.h> /* usb_hc_connection_t */
 
 typedef uint16_t port_status_t;
Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usb/Makefile	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -37,7 +37,7 @@
 	src/ddfiface.c \
 	src/debug.c \
-	src/driver.c \
 	src/dump.c \
-	src/host.c \
+	src/hc.c \
+	src/resolve.c \
 	src/usb.c
 
Index: pace/lib/usb/include/usb/driver.h
===================================================================
--- uspace/lib/usb/include/usb/driver.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * Common definitions for USB drivers.
- */
-#ifndef LIBUSB_DRIVER_H_
-#define LIBUSB_DRIVER_H_
-
-#include <sys/types.h>
-#include <ipc/devman.h>
-
-int usb_hc_find(devman_handle_t, devman_handle_t *);
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usb/include/usb/hc.h
===================================================================
--- uspace/lib/usb/include/usb/hc.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
+++ uspace/lib/usb/include/usb/hc.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusb
+ * @{
+ */
+/** @file
+ * General communication with host controller driver.
+ */
+#ifndef LIBUSB_HC_H_
+#define LIBUSB_HC_H_
+
+#include <sys/types.h>
+#include <ipc/devman.h>
+#include <ddf/driver.h>
+#include <bool.h>
+#include <usb/usb.h>
+
+/** Connection to the host controller driver. */
+typedef struct {
+	/** Devman handle of the host controller. */
+	devman_handle_t hc_handle;
+	/** Phone to the host controller. */
+	int hc_phone;
+} usb_hc_connection_t;
+
+int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
+    ddf_dev_t *);
+int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
+
+int usb_hc_connection_open(usb_hc_connection_t *);
+bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
+int usb_hc_connection_close(usb_hc_connection_t *);
+int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
+    devman_handle_t *);
+
+int usb_hc_get_address_by_handle(devman_handle_t);
+
+int usb_hc_find(devman_handle_t, devman_handle_t *);
+
+int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *,
+    devman_handle_t *);
+
+int usb_ddf_get_hc_handle_by_class(size_t, devman_handle_t *);
+
+
+#endif
+/**
+ * @}
+ */
Index: pace/lib/usb/include/usb/host.h
===================================================================
--- uspace/lib/usb/include/usb/host.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * Host controller common functions.
- */
-#ifndef LIBUSB_HOST_H_
-#define LIBUSB_HOST_H_
-
-#include <sys/types.h>
-#include <ipc/devman.h>
-
-int usb_ddf_get_hc_handle_by_class(size_t, devman_handle_t *);
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usb/src/ddfiface.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -37,5 +37,5 @@
 #include <async.h>
 #include <usb/ddfiface.h>
-#include <usb/driver.h>
+#include <usb/hc.h>
 #include <usb/debug.h>
 #include <errno.h>
Index: pace/lib/usb/src/driver.c
===================================================================
--- uspace/lib/usb/src/driver.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- *
- */
-#include <devman.h>
-#include <dev_iface.h>
-#include <usb_iface.h>
-#include <usb/driver.h>
-#include <errno.h>
-
-
-/** Find host controller handle that is ancestor of given device.
- *
- * @param[in] device_handle Device devman handle.
- * @param[out] hc_handle Where to store handle of host controller
- *	controlling device with @p device_handle handle.
- * @return Error code.
- */
-int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
-{
-	int parent_phone = devman_parent_device_connect(device_handle,
-	    IPC_FLAG_BLOCKING);
-	if (parent_phone < 0) {
-		return parent_phone;
-	}
-
-	devman_handle_t h;
-	int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
-
-	async_hangup(parent_phone);
-
-	if (rc != EOK) {
-		return rc;
-	}
-
-	if (hc_handle != NULL) {
-		*hc_handle = h;
-	}
-
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/lib/usb/src/hc.c
===================================================================
--- uspace/lib/usb/src/hc.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
+++ uspace/lib/usb/src/hc.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusb
+ * @{
+ */
+/** @file
+ * General communication with host controller driver (implementation).
+ */
+#include <devman.h>
+#include <async.h>
+#include <dev_iface.h>
+#include <usb_iface.h>
+#include <usbhc_iface.h>
+#include <usb/hc.h>
+#include <usb/debug.h>
+#include <errno.h>
+#include <assert.h>
+
+/** Initialize connection to USB host controller.
+ *
+ * @param connection Connection to be initialized.
+ * @param device Device connecting to the host controller.
+ * @return Error code.
+ */
+int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
+    ddf_dev_t *device)
+{
+	assert(connection);
+
+	if (device == NULL) {
+		return EBADMEM;
+	}
+
+	devman_handle_t hc_handle;
+	int rc = usb_hc_find(device->handle, &hc_handle);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	rc = usb_hc_connection_initialize(connection, hc_handle);
+
+	return rc;
+}
+
+/** Manually initialize connection to USB host controller.
+ *
+ * @param connection Connection to be initialized.
+ * @param hc_handle Devman handle of the host controller.
+ * @return Error code.
+ */
+int usb_hc_connection_initialize(usb_hc_connection_t *connection,
+    devman_handle_t hc_handle)
+{
+	assert(connection);
+
+	connection->hc_handle = hc_handle;
+	connection->hc_phone = -1;
+
+	return EOK;
+}
+
+/** Open connection to host controller.
+ *
+ * @param connection Connection to the host controller.
+ * @return Error code.
+ */
+int usb_hc_connection_open(usb_hc_connection_t *connection)
+{
+	assert(connection);
+
+	if (usb_hc_connection_is_opened(connection)) {
+		return EBUSY;
+	}
+
+	int phone = devman_device_connect(connection->hc_handle, 0);
+	if (phone < 0) {
+		return phone;
+	}
+
+	connection->hc_phone = phone;
+
+	return EOK;
+}
+
+/** Tells whether connection to host controller is opened.
+ *
+ * @param connection Connection to the host controller.
+ * @return Whether connection is opened.
+ */
+bool usb_hc_connection_is_opened(const usb_hc_connection_t *connection)
+{
+	assert(connection);
+
+	return (connection->hc_phone >= 0);
+}
+
+/** Close connection to the host controller.
+ *
+ * @param connection Connection to the host controller.
+ * @return Error code.
+ */
+int usb_hc_connection_close(usb_hc_connection_t *connection)
+{
+	assert(connection);
+
+	if (!usb_hc_connection_is_opened(connection)) {
+		return ENOENT;
+	}
+
+	int rc = async_hangup(connection->hc_phone);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	connection->hc_phone = -1;
+
+	return EOK;
+}
+
+/** Get handle of USB device with given address.
+ *
+ * @param[in] connection Opened connection to host controller.
+ * @param[in] address Address of device in question.
+ * @param[out] handle Where to write the device handle.
+ * @return Error code.
+ */
+int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
+    usb_address_t address, devman_handle_t *handle)
+{
+	if (!usb_hc_connection_is_opened(connection)) {
+		return ENOENT;
+	}
+
+	sysarg_t tmp;
+	int rc = async_req_2_1(connection->hc_phone,
+	    DEV_IFACE_ID(USBHC_DEV_IFACE),
+	    IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
+	    address, &tmp);
+	if ((rc == EOK) && (handle != NULL)) {
+		*handle = tmp;
+	}
+
+	return rc;
+}
+
+/** Tell USB address assigned to device with given handle.
+ *
+ * @param dev_handle Devman handle of the USB device in question.
+ * @return USB address or negative error code.
+ */
+usb_address_t usb_hc_get_address_by_handle(devman_handle_t dev_handle)
+{
+	int parent_phone = devman_parent_device_connect(dev_handle,
+	    IPC_FLAG_BLOCKING);
+	if (parent_phone < 0) {
+		return parent_phone;
+	}
+
+	sysarg_t address;
+
+	int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_ADDRESS,
+	    dev_handle, &address);
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	async_hangup(parent_phone);
+
+	return (usb_address_t) address;
+}
+
+
+/** Get host controller handle by its class index.
+ *
+ * @param class_index Class index for the host controller.
+ * @param hc_handle Where to store the HC handle
+ *	(can be NULL for existence test only).
+ * @return Error code.
+ */
+int usb_ddf_get_hc_handle_by_class(size_t class_index,
+    devman_handle_t *hc_handle)
+{
+	char *class_index_str;
+	devman_handle_t hc_handle_tmp;
+	int rc;
+
+	rc = asprintf(&class_index_str, "%zu", class_index);
+	if (rc < 0) {
+		return ENOMEM;
+	}
+	rc = devman_device_get_handle_by_class("usbhc", class_index_str,
+	    &hc_handle_tmp, 0);
+	free(class_index_str);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (hc_handle != NULL) {
+		*hc_handle = hc_handle_tmp;
+	}
+
+	return EOK;
+}
+
+/** Find host controller handle that is ancestor of given device.
+ *
+ * @param[in] device_handle Device devman handle.
+ * @param[out] hc_handle Where to store handle of host controller
+ *	controlling device with @p device_handle handle.
+ * @return Error code.
+ */
+int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
+{
+	int parent_phone = devman_parent_device_connect(device_handle,
+	    IPC_FLAG_BLOCKING);
+	if (parent_phone < 0) {
+		return parent_phone;
+	}
+
+	devman_handle_t h;
+	int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
+
+	async_hangup(parent_phone);
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (hc_handle != NULL) {
+		*hc_handle = h;
+	}
+
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: pace/lib/usb/src/host.c
===================================================================
--- uspace/lib/usb/src/host.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/**
- * @file
- * Host controller common functions (implementation).
- */
-#include <stdio.h>
-#include <str_error.h>
-#include <errno.h>
-#include <assert.h>
-#include <bool.h>
-#include <usb/host.h>
-#include <usb/descriptor.h>
-#include <devman.h>
-
-/** Get host controller handle by its class index.
- *
- * @param class_index Class index for the host controller.
- * @param hc_handle Where to store the HC handle
- *	(can be NULL for existence test only).
- * @return Error code.
- */
-int usb_ddf_get_hc_handle_by_class(size_t class_index,
-    devman_handle_t *hc_handle)
-{
-	char *class_index_str;
-	devman_handle_t hc_handle_tmp;
-	int rc;
-
-	rc = asprintf(&class_index_str, "%zu", class_index);
-	if (rc < 0) {
-		return ENOMEM;
-	}
-	rc = devman_device_get_handle_by_class("usbhc", class_index_str,
-	    &hc_handle_tmp, 0);
-	free(class_index_str);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	if (hc_handle != NULL) {
-		*hc_handle = hc_handle_tmp;
-	}
-
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/usb/src/resolve.c
===================================================================
--- uspace/lib/usb/src/resolve.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
+++ uspace/lib/usb/src/resolve.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 libusb
+ * @{
+ */
+/** @file
+ *
+ */
+#include <inttypes.h>
+#include <usb/hc.h>
+#include <devman.h>
+#include <errno.h>
+#include <str.h>
+#include <stdio.h>
+
+#define MAX_DEVICE_PATH 1024
+
+static bool try_parse_bus_and_address(const char *path,
+    char **func_start,
+    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
+{
+	size_t class_index;
+	size_t address;
+	int rc;
+	char *ptr;
+
+	rc = str_size_t(path, &ptr, 10, false, &class_index);
+	if (rc != EOK) {
+		return false;
+	}
+	if ((*ptr == ':') || (*ptr == '.')) {
+		ptr++;
+	} else {
+		return false;
+	}
+	rc = str_size_t(ptr, func_start, 10, false, &address);
+	if (rc != EOK) {
+		return false;
+	}
+	rc = usb_ddf_get_hc_handle_by_class(class_index, out_hc_handle);
+	if (rc != EOK) {
+		return false;
+	}
+	if (out_device_address != NULL) {
+		*out_device_address = (usb_address_t) address;
+	}
+	return true;
+}
+
+static int get_device_handle_by_address(devman_handle_t hc_handle, int addr,
+    devman_handle_t *dev_handle)
+{
+	int rc;
+	usb_hc_connection_t conn;
+
+	usb_hc_connection_initialize(&conn, hc_handle);
+	rc = usb_hc_connection_open(&conn);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	rc = usb_hc_get_handle_by_address(&conn, addr, dev_handle);
+
+	usb_hc_connection_close(&conn);
+
+	return rc;
+}
+
+/** Resolve handle and address of USB device from its path.
+ *
+ * This is a wrapper working on best effort principle.
+ * If the resolving fails, if will not give much details about what
+ * is wrong.
+ * Typically, error from this function would be reported to the user
+ * as "bad device specification" or "device does not exist".
+ *
+ * The path can be specified in following format:
+ *  - devman path (e.g. /hw/pci0/.../usb01_a5
+ *  - bus number and device address (e.g. 5.1)
+ *  - bus number, device address and device function (e.g. 2.1/HID0/keyboard)
+ *
+ * @param[in] dev_path Path to the device.
+ * @param[out] out_hc_handle Where to store handle of a parent host controller.
+ * @param[out] out_dev_addr Where to store device (USB) address.
+ * @param[out] out_dev_handle Where to store device handle.
+ * @return Error code.
+ */
+int usb_resolve_device_handle(const char *dev_path, devman_handle_t *out_hc_handle,
+    usb_address_t *out_dev_addr, devman_handle_t *out_dev_handle)
+{
+	if (dev_path == NULL) {
+		return EBADMEM;
+	}
+
+	bool found_hc = false;
+	bool found_addr = false;
+	devman_handle_t hc_handle, dev_handle;
+	usb_address_t dev_addr = -1;
+	int rc;
+	bool is_bus_addr;
+	char *func_start = NULL;
+	char *path = NULL;
+
+	/* First try the BUS.ADDR format. */
+	is_bus_addr = try_parse_bus_and_address(dev_path, &func_start,
+	    &hc_handle, &dev_addr);
+	if (is_bus_addr) {
+		found_hc = true;
+		found_addr = true;
+		/*
+		 * Now get the handle of the device. We will need that
+		 * in both cases. If there is only BUS.ADDR, it will
+		 * be the handle to be returned to the caller, otherwise
+		 * we will need it to resolve the path to which the
+		 * suffix would be appended.
+		 */
+		/* If there is nothing behind the BUS.ADDR, we will
+		 * get the device handle from the host controller.
+		 * Otherwise, we will
+		 */
+		rc = get_device_handle_by_address(hc_handle, dev_addr,
+		    &dev_handle);
+		if (rc != EOK) {
+			return rc;
+		}
+		if (str_length(func_start) > 0) {
+			char tmp_path[MAX_DEVICE_PATH ];
+			rc = devman_get_device_path(dev_handle,
+			    tmp_path, MAX_DEVICE_PATH);
+			if (rc != EOK) {
+				return rc;
+			}
+			rc = asprintf(&path, "%s%s", tmp_path, func_start);
+			if (rc < 0) {
+				return ENOMEM;
+			}
+		} else {
+			/* Everything is resolved. Get out of here. */
+			goto copy_out;
+		}
+	} else {
+		path = str_dup(dev_path);
+		if (path == NULL) {
+			return ENOMEM;
+		}
+	}
+
+	/* First try to get the device handle. */
+	rc = devman_device_get_handle(path, &dev_handle, 0);
+	if (rc != EOK) {
+		free(path);
+		/* Invalid path altogether. */
+		return rc;
+	}
+
+	/* Remove suffixes and hope that we will encounter device node. */
+	while (str_length(path) > 0) {
+		/* Get device handle first. */
+		devman_handle_t tmp_handle;
+		rc = devman_device_get_handle(path, &tmp_handle, 0);
+		if (rc != EOK) {
+			free(path);
+			return rc;
+		}
+
+		/* Try to find its host controller. */
+		if (!found_hc) {
+			rc = usb_hc_find(tmp_handle, &hc_handle);
+			if (rc == EOK) {
+				found_hc = true;
+			}
+		}
+
+		/* Try to get its address. */
+		if (!found_addr) {
+			dev_addr = usb_hc_get_address_by_handle(tmp_handle);
+			if (dev_addr >= 0) {
+				found_addr = true;
+			}
+		}
+
+		/* Speed-up. */
+		if (found_hc && found_addr) {
+			break;
+		}
+
+		/* Remove the last suffix. */
+		char *slash_pos = str_rchr(path, '/');
+		if (slash_pos != NULL) {
+			*slash_pos = 0;
+		}
+	}
+
+	free(path);
+
+	if (!found_addr || !found_hc) {
+		return ENOENT;
+	}
+
+copy_out:
+	if (out_dev_addr != NULL) {
+		*out_dev_addr = dev_addr;
+	}
+	if (out_hc_handle != NULL) {
+		*out_hc_handle = hc_handle;
+	}
+	if (out_dev_handle != NULL) {
+		*out_dev_handle = dev_handle;
+	}
+
+	return EOK;
+}
+
+
+/**
+ * @}
+ */
+
Index: uspace/lib/usbdev/Makefile
===================================================================
--- uspace/lib/usbdev/Makefile	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbdev/Makefile	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -46,6 +46,5 @@
 	src/pipesio.c \
 	src/recognise.c \
-	src/request.c \
-	src/usbdevice.c
+	src/request.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: pace/lib/usbdev/include/usb/dev/hc.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/hc.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusbdev
- * @{
- */
-/** @file
- * General communication between device drivers and host controller driver.
- */
-#ifndef LIBUSBDEV_HC_H_
-#define LIBUSBDEV_HC_H_
-
-#include <sys/types.h>
-#include <ipc/devman.h>
-#include <ddf/driver.h>
-#include <bool.h>
-#include <usb/usb.h>
-
-/** Connection to the host controller driver. */
-typedef struct {
-	/** Devman handle of the host controller. */
-	devman_handle_t hc_handle;
-	/** Phone to the host controller. */
-	int hc_phone;
-} usb_hc_connection_t;
-
-int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
-    ddf_dev_t *);
-int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
-
-int usb_hc_connection_open(usb_hc_connection_t *);
-bool usb_hc_connection_is_opened(const usb_hc_connection_t *);
-int usb_hc_connection_close(usb_hc_connection_t *);
-
-
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbdev/include/usb/dev/hub.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/hub.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbdev/include/usb/dev/hub.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -39,5 +39,5 @@
 
 #include <sys/types.h>
-#include <usb/dev/hc.h>
+#include <usb/hc.h>
 
 int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
@@ -63,6 +63,4 @@
     const usb_hc_attached_device_t *);
 int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
-int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
-    devman_handle_t *);
 
 #endif
Index: uspace/lib/usbdev/include/usb/dev/pipes.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/pipes.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbdev/include/usb/dev/pipes.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -38,5 +38,5 @@
 #include <sys/types.h>
 #include <usb/usb.h>
-#include <usb/dev/hc.h>
+#include <usb/hc.h>
 #include <usb/descriptor.h>
 #include <ipc/devman.h>
@@ -163,5 +163,4 @@
 
 int usb_device_get_assigned_interface(ddf_dev_t *);
-usb_address_t usb_device_get_assigned_address(devman_handle_t);
 
 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
Index: uspace/lib/usbdev/src/hub.c
===================================================================
--- uspace/lib/usbdev/src/hub.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbdev/src/hub.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -120,27 +120,4 @@
 }
 
-/** Get handle of USB device with given address.
- *
- * @param[in] connection Opened connection to host controller.
- * @param[in] address Address of device in question.
- * @param[out] handle Where to write the device handle.
- * @return Error code.
- */
-int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
-    usb_address_t address, devman_handle_t *handle)
-{
-	CHECK_CONNECTION(connection);
-
-	sysarg_t tmp;
-	int rc = async_req_2_1(connection->hc_phone,
-	    DEV_IFACE_ID(USBHC_DEV_IFACE),
-	    IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
-	    address, &tmp);
-	if ((rc == EOK) && (handle != NULL)) {
-		*handle = tmp;
-	}
-
-	return rc;
-}
 
 static void unregister_control_endpoint_on_default_address(
Index: uspace/lib/usbdev/src/pipes.c
===================================================================
--- uspace/lib/usbdev/src/pipes.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbdev/src/pipes.c	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -36,5 +36,5 @@
 #include <usb/dev/pipes.h>
 #include <usb/debug.h>
-#include <usb/driver.h>
+#include <usb/hc.h>
 #include <usbhc_iface.h>
 #include <usb_iface.h>
@@ -97,32 +97,4 @@
 
 	return (int) iface_no;
-}
-
-/** Tell USB address assigned to given device.
- *
- * @param dev_handle Devman handle of the USB device in question.
- * @return USB address or negative error code.
- */
-usb_address_t usb_device_get_assigned_address(devman_handle_t dev_handle)
-{
-	int parent_phone = devman_parent_device_connect(dev_handle,
-	    IPC_FLAG_BLOCKING);
-	if (parent_phone < 0) {
-		return parent_phone;
-	}
-
-	sysarg_t address;
-
-	int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_ADDRESS,
-	    dev_handle, &address);
-
-	if (rc != EOK) {
-		return rc;
-	}
-
-	async_hangup(parent_phone);
-
-	return (usb_address_t) address;
 }
 
Index: pace/lib/usbdev/src/usbdevice.c
===================================================================
--- uspace/lib/usbdev/src/usbdevice.c	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ 	(revision )
@@ -1,147 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusbdev
- * @{
- */
-/** @file
- * General communication between device drivers and host controller driver.
- */
-#include <devman.h>
-#include <async.h>
-#include <usb_iface.h>
-#include <usb/dev/hc.h>
-#include <usb/driver.h>
-#include <usb/debug.h>
-#include <errno.h>
-#include <assert.h>
-
-/** Initialize connection to USB host controller.
- *
- * @param connection Connection to be initialized.
- * @param device Device connecting to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
-    ddf_dev_t *device)
-{
-	assert(connection);
-
-	if (device == NULL) {
-		return EBADMEM;
-	}
-
-	devman_handle_t hc_handle;
-	int rc = usb_hc_find(device->handle, &hc_handle);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	rc = usb_hc_connection_initialize(connection, hc_handle);
-
-	return rc;
-}
-
-/** Manually initialize connection to USB host controller.
- *
- * @param connection Connection to be initialized.
- * @param hc_handle Devman handle of the host controller.
- * @return Error code.
- */
-int usb_hc_connection_initialize(usb_hc_connection_t *connection,
-    devman_handle_t hc_handle)
-{
-	assert(connection);
-
-	connection->hc_handle = hc_handle;
-	connection->hc_phone = -1;
-
-	return EOK;
-}
-
-/** Open connection to host controller.
- *
- * @param connection Connection to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_open(usb_hc_connection_t *connection)
-{
-	assert(connection);
-
-	if (usb_hc_connection_is_opened(connection)) {
-		return EBUSY;
-	}
-
-	int phone = devman_device_connect(connection->hc_handle, 0);
-	if (phone < 0) {
-		return phone;
-	}
-
-	connection->hc_phone = phone;
-
-	return EOK;
-}
-
-/** Tells whether connection to host controller is opened.
- *
- * @param connection Connection to the host controller.
- * @return Whether connection is opened.
- */
-bool usb_hc_connection_is_opened(const usb_hc_connection_t *connection)
-{
-	assert(connection);
-
-	return (connection->hc_phone >= 0);
-}
-
-/** Close connection to the host controller.
- *
- * @param connection Connection to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_close(usb_hc_connection_t *connection)
-{
-	assert(connection);
-
-	if (!usb_hc_connection_is_opened(connection)) {
-		return ENOENT;
-	}
-
-	int rc = async_hangup(connection->hc_phone);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	connection->hc_phone = -1;
-
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/lib/usbhid/include/usb/hid/hid_report_items.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -27,84 +27,326 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
 /** @file
- * @brief USB HID parser.
- */
-#ifndef LIBUSBHID_HID_REPORT_ITEMS_H_
-#define LIBUSBHID_HID_REPORT_ITEMS_H_
+ * @brief USB HID Report descriptor item tags.
+ */
+#ifndef LIBUSB_HID_REPORT_ITEMS_H_
+#define LIBUSB_HID_REPORT_ITEMS_H_
 
 #include <stdint.h>
 
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Item prefix
  */
+
+/** Returns size of item data in bytes */
 #define USB_HID_ITEM_SIZE(data) 	((uint8_t)(data & 0x3))
+
+/** Returns item tag */
 #define USB_HID_ITEM_TAG(data) 		((uint8_t)((data & 0xF0) >> 4))
+
+/** Returns class of item tag */
 #define USB_HID_ITEM_TAG_CLASS(data)	((uint8_t)((data & 0xC) >> 2))
+
+/** Returns if the item is the short item or long item. Long items are not
+ * supported. */
 #define USB_HID_ITEM_IS_LONG(data)	(data == 0xFE)
 
-
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Extended usage macros
  */
+
+/** Recognizes if the given usage is extended (contains also usage page).  */
 #define USB_HID_IS_EXTENDED_USAGE(usage)	((usage & 0xFFFF0000) != 0)
+
+/** Cuts usage page of the extended usage. */
 #define USB_HID_EXTENDED_USAGE_PAGE(usage)	((usage & 0xFFFF0000) >> 16)
+
+/** Cuts usage of the extended usage */
 #define USB_HID_EXTENDED_USAGE(usage)		(usage & 0xFFFF)
 
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Input/Output/Feature Item flags
  */
-/** Constant (1) / Variable (0) */
+/** 
+ * Indicates whether the item is data (0) or a constant (1) value. Data
+ * indicates the item is defining report fields that contain modifiable device
+ * data. Constant indicates the item is a static read-only field in a report
+ * and cannot be modified (written) by the host.
+ */
 #define USB_HID_ITEM_FLAG_CONSTANT(flags) 	((flags & 0x1) == 0x1)
-/** Variable (1) / Array (0) */
+
+/**
+ * Indicates whether the item creates variable (1) or array (0) data fields in
+ * reports. 
+ */
 #define USB_HID_ITEM_FLAG_VARIABLE(flags) 	((flags & 0x2) == 0x2)
-/** Absolute / Relative*/
+
+/**
+ * Indicates whether the data is absolute (0) (based on a fixed origin) or
+ * relative (1) (indicating the change in value from the last report). Mouse
+ * devices usually provide relative data, while tablets usually provide
+ * absolute data.
+ */
 #define USB_HID_ITEM_FLAG_RELATIVE(flags) 	((flags & 0x4) == 0x4)
-/** Wrap / No Wrap */
+
+/**
+ * Indicates whether the data “rolls over” when reaching either the extreme
+ * high or low value. For example, a dial that can spin freely 360 degrees
+ * might output values from 0 to 10. If Wrap is indicated, the next value
+ * reported after passing the 10 position in the increasing direction would be
+ * 0.
+ */
 #define USB_HID_ITEM_FLAG_WRAP(flags)		((flags & 0x8) == 0x8)
+
+/**
+ * Indicates whether the raw data from the device has been processed in some
+ * way, and no longer represents a linear relationship between what is
+ * measured and the data that is reported.
+ */
 #define USB_HID_ITEM_FLAG_LINEAR(flags)		((flags & 0x10) == 0x10)
+
+/**
+ * Indicates whether the control has a preferred state to which it will return
+ * when the user is not physically interacting with the control. Push buttons
+ * (as opposed to toggle buttons) and self- centering joysticks are examples.
+ */
 #define USB_HID_ITEM_FLAG_PREFERRED(flags)	((flags & 0x20) == 0x20)
+
+/**
+ * Indicates whether the control has a state in which it is not sending
+ * meaningful data. One possible use of the null state is for controls that
+ * require the user to physically interact with the control in order for it to
+ * report useful data.
+ */
 #define USB_HID_ITEM_FLAG_POSITION(flags)	((flags & 0x40) == 0x40)
+
+/**
+ * Indicates whether the Feature or Output control's value should be changed
+ * by the host or not.  Volatile output can change with or without host
+ * interaction. To avoid synchronization problems, volatile controls should be
+ * relative whenever possible.
+ */
 #define USB_HID_ITEM_FLAG_VOLATILE(flags)	((flags & 0x80) == 0x80)
+
+/**
+ * Indicates that the control emits a fixed-size stream of bytes. The contents
+ * of the data field are determined by the application. The contents of the
+ * buffer are not interpreted as a single numeric quantity. Report data
+ * defined by a Buffered Bytes item must be aligned on an 8-bit boundary.
+ */
 #define USB_HID_ITEM_FLAG_BUFFERED(flags)	((flags & 0x100) == 0x100)
 
+/*---------------------------------------------------------------------------*/
+
 /* MAIN ITEMS */
-#define USB_HID_TAG_CLASS_MAIN				0x0
-#define USB_HID_REPORT_TAG_INPUT			0x8
-#define USB_HID_REPORT_TAG_OUTPUT			0x9
-#define USB_HID_REPORT_TAG_FEATURE			0xB
+
+/**
+ * Main items are used to either define or group certain types of data fields
+ * within a Report descriptor.
+ */
+#define USB_HID_TAG_CLASS_MAIN			0x0
+
+/**
+ * An Input item describes information about the data provided by one or more
+ * physical controls. An application can use this information to interpret the
+ * data provided by the device. All data fields defined in a single item share
+ * an identical data format.
+ */
+#define USB_HID_REPORT_TAG_INPUT		0x8
+
+/**
+ * The Output item is used to define an output data field in a report. This
+ * item is similar to an Input item except it describes data sent to the
+ * device—for example, LED states.
+ */
+#define USB_HID_REPORT_TAG_OUTPUT		0x9
+
+/**
+ * Feature items describe device configuration information that can be sent to
+ * the device.
+ */
+#define USB_HID_REPORT_TAG_FEATURE		0xB
+
+/**
+ * A Collection item identifies a relationship between two or more data
+ * (Input, Output, or Feature.) 
+ */
 #define USB_HID_REPORT_TAG_COLLECTION		0xA
+
+/**
+ * While the Collection item opens a collection of data, the End Collection
+ * item closes a collection.
+ */
 #define USB_HID_REPORT_TAG_END_COLLECTION	0xC
 
+/*---------------------------------------------------------------------------*/
+
 /* GLOBAL ITEMS */
-#define USB_HID_TAG_CLASS_GLOBAL			0x1
+
+/**
+ * Global items describe rather than define data from a control.
+ */
+#define USB_HID_TAG_CLASS_GLOBAL		0x1
+
+/**
+ * Unsigned integer specifying the current Usage Page. Since a usage are 32
+ * bit values, Usage Page items can be used to conserve space in a report
+ * descriptor by setting the high order 16 bits of a subsequent usages. Any
+ * usage that follows which is defines 16 bits or less is interpreted as a
+ * Usage ID and concatenated with the Usage Page to form a 32 bit Usage.
+ */
 #define USB_HID_REPORT_TAG_USAGE_PAGE		0x0
+
+/** 
+ * Extent value in logical units. This is the minimum value that a variable
+ * or array item will report. For example, a mouse reporting x position values
+ * from 0 to 128 would have a Logical Minimum of 0 and a Logical Maximum of
+ * 128.
+ */
 #define USB_HID_REPORT_TAG_LOGICAL_MINIMUM	0x1
+
+/** 
+ * Extent value in logical units. This is the maximum value that a variable
+ * or array item will report.
+ */
 #define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM	0x2
-#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3
-#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4
+
+/** 
+ * Minimum value for the physical extent of a variable item. This represents
+ * the Logical Minimum with units applied to it.
+ */
+#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 	0x3
+
+/** 
+ * Maximum value for the physical extent of a variable item.
+ */
+#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 	0x4
+
+/** 
+ * Value of the unit exponent in base 10. See the table later in this section
+ * for more information.
+ */
 #define USB_HID_REPORT_TAG_UNIT_EXPONENT	0x5
-#define USB_HID_REPORT_TAG_UNIT				0x6
+
+/** 
+ * Unit values.
+ */
+#define USB_HID_REPORT_TAG_UNIT			0x6
+
+/** 
+ * Unsigned integer specifying the size of the report fields in bits. This
+ * allows the parser to build an item map for the report handler to use.
+ */
 #define USB_HID_REPORT_TAG_REPORT_SIZE		0x7
+
+/** 
+ * Unsigned value that specifies the Report ID. If a Report ID tag is used
+ * anywhere in Report descriptor, all data reports for the device are preceded
+ * by a single byte ID field. All items succeeding the first Report ID tag but
+ * preceding a second Report ID tag are included in a report prefixed by a
+ * 1-byte ID. All items succeeding the second but preceding a third Report ID
+ * tag are included in a second report prefixed by a second ID, and so on.
+ */
 #define USB_HID_REPORT_TAG_REPORT_ID		0x8
+
+/** 
+ * Unsigned integer specifying the number of data fields for the item;
+ * determines how many fields are included in the report for this particular
+ * item (and consequently how many bits are added to the report).
+ */
 #define USB_HID_REPORT_TAG_REPORT_COUNT		0x9
-#define USB_HID_REPORT_TAG_PUSH				0xA
-#define USB_HID_REPORT_TAG_POP				0xB
-
+
+/** 
+ * Places a copy of the global item state table on the stack.
+ */
+#define USB_HID_REPORT_TAG_PUSH			0xA
+
+/** 
+ * Replaces the item state table with the top structure from the stack.
+ */
+#define USB_HID_REPORT_TAG_POP			0xB
+
+/*---------------------------------------------------------------------------*/
 
 /* LOCAL ITEMS */
-#define USB_HID_TAG_CLASS_LOCAL					0x2
-#define USB_HID_REPORT_TAG_USAGE				0x0
-#define USB_HID_REPORT_TAG_USAGE_MINIMUM		0x1
-#define USB_HID_REPORT_TAG_USAGE_MAXIMUM		0x2
-#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX		0x3
+
+/**
+ * Local item tags define characteristics of controls. These items do not
+ * carry over to the next Main item. If a Main item defines more than one
+ * control, it may be preceded by several similar Local item tags. For
+ * example, an Input item may have several Usage tags associated with it, one
+ * for each control.
+ */
+#define USB_HID_TAG_CLASS_LOCAL			0x2
+
+/**
+ * Usage index for an item usage; represents a suggested usage for the item or
+ * collection. In the case where an item represents multiple controls, a Usage
+ * tag may suggest a usage for every variable or element in an array.
+ */
+#define USB_HID_REPORT_TAG_USAGE		0x0
+
+/**
+ * Defines the starting usage associated with an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_USAGE_MINIMUM	0x1
+
+/**
+ * Defines the ending usage associated with an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_USAGE_MAXIMUM	0x2
+
+/**
+ * Determines the body part used for a control. Index points to a designator
+ * in the Physical descriptor.
+ */
+#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX	0x3
+
+/**
+ * Defines the index of the starting designator associated with an array or
+ * bitmap.
+ */
 #define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM	0x4
+
+/**
+ * Defines the index of the ending designator associated with an array or
+ * bitmap.
+ */
 #define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM	0x5
-#define USB_HID_REPORT_TAG_STRING_INDEX			0x7
-#define USB_HID_REPORT_TAG_STRING_MINIMUM		0x8
-#define USB_HID_REPORT_TAG_STRING_MAXIMUM		0x9
-#define USB_HID_REPORT_TAG_DELIMITER			0xA
+
+/**
+ * String index for a String descriptor; allows a string to be associated with
+ * a particular item or control.
+ */
+#define USB_HID_REPORT_TAG_STRING_INDEX		0x7
+
+/**
+ * Specifies the first string index when assigning a group of sequential
+ * strings to controls in an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_STRING_MINIMUM	0x8
+
+/**
+ * Specifies the last string index when assigning a group of sequential
+ * strings to controls in an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_STRING_MAXIMUM	0x9
+
+/**
+ * Defines the beginning or end of a set of local items (1 = open set, 0 =
+ * close set).
+ *
+ * Usages other than the first (most preferred) usage defined are not
+ * accessible by system software.
+ */
+#define USB_HID_REPORT_TAG_DELIMITER		0xA
+
+/*---------------------------------------------------------------------------*/
 
 #endif
Index: uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
@@ -33,6 +33,6 @@
  * USB HID report descriptor and report data parser
  */
-#ifndef LIBUSBHID_HIDDESCRIPTOR_H_
-#define LIBUSBHID_HIDDESCRIPTOR_H_
+#ifndef LIBUSB_HIDDESCRIPTOR_H_
+#define LIBUSB_HIDDESCRIPTOR_H_
 
 #include <stdint.h>
@@ -42,41 +42,43 @@
 #include <usb/hid/hidtypes.h>
 
-
-/*
- * Descriptor parser functions
- */
-
-/** */
 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
                                     const uint8_t *data, size_t size);
 
-/** */
 void usb_hid_free_report(usb_hid_report_t *report);
 
-/** */
 void usb_hid_descriptor_print(usb_hid_report_t *report);
 
+int usb_hid_report_init(usb_hid_report_t *report);
 
-int usb_hid_report_init(usb_hid_report_t *report);
 int usb_hid_report_append_fields(usb_hid_report_t *report, 
                                  usb_hid_report_item_t *report_item);
 
 usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
+
 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
 
 void usb_hid_descriptor_print_list(link_t *head);
+
 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item);
+
 void usb_hid_free_report_list(link_t *head);
+
 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
+
 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
 
 usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
+
+
 #endif
 /**
Index: uspace/lib/usbhid/include/usb/hid/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
@@ -33,6 +33,6 @@
  * USB HID report descriptor and report data parser
  */
-#ifndef LIBUSBHID_HIDPATH_H_
-#define LIBUSBHID_HIDPATH_H_
+#ifndef LIBUSB_HIDPATH_H_
+#define LIBUSB_HIDPATH_H_
 
 #include <usb/hid/hidparser.h>
@@ -40,73 +40,97 @@
 #include <adt/list.h>
 
+
+/*---------------------------------------------------------------------------*/
 /**
- * Description of path of usage pages and usages in report descriptor
+ * Flags of usage paths comparison modes.
+ *
  */
-/** Wanted usage path must be exactly the same as the searched one */
+/** Wanted usage path must be exactly the same as the searched one.
+ * This option cannot be combined with the others. 
+ */
 #define USB_HID_PATH_COMPARE_STRICT		0
-/** Wanted usage path must be the suffix in the searched one */
+
+/**
+ * Wanted usage path must be the suffix in the searched one.
+ */
 #define USB_HID_PATH_COMPARE_END		1
-/** */
+
+/** 
+ * Only usage page are compared along the usage path. 
+ * This option can be combined with others. 
+ */
 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	2
-/** Searched usage page must be prefix of the other one */
+
+/** 
+ * Searched usage page must be prefix of the other one.
+ */
 #define USB_HID_PATH_COMPARE_BEGIN		4
-/** Searched couple of usage page and usage can be anywhere in usage path */
+
+/** 
+ * Searched couple of usage page and usage can be anywhere in usage path.
+ * This option is deprecated.
+ */
 #define USB_HID_PATH_COMPARE_ANYWHERE		8
 
-
-/** Collection usage path structure */
+/*----------------------------------------------------------------------------*/
+/** 
+ * Item of usage path structure. Last item of linked list describes one item
+ * in report, the others describe superior Collection tags. Usage and Usage
+ * page of report item can be changed due to data in report. 
+ */
 typedef struct {
-	/** */
+	/** Usage page of report item. Zero when usage page can be changed. */
 	uint32_t usage_page;
-	/** */	
+	/** Usage of report item. Zero when usage can be changed. */	
 	uint32_t usage;
 
+	/** Attribute of Collection tag in report descriptor*/
 	uint8_t flags;
-	/** */
+
+	/** Linked list structure*/
 	link_t link;
 } usb_hid_report_usage_path_t;
 
-/** */
+
+/*---------------------------------------------------------------------------*/
+/** 
+ * USB HID usage path structure.
+ * */
 typedef struct {
-	/** */	
+	/** Length of usage path */	
 	int depth;	
+
+	/** Report id. Zero is reserved and means that report id is not used. */
 	uint8_t report_id;
 	
-	/** */	
+	/** Linked list structure. */	
 	link_t link; /* list */
 
-	link_t head; /* head of list of usage paths */
+	/** Head of the list of usage path items. */
+	link_t head;
 
 } usb_hid_report_path_t;
 
-/** */
+/*---------------------------------------------------------------------------*/
 usb_hid_report_path_t *usb_hid_report_path(void);
 
-/** */
 void usb_hid_report_path_free(usb_hid_report_path_t *path);
 
-/** */
 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 
                                       uint8_t report_id);
 
-/** */
 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
                                     int32_t usage_page, int32_t usage);
 
-/** */
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
 
-/** */
 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
 
-/** */
 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
                                   int32_t tag, int32_t data);
 
-/** */
 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
                                       usb_hid_report_path_t *path, int flags);
 
-/** */
 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
 
Index: uspace/lib/usbhid/include/usb/hid/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision 563ead9c368591330423b755226a950d0f735d2e)
+++ uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision fcbcaae942a73b291d86a5f577ce215f8ace8f1c)
@@ -27,22 +27,51 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
 /** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSBHID_HIDTYPES_H_
-#define LIBUSBHID_HIDTYPES_H_
+ * Basic data structures for USB HID Report descriptor and report parser.
+ */
+#ifndef LIBUSB_HIDTYPES_H_
+#define LIBUSB_HIDTYPES_H_
 
 #include <stdint.h>
 #include <adt/list.h>
 
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Maximum amount of specified usages for one report item
+ */
 #define USB_HID_MAX_USAGES	0xffff
 
-#define USB_HID_UINT32_TO_INT32(x, size)	((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
-#define USB_HID_INT32_TO_UINT32(x, size)	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
-
-
+/**
+ * Converts integer from unsigned two's complement format format to signed
+ * one.
+ *
+ * @param x Number to convert
+ * @param size Length of the unsigned number in bites
+ * @return signed int
+ */
+#define USB_HID_UINT32_TO_INT32(x, size)	\
+	((((x) & (1 << ((size) - 1))) != 0) ?   \
+	 -(~((x) - 1) & ((1 << size) - 1)) : (x))
+
+/**
+ * Convert integer from signed format to unsigned. If number is negative the
+ * two's complement format is used.
+ *
+ * @param x Number to convert
+ * @param size Length of result number in bites
+ * @return unsigned int
+ */
+#define USB_HID_INT32_TO_UINT32(x, size)	\
+	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
+
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Report type
+ */
 typedef enum {
 	USB_HID_REPORT_TYPE_INPUT = 1,
@@ -51,62 +80,124 @@
 } usb_hid_report_type_t;
 
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of all reports described in one report descriptor.
+ */
 typedef struct {
-	/** */
+	/** Count of available reports. */
 	int report_count;
-	link_t reports;		/** list of usb_hid_report_description_t */
-
+
+	/** Head of linked list of description of reports. */
+	link_t reports;
+
+	/** Head of linked list of all used usage/collection paths. */
 	link_t collection_paths;
+
+	/** Length of list of usage paths. */
 	int collection_paths_count;
 
+	/** Flag whether report ids are used. */
 	int use_report_ids;
+
+	/** Report id of last parsed report. */
 	uint8_t last_report_id;
 	
 } usb_hid_report_t;
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of one concrete report
+ */
 typedef struct {
+	/** Report id. Zero when no report id is used. */
 	uint8_t report_id;
+
+	/** Type of report */
 	usb_hid_report_type_t type;
 
+	/** Bit length of the report */
 	size_t bit_length;
+
+	/** Number of items in report */
 	size_t item_length;
 	
-	link_t report_items;	/** list of report items (fields) */
-
+	/** Linked list of report items in report */
+	link_t report_items;
+
+	/** Linked list of descriptions. */
 	link_t link;
 } usb_hid_report_description_t;
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of one field/item in report 
+ */
 typedef struct {
-
+	/** Bit offset of the field */
 	int offset;
+
+	/** Bit size of the field */
 	size_t size;
 
+	/** Usage page. Zero when usage page can be changed. */
 	uint16_t usage_page;
+
+	/** Usage. Zero when usage can be changed. */
 	uint16_t usage;
 
+	/** Item's attributes */
 	uint8_t item_flags;
+
+	/** Usage/Collection path of the field. */
 	usb_hid_report_path_t *collection_path;
 
+	/** 
+	 * The lowest valid logical value (value with the device operates)
+	 */
 	int32_t logical_minimum;
+
+	/**
+	 * The greatest valid logical value
+	 */
 	int32_t logical_maximum;
+
+	/**
+	 * The lowest valid physical value (value with the system operates)
+	 */
 	int32_t physical_minimum;
+
+	/** The greatest valid physical value */
 	int32_t physical_maximum;
+
+	/** The lowest valid usage index */
 	int32_t usage_minimum;
+
+	/** The greatest valid usage index */
 	int32_t usage_maximum;
+	
+	/** Unit of the value */
 	uint32_t unit;
+
+	/** Unit exponent */
 	uint32_t unit_exponent;
 
+	/** Array of possible usages */
 	uint32_t *usages;
+
+	/** Size of the array of usages */
 	size_t usages_count;
 
+	/** Parsed value */
 	int32_t value;
 
+	/** List to another report items */
 	link_t link;
 } usb_hid_report_field_t;
 
-
-
-/**
- * state table
+/*---------------------------------------------------------------------------*/
+
+/**
+ * State table for report descriptor parsing
  */
 typedef struct {
@@ -114,73 +205,84 @@
 	int32_t id;
 	
-	/** */
+	/** Extended usage page */
 	uint16_t extended_usage_page;
+
+	/** Array of usages specified for this item */
 	uint32_t usages[USB_HID_MAX_USAGES];
+	
+	/** Length of usages array */
 	int usages_count;
 
-	/** */
+	/** Usage page*/
 	uint32_t usage_page;
 
-	/** */	
+	/** Minimum valid usage index */	
 	int32_t usage_minimum;
-	/** */	
+	
+	/** Maximum valid usage index */	
 	int32_t usage_maximum;
-	/** */	
+	
+	/** Minimum valid logical value */	
 	int32_t logical_minimum;
-	/** */	
+	
+	/** Maximum valid logical value */	
 	int32_t logical_maximum;
-	/** */	
+
+	/** Length of the items in bits*/	
 	int32_t size;
-	/** */	
+
+	/** COunt of items*/	
 	int32_t count;
-	/** */	
+
+	/**  Bit offset of the item in report */	
 	size_t offset;
-	/** */	
+
+	/** Unit exponent */	
 	int32_t unit_exponent;
-	/** */	
+	/** Unit of the value */	
 	int32_t unit;
 
-	/** */
+	/** String index */
 	uint32_t string_index;
-	/** */	
+
+	/** Minimum valid string index */	
 	uint32_t string_minimum;
-	/** */	
+
+	/** Maximum valid string index */	
 	uint32_t string_maximum;
-	/** */	
+
+	/** The designator index */	
 	uint32_t designator_index;
-	/** */	
+
+	/** Minimum valid designator value*/	
 	uint32_t designator_minimum;
-	/** */	
+
+	/** Maximum valid designator value*/	
 	uint32_t designator_maximum;
-	/** */	
+
+	/** Minimal valid physical value*/	
 	int32_t physical_minimum;
-	/** */	
+
+	/** Maximal valid physical value */	
 	int32_t physical_maximum;
 
-	/** */	
+	/** Items attributes*/	
 	uint8_t item_flags;
 
+	/** Report type */
 	usb_hid_report_type_t type;
 
 	/** current collection path*/	
 	usb_hid_report_path_t *usage_path;
-	/** */	
+
+	/** Unused*/	
 	link_t link;
 
 	int in_delimiter;
 } usb_hid_report_item_t;
-
-/** HID parser callbacks for IN items. */
-typedef struct {
-	/** Callback for keyboard.
-	 *
-	 * @param key_codes Array of pressed key (including modifiers).
-	 * @param count Length of @p key_codes.
-	 * @param arg Custom argument.
-	 */
-	void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);
-} usb_hid_report_in_callbacks_t;
-
-
+/*---------------------------------------------------------------------------*/
+/**
+ * Enum of the keyboard modifiers 
+ */
 typedef enum {
 	USB_HID_MOD_LCTRL = 0x01,
@@ -206,4 +308,6 @@
 	USB_HID_MOD_RGUI
 };
+/*---------------------------------------------------------------------------*/
+
 
 #endif
