Index: pace/app/netstart/self_test.c
===================================================================
--- uspace/app/netstart/self_test.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ 	(revision )
@@ -1,334 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 net
- * @{
- */
-
-/** @file
- * Networking self-tests implementation.
- *
- */
-
-#include <errno.h>
-#include <malloc.h>
-#include <stdio.h>
-
-#include <net_checksum.h>
-#include <adt/int_map.h>
-#include <adt/char_map.h>
-#include <adt/generic_char_map.h>
-#include <adt/measured_strings.h>
-#include <adt/dynamic_fifo.h>
-
-#include "self_test.h"
-
-/** Test the statement, compare the result and evaluate.
- *
- * @param[in] statement The statement to test.
- * @param[in] result    The expected result.
- *
- */
-#define TEST(statement, result) \
-	do { \
-		printf("\n\t%s == %s", #statement, #result); \
-		if ((statement) != (result)) { \
-			printf("\tfailed\n"); \
-			fprintf(stderr, "\nNetwork self-test failed\n"); \
-			return EINVAL; \
-		} else \
-			printf("\tOK"); \
-	} while (0)
-
-#define XMALLOC(var, type) \
-	do { \
-		(var) = (type *) malloc(sizeof(type)); \
-		if ((var) == NULL) { \
-			fprintf(stderr, "\nMemory allocation error\n"); \
-			return ENOMEM; \
-		} \
-	} while (0)
-
-GENERIC_CHAR_MAP_DECLARE(int_char_map, int);
-GENERIC_CHAR_MAP_IMPLEMENT(int_char_map, int);
-
-GENERIC_FIELD_DECLARE(int_field, int);
-GENERIC_FIELD_IMPLEMENT(int_field, int);
-
-INT_MAP_DECLARE(int_map, int);
-INT_MAP_IMPLEMENT(int_map, int);
-
-/** Self-test start function.
- *
- * Run all self-tests.
- *
- * @returns EOK on success.
- * @returns The first error occurred.
- *
- */
-int self_test(void)
-{
-	printf("Running networking self-tests\n");
-	
-	printf("\nChar map test");
-	char_map_t cm;
-	
-	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
-	TEST(char_map_initialize(&cm), EOK);
-	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
-	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
-	TEST(char_map_add(&cm, "bla", 0, 1), EOK);
-	TEST(char_map_find(&cm, "bla", 0), 1);
-	TEST(char_map_add(&cm, "bla", 0, 10), EEXISTS);
-	TEST(char_map_update(&cm, "bla", 0, 2), EOK);
-	TEST(char_map_find(&cm, "bla", 0), 2);
-	TEST(char_map_update(&cm, "ucho", 0, 2), EOK);
-	TEST(char_map_exclude(&cm, "bla", 0), 2);
-	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
-	TEST(char_map_find(&cm, "ucho", 0), 2);
-	TEST(char_map_update(&cm, "ucho", 0, 3), EOK);
-	TEST(char_map_find(&cm, "ucho", 0), 3);
-	TEST(char_map_add(&cm, "blabla", 0, 5), EOK);
-	TEST(char_map_find(&cm, "blabla", 0), 5);
-	TEST(char_map_add(&cm, "bla", 0, 6), EOK);
-	TEST(char_map_find(&cm, "bla", 0), 6);
-	TEST(char_map_exclude(&cm, "bla", 0), 6);
-	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
-	TEST(char_map_find(&cm, "blabla", 0), 5);
-	TEST(char_map_add(&cm, "auto", 0, 7), EOK);
-	TEST(char_map_find(&cm, "auto", 0), 7);
-	TEST(char_map_add(&cm, "kara", 0, 8), EOK);
-	TEST(char_map_find(&cm, "kara", 0), 8);
-	TEST(char_map_add(&cm, "nic", 0, 9), EOK);
-	TEST(char_map_find(&cm, "nic", 0), 9);
-	TEST(char_map_find(&cm, "blabla", 0), 5);
-	TEST(char_map_add(&cm, "micnicnic", 5, 9), EOK);
-	TEST(char_map_find(&cm, "micni", 0), 9);
-	TEST(char_map_find(&cm, "micnicn", 5), 9);
-	TEST(char_map_add(&cm, "\x10\x0\x2\x2", 4, 15), EOK);
-	TEST(char_map_find(&cm, "\x10\x0\x2\x2", 4), 15);
-	
-	TEST((char_map_destroy(&cm), EOK), EOK);
-	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
-	
-	printf("\nCRC computation test");
-	uint32_t value;
-	
-	TEST(value = ~compute_crc32(~0, "123456789", 8 * 9), 0xcbf43926);
-	TEST(value = ~compute_crc32(~0, "1", 8), 0x83dcefb7);
-	TEST(value = ~compute_crc32(~0, "12", 8 * 2), 0x4f5344cd);
-	TEST(value = ~compute_crc32(~0, "123", 8 * 3), 0x884863d2);
-	TEST(value = ~compute_crc32(~0, "1234", 8 * 4), 0x9be3e0a3);
-	TEST(value = ~compute_crc32(~0, "12345678", 8 * 8), 0x9ae0daaf);
-	TEST(value = ~compute_crc32(~0, "ahoj pane", 8 * 9), 0x5fc3d706);
-	
-	printf("\nDynamic fifo test");
-	dyn_fifo_t fifo;
-	
-	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
-	TEST(dyn_fifo_initialize(&fifo, 1), EOK);
-	TEST(dyn_fifo_push(&fifo, 1, 0), EOK);
-	TEST(dyn_fifo_pop(&fifo), 1);
-	TEST(dyn_fifo_pop(&fifo), ENOENT);
-	TEST(dyn_fifo_push(&fifo, 2, 1), EOK);
-	TEST(dyn_fifo_push(&fifo, 3, 1), ENOMEM);
-	TEST(dyn_fifo_push(&fifo, 3, 0), EOK);
-	TEST(dyn_fifo_pop(&fifo), 2);
-	TEST(dyn_fifo_pop(&fifo), 3);
-	TEST(dyn_fifo_push(&fifo, 4, 2), EOK);
-	TEST(dyn_fifo_push(&fifo, 5, 2), EOK);
-	TEST(dyn_fifo_push(&fifo, 6, 2), ENOMEM);
-	TEST(dyn_fifo_push(&fifo, 6, 5), EOK);
-	TEST(dyn_fifo_push(&fifo, 7, 5), EOK);
-	TEST(dyn_fifo_pop(&fifo), 4);
-	TEST(dyn_fifo_pop(&fifo), 5);
-	TEST(dyn_fifo_push(&fifo, 8, 5), EOK);
-	TEST(dyn_fifo_push(&fifo, 9, 5), EOK);
-	TEST(dyn_fifo_push(&fifo, 10, 6), EOK);
-	TEST(dyn_fifo_push(&fifo, 11, 6), EOK);
-	TEST(dyn_fifo_pop(&fifo), 6);
-	TEST(dyn_fifo_pop(&fifo), 7);
-	TEST(dyn_fifo_push(&fifo, 12, 6), EOK);
-	TEST(dyn_fifo_push(&fifo, 13, 6), EOK);
-	TEST(dyn_fifo_push(&fifo, 14, 6), ENOMEM);
-	TEST(dyn_fifo_push(&fifo, 14, 8), EOK);
-	TEST(dyn_fifo_pop(&fifo), 8);
-	TEST(dyn_fifo_pop(&fifo), 9);
-	TEST(dyn_fifo_pop(&fifo), 10);
-	TEST(dyn_fifo_pop(&fifo), 11);
-	TEST(dyn_fifo_pop(&fifo), 12);
-	TEST(dyn_fifo_pop(&fifo), 13);
-	TEST(dyn_fifo_pop(&fifo), 14);
-	TEST(dyn_fifo_destroy(&fifo), EOK);
-	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
-	
-	printf("\nGeneric char map test");
-	
-	int *x;
-	int *y;
-	int *z;
-	int *u;
-	int *v;
-	int *w;
-	
-	XMALLOC(x, int);
-	XMALLOC(y, int);
-	XMALLOC(z, int);
-	XMALLOC(u, int);
-	XMALLOC(v, int);
-	XMALLOC(w, int);
-	
-	int_char_map_t icm;
-	icm.magic = 0;
-	
-	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
-	TEST(int_char_map_initialize(&icm), EOK);
-	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
-	TEST(int_char_map_find(&icm, "bla", 0), NULL);
-	TEST(int_char_map_add(&icm, "bla", 0, x), EOK);
-	TEST(int_char_map_find(&icm, "bla", 0), x);
-	TEST(int_char_map_add(&icm, "bla", 0, y), EEXISTS);
-	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
-	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
-	TEST(int_char_map_add(&icm, "blabla", 0, v), EOK);
-	TEST(int_char_map_find(&icm, "blabla", 0), v);
-	TEST(int_char_map_add(&icm, "bla", 0, w), EOK);
-	TEST(int_char_map_find(&icm, "bla", 0), w);
-	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
-	TEST(int_char_map_find(&icm, "bla", 0), NULL);
-	TEST(int_char_map_find(&icm, "blabla", 0), v);
-	TEST(int_char_map_add(&icm, "auto", 0, u), EOK);
-	TEST(int_char_map_find(&icm, "auto", 0), u);
-	TEST((int_char_map_destroy(&icm), EOK), EOK);
-	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
-	
-	printf("\nGeneric field test");
-	
-	XMALLOC(x, int);
-	XMALLOC(y, int);
-	XMALLOC(z, int);
-	XMALLOC(u, int);
-	XMALLOC(v, int);
-	XMALLOC(w, int);
-	
-	int_field_t gf;
-	gf.magic = 0;
-	
-	TEST(int_field_add(&gf, x), EINVAL);
-	TEST(int_field_count(&gf), -1);
-	TEST(int_field_initialize(&gf), EOK);
-	TEST(int_field_count(&gf), 0);
-	TEST(int_field_get_index(&gf, 1), NULL);
-	TEST(int_field_add(&gf, x), 0);
-	TEST(int_field_get_index(&gf, 0), x);
-	TEST((int_field_exclude_index(&gf, 0), EOK), EOK);
-	TEST(int_field_get_index(&gf, 0), NULL);
-	TEST(int_field_add(&gf, y), 1);
-	TEST(int_field_get_index(&gf, 1), y);
-	TEST(int_field_add(&gf, z), 2);
-	TEST(int_field_get_index(&gf, 2), z);
-	TEST(int_field_get_index(&gf, 1), y);
-	TEST(int_field_count(&gf), 3);
-	TEST(int_field_add(&gf, u), 3);
-	TEST(int_field_get_index(&gf, 3), u);
-	TEST(int_field_add(&gf, v), 4);
-	TEST(int_field_get_index(&gf, 4), v);
-	TEST(int_field_add(&gf, w), 5);
-	TEST(int_field_get_index(&gf, 5), w);
-	TEST(int_field_count(&gf), 6);
-	TEST((int_field_exclude_index(&gf, 1), EOK), EOK);
-	TEST(int_field_get_index(&gf, 1), NULL);
-	TEST(int_field_get_index(&gf, 3), u);
-	TEST((int_field_exclude_index(&gf, 7), EOK), EOK);
-	TEST(int_field_get_index(&gf, 3), u);
-	TEST(int_field_get_index(&gf, 5), w);
-	TEST((int_field_exclude_index(&gf, 4), EOK), EOK);
-	TEST(int_field_get_index(&gf, 4), NULL);
-	TEST((int_field_destroy(&gf), EOK), EOK);
-	TEST(int_field_count(&gf), -1);
-	
-	printf("\nInt map test");
-	
-	XMALLOC(x, int);
-	XMALLOC(y, int);
-	XMALLOC(z, int);
-	XMALLOC(u, int);
-	XMALLOC(v, int);
-	XMALLOC(w, int);
-	
-	int_map_t im;
-	im.magic = 0;
-	
-	TEST(int_map_add(&im, 1, x), EINVAL);
-	TEST(int_map_count(&im), -1);
-	TEST(int_map_initialize(&im), EOK);
-	TEST(int_map_count(&im), 0);
-	TEST(int_map_find(&im, 1), NULL);
-	TEST(int_map_add(&im, 1, x), 0);
-	TEST(int_map_find(&im, 1), x);
-	TEST((int_map_exclude(&im, 1), EOK), EOK);
-	TEST(int_map_find(&im, 1), NULL);
-	TEST(int_map_add(&im, 1, y), 1);
-	TEST(int_map_find(&im, 1), y);
-	TEST(int_map_add(&im, 4, z), 2);
-	TEST(int_map_get_index(&im, 2), z);
-	TEST(int_map_find(&im, 4), z);
-	TEST(int_map_find(&im, 1), y);
-	TEST(int_map_count(&im), 3);
-	TEST(int_map_add(&im, 2, u), 3);
-	TEST(int_map_find(&im, 2), u);
-	TEST(int_map_add(&im, 3, v), 4);
-	TEST(int_map_find(&im, 3), v);
-	TEST(int_map_get_index(&im, 4), v);
-	TEST(int_map_add(&im, 6, w), 5);
-	TEST(int_map_find(&im, 6), w);
-	TEST(int_map_count(&im), 6);
-	TEST((int_map_exclude(&im, 1), EOK), EOK);
-	TEST(int_map_find(&im, 1), NULL);
-	TEST(int_map_find(&im, 2), u);
-	TEST((int_map_exclude(&im, 7), EOK), EOK);
-	TEST(int_map_find(&im, 2), u);
-	TEST(int_map_find(&im, 6), w);
-	TEST((int_map_exclude_index(&im, 4), EOK), EOK);
-	TEST(int_map_get_index(&im, 4), NULL);
-	TEST(int_map_find(&im, 3), NULL);
-	TEST((int_map_destroy(&im), EOK), EOK);
-	TEST(int_map_count(&im), -1);
-	
-	printf("\nMeasured strings test");
-	
-	measured_string_ref string =
-	    measured_string_create_bulk("I am a measured string!", 0);
-	printf("\n%x, %s at %x of %d\n", string, string->value, string->value,
-	    string->length);
-	
-	return EOK;
-}
-
-/** @}
- */
Index: pace/app/netstart/self_test.h
===================================================================
--- uspace/app/netstart/self_test.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 net
- * @{
- */
-
-#ifndef __SELF_TEST_H__
-#define __SELF_TEST_H__
-
-extern int self_test(void);
-
-#endif
-
-/** @}
- */
Index: uspace/drv/usbmid/main.c
===================================================================
--- uspace/drv/usbmid/main.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmid/main.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -44,4 +44,9 @@
 #include "usbmid.h"
 
+/** Callback when new MID device is attached to the host.
+ *
+ * @param gen_dev Generic DDF device representing the new device.
+ * @return Error code.
+ */
 static int usbmid_add_device(ddf_dev_t *gen_dev)
 {
@@ -86,8 +91,10 @@
 }
 
+/** USB MID driver ops. */
 static driver_ops_t mid_driver_ops = {
 	.add_device = usbmid_add_device,
 };
 
+/** USB MID driver. */
 static driver_t mid_driver = {
 	.name = NAME,
Index: uspace/drv/usbmid/usbmid.c
===================================================================
--- uspace/drv/usbmid/usbmid.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmid/usbmid.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -67,4 +67,5 @@
 }
 
+/** DDF interface of the child - interface function. */
 static usb_iface_t child_usb_iface = {
 	.get_hc_handle = usb_iface_get_hc_handle_hub_child_impl,
@@ -73,9 +74,10 @@
 };
 
-
+/** Operations for children - interface functions. */
 static ddf_dev_ops_t child_device_ops = {
 	.interfaces[USB_DEV_IFACE] = &child_usb_iface
 };
 
+/** Operations of the device itself. */
 static ddf_dev_ops_t mid_device_ops = {
 	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
Index: uspace/drv/usbmid/usbmid.h
===================================================================
--- uspace/drv/usbmid/usbmid.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmid/usbmid.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -44,4 +44,5 @@
 #define NAME "usbmid"
 
+/** USB MID device container. */
 typedef struct {
 	/** Device container. */
@@ -54,4 +55,6 @@
 } usbmid_device_t;
 
+
+/** Container for single interface in a MID device. */
 typedef struct {
 	/** Function container. */
Index: uspace/drv/usbmouse/init.c
===================================================================
--- uspace/drv/usbmouse/init.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmouse/init.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -101,4 +101,5 @@
 
 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
+/** Device ops for USB mouse. */
 static ddf_dev_ops_t mouse_ops = {
 	.default_handler = default_connection_handler
@@ -135,5 +136,11 @@
 }
 
-
+/** Create USB mouse device.
+ *
+ * The mouse device is stored into <code>dev-&gt;driver_data</code>.
+ *
+ * @param dev Generic device.
+ * @return Error code.
+ */
 int usb_mouse_create(ddf_dev_t *dev)
 {
Index: uspace/drv/usbmouse/main.c
===================================================================
--- uspace/drv/usbmouse/main.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmouse/main.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -39,4 +39,9 @@
 #include <str_error.h>
 
+/** Callback when new mouse device is attached and recognised by DDF.
+ *
+ * @param dev Representation of a generic DDF device.
+ * @return Error code.
+ */
 static int usbmouse_add_device(ddf_dev_t *dev)
 {
@@ -63,8 +68,10 @@
 }
 
+/** USB mouse driver ops. */
 static driver_ops_t mouse_driver_ops = {
 	.add_device = usbmouse_add_device,
 };
 
+/** USB mouse driver. */
 static driver_t mouse_driver = {
 	.name = NAME,
@@ -74,5 +81,5 @@
 int main(int argc, char *argv[])
 {
-	usb_log_enable(USB_LOG_LEVEL_DEBUG2, NAME);
+	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
 
 	return ddf_driver_main(&mouse_driver);
Index: uspace/drv/usbmouse/mouse.c
===================================================================
--- uspace/drv/usbmouse/mouse.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmouse/mouse.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -40,4 +40,12 @@
 #include <ipc/mouse.h>
 
+/** Fibril function for polling the mouse device.
+ *
+ * This function shall not terminate unless the device breaks and fails
+ * to send data (e.g. stalls on data request).
+ *
+ * @param arg ddf_dev_t type representing the mouse device.
+ * @return EOK Always.
+ */
 int usb_mouse_polling_fibril(void *arg)
 {
Index: uspace/drv/usbmouse/mouse.h
===================================================================
--- uspace/drv/usbmouse/mouse.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/drv/usbmouse/mouse.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -43,11 +43,19 @@
 #define NAME "usbmouse"
 
+/** Container for USB mouse device. */
 typedef struct {
+	/** Generic device container. */
 	ddf_dev_t *device;
+	/** Function representing the device. */
 	ddf_fun_t *mouse_fun;
+	/** Representation of connection to the device. */
 	usb_device_connection_t wire;
+	/** Default (zero) control pipe. */
 	usb_endpoint_pipe_t ctrl_pipe;
+	/** Polling (in) pipe. */
 	usb_endpoint_pipe_t poll_pipe;
+	/** Polling interval in microseconds. */
 	suseconds_t poll_interval_us;
+	/** IPC phone to console (consumer). */
 	int console_phone;
 } usb_mouse_t;
Index: uspace/lib/packet/include/net_byteorder.h
===================================================================
--- uspace/lib/packet/include/net_byteorder.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
+++ uspace/lib/packet/include/net_byteorder.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Host - network byte order manipulation functions.
+ */
+
+#ifndef __NET_BYTEORDER_H__
+#define __NET_BYTEORDER_H__
+
+#include <byteorder.h>
+#include <sys/types.h>
+
+
+/** Converts the given short number (16 bit) from the host byte order to the network byte order (big endian).
+ *  @param[in] number The number in the host byte order to be converted.
+ *  @returns The number in the network byte order.
+ */
+#define htons(number)		host2uint16_t_be(number)
+
+/** Converts the given long number (32 bit) from the host byte order to the network byte order (big endian).
+ *  @param[in] number The number in the host byte order to be converted.
+ *  @returns The number in the network byte order.
+ */
+#define htonl(number)		host2uint32_t_be(number)
+
+/** Converts the given short number (16 bit) from the network byte order (big endian) to the host byte order.
+ *  @param[in] number The number in the network byte order to be converted.
+ *  @returns The number in the host byte order.
+ */
+#define ntohs(number) 	uint16_t_be2host(number)
+
+/** Converts the given long number (32 bit) from the network byte order (big endian) to the host byte order.
+ *  @param[in] number The number in the network byte order to be converted.
+ *  @returns The number in the host byte order.
+ */
+#define ntohl(number)		uint32_t_be2host(number)
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/net_err.h
===================================================================
--- uspace/lib/packet/include/net_err.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
+++ uspace/lib/packet/include/net_err.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 net
+ * @{
+ */
+
+/** @file
+ * Common error processing codes and routines.
+ */
+
+#ifndef __NET_ERR_H__
+#define __NET_ERR_H__
+
+#include <errno.h>
+
+#ifdef CONFIG_DEBUG
+	#include <stdio.h>
+	#include <str_error.h>
+#endif
+
+/** An actual stored error code.
+ *
+ */
+#define ERROR_CODE  error_check_return_value
+
+/** An error processing routines declaration.
+ *
+ * This has to be declared in the block where the error processing
+ * is desired.
+ *
+ */
+#define ERROR_DECLARE  int ERROR_CODE
+
+/** Store the value as an error code and checks if an error occurred.
+ *
+ * @param[in] value The value to be checked. May be a function call.
+ * @return False if the value indicates success (EOK).
+ * @return True otherwise.
+ *
+ */
+#ifdef CONFIG_DEBUG
+
+#define ERROR_OCCURRED(value) \
+	(((ERROR_CODE = (value)) != EOK) \
+	&& ({ \
+		fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
+		__FILE__, __LINE__, str_error(ERROR_CODE)); \
+		1; \
+	}))
+
+#else
+
+#define ERROR_OCCURRED(value)  ((ERROR_CODE = (value)) != EOK)
+
+#endif
+
+/** Error propagation
+ *
+ * Check if an error occurred and immediately exit the actual
+ * function returning the error code.
+ *
+ * @param[in] value The value to be checked. May be a function call.
+ *
+ */
+
+#define ERROR_PROPAGATE(value) \
+	if (ERROR_OCCURRED(value)) \
+		return ERROR_CODE
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/socket_errno.h
===================================================================
--- uspace/lib/packet/include/socket_errno.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
+++ uspace/lib/packet/include/socket_errno.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Socket error codes.
+ *  Based on BSD.
+ */
+
+#ifndef __NET_SOCKET_ERR_H__
+#define __NET_SOCKET_ERR_H__
+
+#include <errno.h>
+
+/** @name Socket error codes definitions
+ */
+/*@{*/
+
+////#define EINTR			(-10004)
+////#define EBADF			(-10009)
+//#define EACCES			(-10013)
+//#define EFAULT			(-10014)
+////#define EINVAL			(-10022)
+////#define EMFILE			(-10024)
+//#define EWOULDBLOCK		(-10035)
+
+/** An API function is called while another blocking function is in progress.
+ */
+#define EINPROGRESS		(-10036)
+
+//#define EALREADY		(-10037)
+
+/** The socket identifier is not valid.
+ */
+#define ENOTSOCK		(-10038)
+
+/** The destination address required.
+ */
+#define EDESTADDRREQ	(-10039)
+
+//#define EMSGSIZE		(-10040)
+//#define EPROTOTYPE		(-10041)
+//#define ENOPROTOOPT		(-10042)
+
+/** Protocol is not supported.
+ */
+#define EPROTONOSUPPORT	(-10043)
+
+/** Socket type is not supported.
+ */
+#define ESOCKTNOSUPPORT	(-10044)
+
+//#define EOPNOTSUPP		(-10045)
+
+/** Protocol family is not supported.
+ */
+#define EPFNOSUPPORT	(-10046)
+
+/** Address family is not supported.
+ */
+#define EAFNOSUPPORT	(-10047)
+
+/** Address is already in use.
+ */
+#define EADDRINUSE		(-10048)
+
+//#define EADDRNOTAVAIL	(-10049)
+/* May be reported at any time if the implementation detects an underlying failure.
+ */
+//#define ENETDOWN		(-10050)
+//#define ENETUNREACH		(-10051)
+//#define ENETRESET		(-10052)
+//#define ECONNABORTED	(-10053)
+//#define ECONNRESET		(-10054)
+//#define ENOBUFS			(-10055)
+//#define EISCONN			(-10056)
+
+/** The socket is not connected or bound.
+ */
+#define ENOTCONN		(-10057)
+
+//#define ESHUTDOWN		(-10058)
+//#define ETOOMANYREFS	(-10059)
+//#define ETIMEDOUT		(-10060)
+//#define ECONNREFUSED	(-10061)
+//#define ELOOP			(-10062)
+////#define ENAMETOOLONG	(-10063)
+//#define EHOSTDOWN		(-10064)
+//#define EHOSTUNREACH	(-10065)
+//#define HOST_NOT_FOUND	(-11001)
+
+/** The requested operation was not performed.
+ *  Try again later.
+ */
+#define TRY_AGAIN		(-11002)
+
+//#define NO_RECOVERY		(-11003)
+
+/** No data.
+ */
+#define NO_DATA			(-11004)
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/usb/include/usb/classes/classes.h
===================================================================
--- uspace/lib/usb/include/usb/classes/classes.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/classes/classes.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief USB device classes and subclasses.
+ * USB device classes (generic constants and functions).
  */
 #ifndef LIBUSB_CLASSES_H_
Index: uspace/lib/usb/include/usb/debug.h
===================================================================
--- uspace/lib/usb/include/usb/debug.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/debug.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Debugging related functions.
+ * Debugging related functions.
  */
 #ifndef LIBUSB_DEBUG_H_
@@ -39,7 +39,4 @@
 #include <assert.h>
 
-void usb_dprintf(const char *tag, int level, const char *format, ...);
-void usb_dprintf_enable(const char *tag, int level);
-
 void usb_dump_standard_descriptor(FILE *, const char *, const char *,
     const uint8_t *, size_t);
@@ -47,10 +44,36 @@
 /** Logging level. */
 typedef enum {
+	/** Fatal, unrecoverable, error.
+	 * Such error prevents the driver from working at all.
+	 */
 	USB_LOG_LEVEL_FATAL,
+
+	/** Serious but recoverable error
+	 * Shall be used for errors fatal for single device but not for
+	 * driver itself.
+	 */
 	USB_LOG_LEVEL_ERROR,
+
+	/** Warning.
+	 * Problems from which the driver is able to recover gracefully.
+	 */
 	USB_LOG_LEVEL_WARNING,
+
+	/** Information message.
+	 * This should be the last level that is printed by default to
+	 * the screen.
+	 * Typical usage is to inform that new device was found and what
+	 * are its capabilities.
+	 * Do not use for repetitive actions (such as device polling).
+	 */
 	USB_LOG_LEVEL_INFO,
+
+	/** Debugging message. */
 	USB_LOG_LEVEL_DEBUG,
+
+	/** More detailed debugging message. */
 	USB_LOG_LEVEL_DEBUG2,
+
+	/** Terminating constant for logging levels. */
 	USB_LOG_LEVEL_MAX
 } usb_log_level_t;
@@ -61,19 +84,25 @@
 void usb_log_printf(usb_log_level_t, const char *, ...);
 
+/** Log fatal error. */
 #define usb_log_fatal(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_FATAL, format, ##__VA_ARGS__)
 
+/** Log normal (recoverable) error. */
 #define usb_log_error(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
 
+/** Log warning. */
 #define usb_log_warning(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_WARNING, format, ##__VA_ARGS__)
 
+/** Log informational message. */
 #define usb_log_info(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
 
+/** Log debugging message. */
 #define usb_log_debug(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
 
+/** Log verbose debugging message. */
 #define usb_log_debug2(format, ...) \
 	usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
Index: uspace/lib/usb/include/usb/descriptor.h
===================================================================
--- uspace/lib/usb/include/usb/descriptor.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/descriptor.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Standard USB descriptors.
+ * Standard USB descriptors.
  */
 #ifndef LIBUSB_DESCRIPTOR_H_
@@ -83,5 +83,5 @@
 	/** Product descriptor index. */
 	uint8_t str_product;
-	/** Device serial number desriptor index. */
+	/** Device serial number descriptor index. */
 	uint8_t str_serial_number;
 	/** Number of possible configurations. */
@@ -167,7 +167,4 @@
 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
 
-
-/* TODO: string descriptors. */
-
 #endif
 /**
Index: uspace/lib/usb/include/usb/dp.h
===================================================================
--- uspace/lib/usb/include/usb/dp.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/dp.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief USB descriptor parser.
+ * USB descriptor parser.
  */
 #ifndef LIBUSB_DP_H_
@@ -40,6 +40,15 @@
 #include <usb/descriptor.h>
 
+/** USB descriptors nesting.
+ * The nesting describes the logical tree USB descriptors form
+ * (e.g. that endpoint descriptor belongs to interface or that
+ * interface belongs to configuration).
+ *
+ * See usb_descriptor_type_t for descriptor constants.
+ */
 typedef struct {
+	/** Child descriptor id. */
 	int child;
+	/** Parent descriptor id. */
 	int parent;
 } usb_dp_descriptor_nesting_t;
@@ -47,11 +56,17 @@
 extern usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[];
 
+/** Descriptor parser structure. */
 typedef struct {
+	/** Used descriptor nesting. */
 	usb_dp_descriptor_nesting_t *nesting;
 } usb_dp_parser_t;
 
+/** Descriptor parser data. */
 typedef struct {
+	/** Data to be parsed. */
 	uint8_t *data;
+	/** Size of input data in bytes. */
 	size_t size;
+	/** Custom argument. */
 	void *arg;
 } usb_dp_parser_data_t;
Index: uspace/lib/usb/include/usb/hub.h
===================================================================
--- uspace/lib/usb/include/usb/hub.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/hub.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -32,4 +32,6 @@
 /** @file
  * Functions needed by hub drivers.
+ *
+ * For class specific requests, see usb/classes/hub.h.
  */
 #ifndef LIBUSB_HUB_H_
Index: uspace/lib/usb/include/usb/pipes.h
===================================================================
--- uspace/lib/usb/include/usb/pipes.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/pipes.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -43,6 +43,5 @@
 #include <ddf/driver.h>
 
-/**
- * Abstraction of a physical connection to the device.
+/** Abstraction of a physical connection to the device.
  * This type is an abstraction of the USB wire that connects the host and
  * the function (device).
@@ -55,6 +54,5 @@
 } usb_device_connection_t;
 
-/**
- * Abstraction of a logical connection to USB device endpoint.
+/** Abstraction of a logical connection to USB device endpoint.
  * It encapsulates endpoint attributes (transfer type etc.) as well
  * as information about currently running sessions.
@@ -111,5 +109,5 @@
 	/** Found descriptor fitting the description. */
 	usb_standard_endpoint_descriptor_t *descriptor;
-	/** Interface the endpoint belongs to. */
+	/** Interface descriptor the endpoint belongs to. */
 	usb_standard_interface_descriptor_t *interface;
 	/** Whether the endpoint was actually found. */
Index: uspace/lib/usb/include/usb/request.h
===================================================================
--- uspace/lib/usb/include/usb/request.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/request.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -72,5 +72,5 @@
 	union {
 		uint16_t value;
-		/* FIXME: add #ifdefs according to host endianess */
+		/* FIXME: add #ifdefs according to host endianness */
 		struct {
 			uint8_t value_low;
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/include/usb/usb.h	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Base USB types.
+ * Common USB types and functions.
  */
 #ifndef LIBUSB_USB_H_
@@ -121,4 +121,10 @@
 } usb_target_t;
 
+/** Compare USB targets (addresses and endpoints).
+ *
+ * @param a First target.
+ * @param b Second target.
+ * @return Whether @p a and @p b points to the same pipe on the same device.
+ */
 static inline int usb_target_same(usb_target_t a, usb_target_t b)
 {
Index: uspace/lib/usb/src/debug.c
===================================================================
--- uspace/lib/usb/src/debug.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/debug.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Debugging support.
+ * Debugging and logging support.
  */
 #include <adt/list.h>
@@ -40,126 +40,16 @@
 #include <usb/debug.h>
 
-/** Debugging tag. */
-typedef struct {
-	/** Linked list member. */
-	link_t link;
-	/** Tag name.
-	 * We always have a private copy of the name.
-	 */
-	char *tag;
-	/** Enabled level of debugging. */
-	int level;
-} usb_debug_tag_t;
-
-/** Get instance of usb_debug_tag_t from link_t. */
-#define USB_DEBUG_TAG_INSTANCE(iterator) \
-	list_get_instance(iterator, usb_debug_tag_t, link)
-
-/** List of all known tags. */
-static LIST_INITIALIZE(tag_list);
-/** Mutex guard for the list of all tags. */
-static FIBRIL_MUTEX_INITIALIZE(tag_list_guard);
-
 /** Level of logging messages. */
 static usb_log_level_t log_level = USB_LOG_LEVEL_WARNING;
+
 /** Prefix for logging messages. */
 static const char *log_prefix = "usb";
+
 /** Serialization mutex for logging functions. */
 static FIBRIL_MUTEX_INITIALIZE(log_serializer);
+
+/** File where to store the log. */
 static FILE *log_stream = NULL;
 
-/** Find or create new tag with given name.
- *
- * @param tagname Tag name.
- * @return Debug tag structure.
- * @retval NULL Out of memory.
- */
-static usb_debug_tag_t *get_tag(const char *tagname)
-{
-	link_t *link;
-	for (link = tag_list.next; \
-	    link != &tag_list; \
-	    link = link->next) {
-		usb_debug_tag_t *tag = USB_DEBUG_TAG_INSTANCE(link);
-		if (str_cmp(tag->tag, tagname) == 0) {
-			return tag;
-		}
-	}
-
-	/*
-	 * Tag not found, we will create a new one.
-	 */
-	usb_debug_tag_t *new_tag = malloc(sizeof(usb_debug_tag_t));
-	int rc = asprintf(&new_tag->tag, "%s", tagname);
-	if (rc < 0) {
-		free(new_tag);
-		return NULL;
-	}
-	list_initialize(&new_tag->link);
-	new_tag->level = 1;
-
-	/*
-	 * Append it to the end of known tags.
-	 */
-	list_append(&new_tag->link, &tag_list);
-
-	return new_tag;
-}
-
-/** Print debugging information.
- * If the tag is used for the first time, its structures are automatically
- * created and initial verbosity level is set to 1.
- *
- * @param tagname Tag name.
- * @param level Level (verbosity) of the message.
- * @param format Formatting string for printf().
- */
-void usb_dprintf(const char *tagname, int level, const char *format, ...)
-{
-	fibril_mutex_lock(&tag_list_guard);
-	usb_debug_tag_t *tag = get_tag(tagname);
-	if (tag == NULL) {
-		printf("USB debug: FATAL ERROR - failed to create tag.\n");
-		goto leave;
-	}
-
-	if (tag->level < level) {
-		goto leave;
-	}
-
-	va_list args;
-	va_start(args, format);
-
-	printf("[%s:%d]: ", tagname, level);
-	vprintf(format, args);
-
-	va_end(args);
-
-leave:
-	fibril_mutex_unlock(&tag_list_guard);
-}
-
-/** Enable debugging prints for given tag.
- *
- * Setting level to <i>n</i> will cause that only printing messages
- * with level lower or equal to <i>n</i> will be printed.
- *
- * @param tagname Tag name.
- * @param level Enabled level.
- */
-void usb_dprintf_enable(const char *tagname, int level)
-{
-	fibril_mutex_lock(&tag_list_guard);
-	usb_debug_tag_t *tag = get_tag(tagname);
-	if (tag == NULL) {
-		printf("USB debug: FATAL ERROR - failed to create tag.\n");
-		goto leave;
-	}
-
-	tag->level = level;
-
-leave:
-	fibril_mutex_unlock(&tag_list_guard);
-}
 
 /** Enable logging.
@@ -182,5 +72,9 @@
 }
 
-
+/** Get log level name prefix.
+ *
+ * @param level Log level.
+ * @return String prefix for the message.
+ */
 static const char *log_level_name(usb_log_level_t level)
 {
@@ -256,6 +150,12 @@
 /* string + terminator + number width (enough for 4GB)*/
 #define REMAINDER_STR_LEN (5 + 1 + 10)
+
+/** How many bytes to group together. */
 #define BUFFER_DUMP_GROUP_SIZE 4
+
+/** Size of the string for buffer dumps. */
 #define BUFFER_DUMP_LEN 240 /* Ought to be enough for everybody ;-). */
+
+/** Fibril local storage for the dumped buffer. */
 static fibril_local char buffer_dump[BUFFER_DUMP_LEN];
 
@@ -265,5 +165,5 @@
  * in a static fibril local string.
  * That means that you do not have to deallocate the string (actually, you
- * can not do that) and you do not have to save it agains concurrent
+ * can not do that) and you do not have to guard it against concurrent
  * calls to it.
  * The only limitation is that each call rewrites the buffer again.
Index: uspace/lib/usb/src/dp.c
===================================================================
--- uspace/lib/usb/src/dp.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/dp.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -32,5 +32,12 @@
 /**
  * @file
- * @brief USB descriptor parser (implementation).
+ * USB descriptor parser (implementation).
+ *
+ * The descriptor parser is a generic parser for structure, where individual
+ * items are stored in single buffer and each item begins with length followed
+ * by type. These types are organized into tree hierarchy.
+ *
+ * The parser is able of only two actions: find first child and find next
+ * sibling.
  */
 #include <stdio.h>
Index: uspace/lib/usb/src/dump.c
===================================================================
--- uspace/lib/usb/src/dump.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/dump.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Descriptor dumping.
+ * Descriptor dumping.
  */
 #include <adt/list.h>
@@ -43,6 +43,9 @@
 #include <usb/classes/hid.h>
 
+/** Mapping between descriptor id and dumping function. */
 typedef struct {
+	/** Descriptor id. */
 	int id;
+	/** Dumping function. */
 	void (*dump)(FILE *, const char *, const char *,
 	    const uint8_t *, size_t);
@@ -66,4 +69,5 @@
     const uint8_t *, size_t);
 
+/** Descriptor dumpers mapping. */
 static descriptor_dump_t descriptor_dumpers[] = {
 	{ USB_DESCTYPE_DEVICE, usb_dump_descriptor_device },
@@ -273,4 +277,5 @@
     const uint8_t *descriptor, size_t descriptor_length)
 {
+	/* TODO */
 }
 
@@ -279,4 +284,5 @@
     const uint8_t *descriptor, size_t descriptor_length)
 {
+	/* TODO */
 }
 
Index: pace/lib/usb/src/hcdhubd_private.h
===================================================================
--- uspace/lib/usb/src/hcdhubd_private.h	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * Copyright (c) 2010 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
- * @brief Common definitions for both HC driver and hub driver.
- */
-#ifndef LIBUSB_HCDHUBD_PRIVATE_H_
-#define LIBUSB_HCDHUBD_PRIVATE_H_
-
-#define USB_HUB_DEVICE_NAME "usbhub"
-#define USB_KBD_DEVICE_NAME "hid"
-
-extern link_t hc_list;
-extern usb_hc_driver_t *hc_driver;
-
-extern usbhc_iface_t usbhc_interface;
-
-usb_address_t usb_get_address_by_handle(devman_handle_t);
-int usb_add_hc_device(device_t *);
-
-/** lowest allowed usb address */
-extern int usb_lowest_address;
-
-/** highest allowed usb address */
-extern int usb_highest_address;
-
-/**
- * @brief initialize address list of given hcd
- *
- * This function should be used only for hcd initialization.
- * It creates interval list of free addresses, thus it is initialized as
- * list with one interval with whole address space. Using an address shrinks
- * the interval, freeing an address extends an interval or creates a
- * new one. 
- *
- * @param hcd
- * @return
- */
-void  usb_create_address_list(usb_hc_device_t * hcd);
-
-
-
-
-
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usb/src/hub.c
===================================================================
--- uspace/lib/usb/src/hub.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/hub.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -144,5 +144,5 @@
 /** Wrapper for registering attached device to the hub.
  *
- * The @p enable_port function is expected to enable singalling on given
+ * The @p enable_port function is expected to enable signaling on given
  * port.
  * The two arguments to it can have arbitrary meaning
@@ -152,5 +152,5 @@
  *
  * If the @p enable_port fails (i.e. does not return EOK), the device
- * addition is cancelled.
+ * addition is canceled.
  * The return value is then returned (it is good idea to use different
  * error codes than those listed as return codes by this function itself).
@@ -159,5 +159,5 @@
  * @param connection Opened connection to host controller.
  * @param dev_speed New device speed.
- * @param enable_port Function for enabling signalling through the port the
+ * @param enable_port Function for enabling signaling through the port the
  *	device is attached to.
  * @param port_no Port number (passed through to @p enable_port).
@@ -201,5 +201,5 @@
 
 	/*
-	 * Enable the port (i.e. allow signalling through this port).
+	 * Enable the port (i.e. allow signaling through this port).
 	 */
 	rc = enable_port(port_no, arg);
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/recognise.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Functions for recognising kind of attached devices.
+ * Functions for recognition of attached devices.
  */
 #include <sys/types.h>
@@ -44,15 +44,22 @@
 #include <assert.h>
 
+/** Index to append after device name for uniqueness. */
 static size_t device_name_index = 0;
+/** Mutex guard for device_name_index. */
 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
 
+/** DDF operations of child devices. */
 ddf_dev_ops_t child_ops = {
 	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl
 };
 
+/** Get integer part from BCD coded number. */
 #define BCD_INT(a) (((unsigned int)(a)) / 256)
+/** Get fraction part from BCD coded number (as an integer, no less). */
 #define BCD_FRAC(a) (((unsigned int)(a)) % 256)
 
+/** Format for BCD coded number to be used in printf. */
 #define BCD_FMT "%x.%x"
+/** Arguments to printf for BCD coded number. */
 #define BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a))
 
@@ -113,4 +120,11 @@
 }
 
+/** Add match id to list or return with error code.
+ *
+ * @param match_ids List of match ids.
+ * @param score Match id score.
+ * @param format Format of the matching string
+ * @param ... Arguments for the format.
+ */
 #define ADD_MATCHID_OR_RETURN(match_ids, score, format, ...) \
 	do { \
Index: uspace/lib/usb/src/request.c
===================================================================
--- uspace/lib/usb/src/request.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/request.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -110,5 +110,5 @@
   *	(must be in USB endianness).
   * @param data Buffer where to store data accepted during the DATA stage.
-  *	(they will come in USB endianess).
+  *	(they will come in USB endianness).
   * @param data_size Size of the @p data buffer
   * 	(in native endianness).
@@ -161,10 +161,4 @@
  * the new address.
  *
- * @see usb_drv_reserve_default_address
- * @see usb_drv_release_default_address
- * @see usb_drv_request_address
- * @see usb_drv_release_address
- * @see usb_drv_bind_address
- *
  * @param pipe Control endpoint pipe (session must be already started).
  * @param new_address New USB address to be set (in native endianness).
@@ -528,5 +522,5 @@
 		return EEMPTY;
 	}
-	/* Substract first 2 bytes (length and descriptor type). */
+	/* Subtract first 2 bytes (length and descriptor type). */
 	string_descriptor_size -= 2;
 
@@ -548,5 +542,5 @@
 	size_t i;
 	for (i = 0; i < langs_count; i++) {
-		/* Language code from the descriptor is in USB endianess. */
+		/* Language code from the descriptor is in USB endianness. */
 		/* FIXME: is this really correct? */
 		uint16_t lang_code = (string_descriptor[2 + 2 * i + 1] << 8)
@@ -569,7 +563,7 @@
  *
  * @param[in] pipe Control endpoint pipe (session must be already started).
- * @param[in] index String index (in native endianess),
+ * @param[in] index String index (in native endianness),
  *	first index has number 1 (index from descriptors can be used directly).
- * @param[in] lang String language (in native endianess).
+ * @param[in] lang String language (in native endianness).
  * @param[out] string_ptr Where to store allocated string in native encoding.
  * @return Error code.
@@ -613,5 +607,5 @@
 		goto leave;
 	}
-	/* Substract first 2 bytes (length and descriptor type). */
+	/* Subtract first 2 bytes (length and descriptor type). */
 	string_size -= 2;
 
Index: uspace/lib/usb/src/usb.c
===================================================================
--- uspace/lib/usb/src/usb.c	(revision d4beec37cf5cae9d8cf25fbfb5aee665f7654c9e)
+++ uspace/lib/usb/src/usb.c	(revision 960bee9b5ba3efcc8c5c9d486ebeaad527f1f223)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief Base USB types.
+ * Common USB functions.
  */
 #include <usb/usb.h>
@@ -37,5 +37,9 @@
 
 
-/** String representation for USB transfer type. */
+/** String representation for USB transfer type.
+ *
+ * @param t Transfer type.
+ * @return Transfer type as a string (in English).
+ */
 const char * usb_str_transfer_type(usb_transfer_type_t t)
 {
