Index: uspace/app/netstart/self_test.c
===================================================================
--- uspace/app/netstart/self_test.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
+++ uspace/app/netstart/self_test.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -0,0 +1,334 @@
+/*
+ * 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: uspace/app/netstart/self_test.h
===================================================================
--- uspace/app/netstart/self_test.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
+++ uspace/app/netstart/self_test.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -0,0 +1,41 @@
+/*
+ * 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/ohci/batch.c
===================================================================
--- uspace/drv/ohci/batch.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/ohci/batch.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -147,4 +147,5 @@
 	    data->ed->next);
 	size_t i = 0;
+	instance->transfered_size = instance->buffer_size;
 	for (; i < tds; ++i) {
 		assert(data->tds[i] != NULL);
@@ -156,6 +157,4 @@
 		}
 		instance->error = td_error(data->tds[i]);
-		/* FIXME: calculate real transfered size */
-		instance->transfered_size = instance->buffer_size;
 		if (instance->error != EOK) {
 			usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
@@ -174,4 +173,7 @@
 	assert(hcd_ep);
 	hcd_ep->td = data->tds[i];
+	if (i > 0)
+		instance->transfered_size -= td_remain_size(data->tds[i - 1]);
+
 	/* Clear possible ED HALT */
 	data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
@@ -238,7 +240,9 @@
 {
 	assert(instance);
-	instance->next_step = usb_transfer_batch_call_in_and_dispose;
+	/* We are data out, we are supposed to provide data */
+	memcpy(instance->data_buffer, instance->buffer, instance->buffer_size);
+	instance->next_step = usb_transfer_batch_call_out_and_dispose;
 	batch_data(instance);
-	usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
+	usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
 }
 /*----------------------------------------------------------------------------*/
Index: uspace/drv/ohci/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/ohci/hw_struct/transfer_descriptor.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/ohci/hw_struct/transfer_descriptor.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -52,4 +52,7 @@
 		instance->status |= togg[toggle] << TD_STATUS_T_SHIFT;
 	}
+	if (dir == USB_DIRECTION_IN) {
+		instance->status |= TD_STATUS_ROUND_FLAG;
+	}
 	if (buffer != NULL) {
 		assert(size != 0);
Index: uspace/drv/ohci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -59,4 +59,5 @@
 #define TD_STATUS_T_0 (0x2)
 #define TD_STATUS_T_1 (0x3)
+#define TD_STATUS_T_ED (0)
 #define TD_STATUS_EC_MASK (0x3) /* error count */
 #define TD_STATUS_EC_SHIFT (26)
@@ -102,4 +103,12 @@
 	return cc_to_rc(cc);
 }
+
+static inline size_t td_remain_size(td_t *instance)
+{
+	assert(instance);
+	if (instance->cbp == 0)
+		return 0;
+	return instance->be - instance->cbp + 1;
+}
 #endif
 /**
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/ohci/root_hub.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -198,5 +198,8 @@
 static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
 
-
+static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
+    void * change_buffer, size_t buffe_size);
+
+static bool is_zeros(void * buffer, size_t size);
 
 
@@ -213,5 +216,5 @@
 	// set port power mode to no-power-switching
 	instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
-
+	instance->unfinished_interrupt_transfer = NULL;
 	usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
 	return EOK;
@@ -233,16 +236,27 @@
 		usb_log_info("Root hub got CONTROL packet\n");
 		opResult = process_ctrl_request(instance, request);
+		usb_transfer_batch_finish_error(request, opResult);
 	} else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) {
 		usb_log_info("Root hub got INTERRUPT packet\n");
 		void * buffer;
+		size_t buffer_size;
 		create_interrupt_mask(instance, &buffer,
-			&(request->transfered_size));
-		memcpy(request->data_buffer, buffer,
-			request->transfered_size);
+			&buffer_size);
+		if(is_zeros(buffer,buffer_size)){
+			usb_log_debug("no changes..");
+			instance->unfinished_interrupt_transfer=
+			    request;
+			//will be finished later
+		}else{
+			usb_log_debug("processing changes..");
+			process_interrupt(instance, request,
+			    buffer, buffer_size);
+		}
+		free(buffer);
 		opResult = EOK;
 	} else {
 		opResult = EINVAL;
-	}
-	usb_transfer_batch_finish_error(request, opResult);
+		usb_transfer_batch_finish_error(request, opResult);
+	}
 	return EOK;
 }
@@ -252,7 +266,16 @@
 
 void rh_interrupt(rh_t *instance) {
-	usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
-		"interrupts, am I?\n");
-	/* TODO: implement? */
+	//usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
+	//	"interrupts, am I?\n");
+	if(!instance->unfinished_interrupt_transfer){
+		return;
+	}
+	size_t size;
+	void * buffer;
+	create_interrupt_mask(instance, &buffer,
+			&size);
+	process_interrupt(instance,instance->unfinished_interrupt_transfer,
+	    buffer,size);
+	free(buffer);
 }
 /*----------------------------------------------------------------------------*/
@@ -859,4 +882,51 @@
 	return opResult;
 }
+/*----------------------------------------------------------------------------*/
+
+/**
+ * process hanging interrupt request
+ *
+ * If an interrupt transfer has been received and there was no change,
+ * the driver stores the transfer information and waits for change to occcur.
+ * This routine is called when that happens and it finalizes the interrupt
+ * transfer.
+ *
+ * @param instance hub instance
+ * @param request batch request to be processed
+ * @param change_buffer chages on hub
+ * @param buffer_size size of change buffer
+ *
+ * @return
+ */
+static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
+    void * change_buffer, size_t buffe_size){
+	create_interrupt_mask(instance, &change_buffer,
+	    &(request->transfered_size));
+	memcpy(request->data_buffer, change_buffer,request->transfered_size);
+	instance->unfinished_interrupt_transfer = NULL;
+	usb_transfer_batch_finish_error(request, EOK);
+	return EOK;
+}
+
+/*----------------------------------------------------------------------------*/
+
+/**
+ * return whether the buffer is full of zeros
+ *
+ * Convenience function.
+ * @param buffer
+ * @param size
+ * @return
+ */
+static bool is_zeros(void * buffer, size_t size){
+	if(!buffer) return true;
+	if(!size) return true;
+	size_t i;
+	for(i=0;i<size;++i){
+		if(((char*)buffer)[i])
+			return false;
+	}
+	return true;
+}
 
 /**
Index: uspace/drv/ohci/root_hub.h
===================================================================
--- uspace/drv/ohci/root_hub.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/ohci/root_hub.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -54,4 +54,6 @@
 	/** hubs descriptors */
 	usb_device_descriptors_t descriptors;
+	/** interrupt transfer waiting for an actual interrupt to occur */
+	usb_transfer_batch_t * unfinished_interrupt_transfer;
 } rh_t;
 
Index: uspace/drv/usbhid/Makefile
===================================================================
--- uspace/drv/usbhid/Makefile	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/Makefile	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -46,4 +46,5 @@
 	generic/hiddev.c \
 	mouse/mousedev.c \
+	lgtch-ultrax/lgtch-ultrax.c \
 	$(STOLEN_LAYOUT_SOURCES)
 
Index: uspace/drv/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/kbd/kbddev.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -176,4 +176,13 @@
 
 /*----------------------------------------------------------------------------*/
+
+static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
+    uint8_t report_id, void *arg);
+
+static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
+	.keyboard = usb_kbd_process_keycodes
+};
+
+/*----------------------------------------------------------------------------*/
 /* Keyboard layouts                                                           */
 /*----------------------------------------------------------------------------*/
@@ -630,10 +639,4 @@
 {
 	assert(hid_dev->parser != NULL);
-	
-	usb_hid_report_in_callbacks_t *callbacks =
-	    (usb_hid_report_in_callbacks_t *)malloc(
-	        sizeof(usb_hid_report_in_callbacks_t));
-	
-	callbacks->keyboard = usb_kbd_process_keycodes;
 
 	usb_log_debug("Calling usb_hid_parse_report() with "
@@ -644,10 +647,10 @@
 	usb_hid_report_path_t *path = usb_hid_report_path();
 	usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
-	usb_hid_report_path_set_report_id(path, 0);
+	//usb_hid_report_path_set_report_id(path, 0);
 	
 	int rc = usb_hid_parse_report(hid_dev->parser, buffer,
 	    actual_size, path, 
 	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
-	    callbacks, hid_dev);
+	    &usb_kbd_parser_callbacks, hid_dev);
 
 	usb_hid_report_path_free(path);
Index: uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
+++ uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak, 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 drvusbhid
+ * @{
+ */
+/**
+ * @file
+ * USB Logitech UltraX Keyboard sample driver.
+ */
+
+
+#include "lgtch-ultrax.h"
+#include "../usbhid.h"
+
+#include <usb/classes/hidparser.h>
+#include <usb/debug.h>
+#include <errno.h>
+#include <str_error.h>
+
+#define NAME "lgtch-ultrax"
+
+/*----------------------------------------------------------------------------*/
+
+static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
+    uint8_t report_id, void *arg);
+
+static const usb_hid_report_in_callbacks_t usb_lgtch_parser_callbacks = {
+	.keyboard = usb_lgtch_process_keycodes
+};
+
+/*----------------------------------------------------------------------------*/
+
+static void usb_lgtch_process_keycodes(const uint8_t *key_codes, size_t count,
+    uint8_t report_id, void *arg)
+{
+	// TODO: checks
+	
+	usb_log_debug(NAME " Got keys from parser (report id: %u): %s\n", 
+	    report_id, usb_debug_str_buffer(key_codes, count, 0));
+}
+
+/*----------------------------------------------------------------------------*/
+
+bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev, 
+    uint8_t *buffer, size_t buffer_size)
+{
+	// TODO: checks
+	
+	usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n",
+	    hid_dev, buffer, buffer_size);
+
+	usb_log_debug(NAME " Calling usb_hid_parse_report() with "
+	    "buffer %s\n", usb_debug_str_buffer(buffer, buffer_size, 0));
+	
+	usb_hid_report_path_t *path = usb_hid_report_path();
+	usb_hid_report_path_append_item(path, 0xc, 0);
+	usb_hid_report_path_set_report_id(path, 1);
+	
+	int rc = usb_hid_parse_report(hid_dev->parser, buffer,
+	    buffer_size, path, 
+	    USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 
+	    &usb_lgtch_parser_callbacks, hid_dev);
+
+	usb_hid_report_path_free(path);
+	
+	if (rc != EOK) {
+		usb_log_warning("Error in usb_hid_boot_keyboard_input_report():"
+		    "%s\n", str_error(rc));
+	}
+	
+	return true;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h
===================================================================
--- uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
+++ uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011 Lubos Slovak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup drvusbhid
+ * @{
+ */
+/** @file
+ * USB Logitech UltraX Keyboard sample driver.
+ */
+
+#ifndef USB_HID_LGTCH_ULTRAX_H_
+#define USB_HID_LGTCH_ULTRAX_H_
+
+#include <usb/devdrv.h>
+
+struct usb_hid_dev;
+//struct usb_hid_subdriver_mapping;
+
+/*----------------------------------------------------------------------------*/
+
+//extern struct usb_hid_subdriver_mapping usb_lgtch_mapping;
+
+/*----------------------------------------------------------------------------*/
+
+//int usb_lgtch_init(struct usb_hid_dev *hid_dev);
+
+bool usb_lgtch_polling_callback(struct usb_hid_dev *hid_dev, uint8_t *buffer,
+    size_t buffer_size);
+
+/*----------------------------------------------------------------------------*/
+
+#endif // USB_HID_LGTCH_ULTRAX_H_
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/main.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -75,4 +75,6 @@
 static int usb_hid_try_add_device(usb_device_t *dev)
 {
+	assert(dev != NULL);
+	
 	/* 
 	 * Initialize device (get and process descriptors, get address, etc.)
@@ -178,4 +180,9 @@
 	usb_log_debug("usb_hid_add_device()\n");
 	
+	if (dev == NULL) {
+		usb_log_warning("Wrong parameter given for add_device().\n");
+		return EINVAL;
+	}
+	
 	if (dev->interface_no < 0) {
 		usb_log_warning("Device is not a supported HID device.\n");
Index: uspace/drv/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/usbhid/mouse/mousedev.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/mouse/mousedev.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -157,10 +157,10 @@
 static void usb_mouse_free(usb_mouse_t **mouse_dev)
 {
-	if (mouse_dev == NULL || *mouse_dev == NULL) {
-		return;
-	}
+	assert(mouse_dev != NULL && *mouse_dev != NULL);
 	
 	// hangup phone to the console
-	async_hangup((*mouse_dev)->console_phone);
+	if ((*mouse_dev)->console_phone >= 0) {
+		async_hangup((*mouse_dev)->console_phone);
+	}
 	
 	free(*mouse_dev);
Index: uspace/drv/usbhid/subdrivers.c
===================================================================
--- uspace/drv/usbhid/subdrivers.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/subdrivers.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -37,23 +37,47 @@
 #include "usb/classes/hidut.h"
 
-static usb_hid_subdriver_usage_t path_kbd[] = {{USB_HIDUT_PAGE_KEYBOARD, 0}};
+#include "lgtch-ultrax/lgtch-ultrax.h"
+
+static usb_hid_subdriver_usage_t path_kbd[] = {
+	{USB_HIDUT_PAGE_KEYBOARD, 0}, 
+	{0, 0}
+};
+
+static usb_hid_subdriver_usage_t lgtch_path[] = {
+	{0xc, 0},
+	{0, 0}
+};
 
 const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = {
 	{
 		path_kbd,
+		-1,
+		USB_HID_PATH_COMPARE_END 
+		| USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
+		0,
+		0,
+		{
+			.init = usb_kbd_init,
+			.deinit = usb_kbd_deinit,
+			.poll = usb_kbd_polling_callback,
+			.poll_end = NULL
+		},
+		
+	},
+	{
+		lgtch_path,
 		1,
 		USB_HID_PATH_COMPARE_END 
 		| USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
-		NULL,
-		NULL,
+		0x046d,
+		0xc30e,
 		{
-			usb_kbd_init,
-			usb_kbd_deinit,
-			usb_kbd_polling_callback,
-			NULL
-		},
-		
+			.init = NULL,
+			.deinit = NULL,
+			.poll = usb_lgtch_polling_callback,
+			.poll_end = NULL
+		}
 	},
-	{NULL, 0, 0, NULL, NULL, {NULL, NULL, NULL, NULL}}
+	{NULL, -1, 0, 0, 0, {NULL, NULL, NULL, NULL}}
 };
 
Index: uspace/drv/usbhid/subdrivers.h
===================================================================
--- uspace/drv/usbhid/subdrivers.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/subdrivers.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -54,8 +54,8 @@
 typedef struct usb_hid_subdriver_mapping {
 	const usb_hid_subdriver_usage_t *usage_path;
-	int path_size;
+	int report_id;
 	int compare;
-	const char *vendor_id;
-	const char *product_id;
+	uint16_t vendor_id;
+	uint16_t product_id;
 	usb_hid_subdriver_t subdriver;
 } usb_hid_subdriver_mapping_t;
Index: uspace/drv/usbhid/usbhid.c
===================================================================
--- uspace/drv/usbhid/usbhid.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhid/usbhid.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -67,5 +67,5 @@
 static int usb_hid_set_boot_kbd_subdriver(usb_hid_dev_t *hid_dev)
 {
-	assert(hid_dev->subdriver_count == 0);
+	assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
 	
 	hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
@@ -97,5 +97,5 @@
 static int usb_hid_set_boot_mouse_subdriver(usb_hid_dev_t *hid_dev)
 {
-	assert(hid_dev->subdriver_count == 0);
+	assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
 	
 	hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
@@ -127,5 +127,5 @@
 static int usb_hid_set_generic_hid_subdriver(usb_hid_dev_t *hid_dev)
 {
-	assert(hid_dev->subdriver_count == 0);
+	assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
 	
 	hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
@@ -164,8 +164,8 @@
 
 static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev, 
-    const usb_hid_subdriver_usage_t *path, int path_size, int compare)
+    const usb_hid_subdriver_mapping_t *mapping)
 {
 	assert(hid_dev != NULL);
-	assert(path != NULL);
+	assert(mapping != NULL);
 	
 	usb_hid_report_path_t *usage_path = usb_hid_report_path();
@@ -174,19 +174,27 @@
 		return false;
 	}
-	int i;
-	for (i = 0; i < path_size; ++i) {
+	int i = 0;
+	while (mapping->usage_path[i].usage != 0 
+	    || mapping->usage_path[i].usage_page != 0) {
 		if (usb_hid_report_path_append_item(usage_path, 
-		    path[i].usage_page, path[i].usage) != EOK) {
+		    mapping->usage_path[i].usage_page, 
+		    mapping->usage_path[i].usage) != EOK) {
 			usb_log_debug("Failed to append to usage path.\n");
 			usb_hid_report_path_free(usage_path);
 			return false;
 		}
+		++i;
+	}
+	
+	if (mapping->report_id >= 0) {
+		usb_hid_report_path_set_report_id(usage_path, 
+		    mapping->report_id);
 	}
 	
 	assert(hid_dev->parser != NULL);
 	
-	usb_log_debug("Compare flags: %d\n", compare);
+	usb_log_debug("Compare flags: %d\n", mapping->compare);
 	size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path, 
-	    compare);
+	    mapping->compare);
 	usb_log_debug("Size of the input report: %d\n", size);
 	
@@ -231,35 +239,40 @@
 static int usb_hid_find_subdrivers(usb_hid_dev_t *hid_dev)
 {
+	assert(hid_dev != NULL);
+	
 	const usb_hid_subdriver_t *subdrivers[USB_HID_MAX_SUBDRIVERS];
 	
 	int i = 0, count = 0;
 	const usb_hid_subdriver_mapping_t *mapping = &usb_hid_subdrivers[i];
+
+	bool ids_matched;
+	bool matched;
 	
 	while (count < USB_HID_MAX_SUBDRIVERS &&
 	    (mapping->usage_path != NULL
-	    || mapping->vendor_id != NULL
-	    || mapping->product_id != NULL)) {
+	    || mapping->vendor_id != 0 || mapping->product_id != 0)) {
 		// check the vendor & product ID
-		if (mapping->vendor_id != NULL && mapping->product_id == NULL) {
-			usb_log_warning("Missing Product ID for Vendor ID %s\n",
+		if (mapping->vendor_id != 0 && mapping->product_id == 0) {
+			usb_log_warning("Missing Product ID for Vendor ID %u\n",
 			    mapping->vendor_id);
 			return EINVAL;
 		}
-		if (mapping->product_id != NULL && mapping->vendor_id == NULL) {
-			usb_log_warning("Missing Vendor ID for Product ID %s\n",
+		if (mapping->product_id != 0 && mapping->vendor_id == 0) {
+			usb_log_warning("Missing Vendor ID for Product ID %u\n",
 			    mapping->product_id);
 			return EINVAL;
 		}
 		
-		if (mapping->vendor_id != NULL) {
-			assert(mapping->product_id != NULL);
-			usb_log_debug("Comparing device against vendor ID %s"
-			    " and product ID %s.\n", mapping->vendor_id,
+		ids_matched = false;
+		matched = false;
+		
+		if (mapping->vendor_id != 0) {
+			assert(mapping->product_id != 0);
+			usb_log_debug("Comparing device against vendor ID %u"
+			    " and product ID %u.\n", mapping->vendor_id,
 			    mapping->product_id);
 			if (usb_hid_ids_match(hid_dev, mapping)) {
-				usb_log_debug("Matched.\n");
-				subdrivers[count++] = &mapping->subdriver;
-				// skip the checking of usage path
-				goto next;
+				usb_log_debug("IDs matched.\n");
+				ids_matched = true;
 			}
 		}
@@ -267,13 +280,17 @@
 		if (mapping->usage_path != NULL) {
 			usb_log_debug("Comparing device against usage path.\n");
-			if (usb_hid_path_matches(hid_dev, 
-			    mapping->usage_path, mapping->path_size,
-			    mapping->compare)) {
-				subdrivers[count++] = &mapping->subdriver;
-			} else {
-				usb_log_debug("Not matched.\n");
+			if (usb_hid_path_matches(hid_dev, mapping)) {
+				// does not matter if IDs were matched
+				matched = true;
 			}
-		}
-	next:
+		} else {
+			// matched only if IDs were matched and there is no path
+			matched = ids_matched;
+		}
+		
+		if (matched) {
+			subdrivers[count++] = &mapping->subdriver;
+		}
+		
 		mapping = &usb_hid_subdrivers[++i];
 	}
@@ -287,4 +304,6 @@
 static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev)
 {
+	assert(hid_dev != NULL && dev != NULL);
+	
 	int rc = EOK;
 	
@@ -360,5 +379,5 @@
 	rc = usb_hid_check_pipes(hid_dev, dev);
 	if (rc != EOK) {
-		usb_hid_free(&hid_dev);
+		//usb_hid_free(&hid_dev);
 		return rc;
 	}
@@ -368,5 +387,5 @@
 	if (rc != EOK) {
 		usb_log_error("Failed to initialize report parser.\n");
-		usb_hid_free(&hid_dev);
+		//usb_hid_free(&hid_dev);
 		return rc;
 	}
@@ -386,4 +405,6 @@
 			    " device.\n");
 			fallback = true;
+			assert(hid_dev->subdrivers == NULL);
+			assert(hid_dev->subdriver_count == 0);
 		}
 	} else {
@@ -426,5 +447,7 @@
 		usb_log_error("No subdriver for handling this device could be"
 		    " initialized: %s.\n", str_error(rc));
-		usb_hid_free(&hid_dev);
+		usb_log_debug("Subdriver count: %d\n", 
+		    hid_dev->subdriver_count);
+		//usb_hid_free(&hid_dev);
 	} else {
 		bool ok = false;
@@ -550,4 +573,7 @@
 	}
 	
+	usb_log_debug("Subdrivers: %p, subdriver count: %d\n", 
+	    (*hid_dev)->subdrivers, (*hid_dev)->subdriver_count);
+	
 	assert((*hid_dev)->subdrivers != NULL 
 	    || (*hid_dev)->subdriver_count == 0);
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhub/usbhub.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -105,5 +105,5 @@
 	}
 
-	usb_pipe_start_session(hub_info->control_pipe);
+	//usb_pipe_start_session(hub_info->control_pipe);
 	//set hub configuration
 	opResult = usb_hub_set_configuration(hub_info);
@@ -122,8 +122,8 @@
 		return opResult;
 	}
-	usb_pipe_end_session(hub_info->control_pipe);
-
-	/// \TODO what is this?
-	usb_log_debug("Creating `hub' function.\n");
+	//usb_pipe_end_session(hub_info->control_pipe);
+
+
+	usb_log_debug("Creating 'hub' function in DDF.\n");
 	ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
 	    fun_exposed, "hub");
@@ -153,4 +153,5 @@
 bool hub_port_changes_callback(usb_device_t *dev,
     uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
+	usb_log_debug("hub_port_changes_callback\n");
 	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
 
@@ -217,5 +218,6 @@
 	// get hub descriptor
 	usb_log_debug("creating serialized descriptor\n");
-	void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
+	//void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
+	uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
 	usb_hub_descriptor_t * descriptor;
 	int opResult;
@@ -235,12 +237,17 @@
 	}
 	usb_log_debug2("deserializing descriptor\n");
-	descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
+	descriptor = usb_create_deserialized_hub_desriptor(
+	    serialized_descriptor);
 	if (descriptor == NULL) {
 		usb_log_warning("could not deserialize descriptor \n");
-		return opResult;
+		return ENOMEM;
 	}
 	usb_log_debug("setting port count to %d\n", descriptor->ports_count);
 	hub_info->port_count = descriptor->ports_count;
 	/// \TODO this is not semantically correct
+	bool is_power_switched =
+	    ((descriptor->hub_characteristics & 1) ==0);
+	bool has_individual_port_powering =
+	    ((descriptor->hub_characteristics & 1) !=0);
 	hub_info->ports = malloc(
 	    sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
@@ -249,15 +256,31 @@
 		usb_hub_port_init(&hub_info->ports[port]);
 	}
-	for (port = 0; port < hub_info->port_count; port++) {
-		opResult = usb_hub_set_port_feature(hub_info->control_pipe,
-		    port+1, USB_HUB_FEATURE_PORT_POWER);
-		if (opResult != EOK) {
-			usb_log_error("cannot power on port %d;  %d\n",
-			    port+1, opResult);
-		}
+	if(is_power_switched){
+		usb_log_debug("is_power_switched\n");
+		if(has_individual_port_powering){
+			usb_log_debug("has_individual_port_powering\n");
+			for (port = 0; port < hub_info->port_count; port++) {
+				opResult = usb_hub_set_port_feature(hub_info->control_pipe,
+				    port+1, USB_HUB_FEATURE_PORT_POWER);
+				if (opResult != EOK) {
+					usb_log_error("cannot power on port %d;  %d\n",
+					    port+1, opResult);
+				}
+			}
+		}else{
+			usb_log_debug("!has_individual_port_powering\n");
+			opResult = usb_hub_set_feature(hub_info->control_pipe,
+			    USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
+			if (opResult != EOK) {
+				usb_log_error("cannot power hub;  %d\n",
+				  opResult);
+			}
+		}
+	}else{
+		usb_log_debug("!is_power_switched\n");
 	}
 	usb_log_debug2("freeing data\n");
-	free(serialized_descriptor);
-	free(descriptor->devices_removable);
+	//free(serialized_descriptor);
+	//free(descriptor->devices_removable);
 	free(descriptor);
 	return EOK;
@@ -321,13 +344,7 @@
 	 * auto destruction, this could work better.
 	 */
-	int rc = usb_pipe_start_session(hub_info->control_pipe);
+	int rc = usb_hc_connection_open(&hub_info->connection);
 	if (rc != EOK) {
-		usb_log_error("Failed to start session on control pipe: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-	rc = usb_hc_connection_open(&hub_info->connection);
-	if (rc != EOK) {
-		usb_pipe_end_session(hub_info->control_pipe);
+		//usb_pipe_end_session(hub_info->control_pipe);
 		usb_log_error("Failed to open connection to HC: %s.\n",
 		    str_error(rc));
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -113,5 +113,5 @@
 
 	usb_device_request_setup_packet_t clear_request = {
-		.request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
+		.request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,
 		.request = USB_DEVREQ_SET_FEATURE,
 		.length = 0,
@@ -166,22 +166,15 @@
 }
 
-/**
- * create uint8_t array with serialized descriptor
- *
- * @param descriptor
- * @return newly created serializd descriptor pointer
- */
-void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
 
-/**
- * create deserialized desriptor structure out of serialized descriptor
- *
- * The serialized descriptor must be proper usb hub descriptor,
- * otherwise an eerror might occur.
- *
- * @param sdescriptor serialized descriptor
- * @return newly created deserialized descriptor pointer
- */
-usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
+void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor);
+
+void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
+    void * serialized_descriptor);
+
+usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
+    void * serialized_descriptor);
+
+void usb_deserialize_hub_desriptor(void * serialized_descriptor,
+    usb_hub_descriptor_t * descriptor);
 
 
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/drv/usbhub/utils.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -56,5 +56,11 @@
 //hub descriptor utils
 
-void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor) {
+/**
+ * create uint8_t array with serialized descriptor
+ *
+ * @param descriptor
+ * @return newly created serializd descriptor pointer
+ */
+void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor) {
 	//base size
 	size_t size = 7;
@@ -64,25 +70,55 @@
 	uint8_t * result = malloc(size);
 	//size
-	result[0] = size;
+	if(result)
+		usb_serialize_hub_descriptor(descriptor,result);
+	return result;
+}
+
+/**
+ * serialize descriptor into given buffer
+ *
+ * The buffer size is not checked.
+ * @param descriptor
+ * @param serialized_descriptor
+ */
+void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
+    void * serialized_descriptor) {
+	//base size
+	uint8_t * sdescriptor = serialized_descriptor;
+	size_t size = 7;
+	//variable size according to port count
+	size_t var_size = (descriptor->ports_count+7)/8;
+	size += 2 * var_size;
+	//size
+	sdescriptor[0] = size;
 	//descriptor type
-	result[1] = USB_DESCTYPE_HUB;
-	result[2] = descriptor->ports_count;
+	sdescriptor[1] = USB_DESCTYPE_HUB;
+	sdescriptor[2] = descriptor->ports_count;
 	/// @fixme handling of endianness??
-	result[3] = descriptor->hub_characteristics / 256;
-	result[4] = descriptor->hub_characteristics % 256;
-	result[5] = descriptor->pwr_on_2_good_time;
-	result[6] = descriptor->current_requirement;
+	sdescriptor[3] = descriptor->hub_characteristics / 256;
+	sdescriptor[4] = descriptor->hub_characteristics % 256;
+	sdescriptor[5] = descriptor->pwr_on_2_good_time;
+	sdescriptor[6] = descriptor->current_requirement;
 
 	size_t i;
 	for (i = 0; i < var_size; ++i) {
-		result[7 + i] = descriptor->devices_removable[i];
+		sdescriptor[7 + i] = descriptor->devices_removable[i];
 	}
 	for (i = 0; i < var_size; ++i) {
-		result[7 + var_size + i] = 255;
+		sdescriptor[7 + var_size + i] = 255;
 	}
-	return result;
 }
 
-usb_hub_descriptor_t * usb_deserialize_hub_desriptor(
+
+/**
+ * create deserialized desriptor structure out of serialized descriptor
+ *
+ * The serialized descriptor must be proper usb hub descriptor,
+ * otherwise an eerror might occur.
+ *
+ * @param sdescriptor serialized descriptor
+ * @return newly created deserialized descriptor pointer
+ */
+usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
 void * serialized_descriptor) {
 	uint8_t * sdescriptor = serialized_descriptor;
@@ -95,22 +131,32 @@
 
 	usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t));
-	
+	if(result)
+		usb_deserialize_hub_desriptor(serialized_descriptor,result);
+	return result;
+}
 
-	result->ports_count = sdescriptor[2];
+/**
+ * deserialize descriptor into given pointer
+ * 
+ * @param serialized_descriptor
+ * @param descriptor
+ * @return
+ */
+void usb_deserialize_hub_desriptor(
+void * serialized_descriptor, usb_hub_descriptor_t * descriptor) {
+	uint8_t * sdescriptor = serialized_descriptor;
+	descriptor->ports_count = sdescriptor[2];
 	/// @fixme handling of endianness??
-	result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
-	result->pwr_on_2_good_time = sdescriptor[5];
-	result->current_requirement = sdescriptor[6];
-	size_t var_size = (result->ports_count+7) / 8;
-	result->devices_removable = (uint8_t*) malloc(var_size);
+	descriptor->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
+	descriptor->pwr_on_2_good_time = sdescriptor[5];
+	descriptor->current_requirement = sdescriptor[6];
+	size_t var_size = (descriptor->ports_count+7) / 8;
+	//descriptor->devices_removable = (uint8_t*) malloc(var_size);
 
 	size_t i;
 	for (i = 0; i < var_size; ++i) {
-		result->devices_removable[i] = sdescriptor[7 + i];
+		descriptor->devices_removable[i] = sdescriptor[7 + i];
 	}
-	return result;
 }
-
-
 
 /**
Index: pace/lib/packet/include/net_byteorder.h
===================================================================
--- uspace/lib/packet/include/net_byteorder.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ 	(revision )
@@ -1,71 +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
- *  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: pace/lib/packet/include/net_err.h
===================================================================
--- uspace/lib/packet/include/net_err.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ 	(revision )
@@ -1,99 +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
- * 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: pace/lib/packet/include/socket_errno.h
===================================================================
--- uspace/lib/packet/include/socket_errno.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ 	(revision )
@@ -1,136 +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
- *  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/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -152,5 +152,5 @@
             maximum of 255 ports).
      */
-    uint8_t * devices_removable;
+    uint8_t devices_removable[32];
 
     /**
Index: uspace/lib/usb/src/hidreport.c
===================================================================
--- uspace/lib/usb/src/hidreport.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/lib/usb/src/hidreport.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -119,14 +119,4 @@
 	uint16_t length =  hid_desc->report_desc_info.length;
 	size_t actual_size = 0;
-	
-	/*
-	 * Start session for the control transfer.
-	 */
-	int sess_rc = usb_pipe_start_session(&dev->ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
 
 	/*
@@ -162,16 +152,4 @@
 		    "%u)\n", actual_size, length);
 		return EINVAL;
-	}
-	
-	/*
-	 * End session for the control transfer.
-	 */
-	sess_rc = usb_pipe_end_session(&dev->ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to end a session: %s.\n",
-		    str_error(sess_rc));
-		free(*report_desc);
-		*report_desc = NULL;
-		return sess_rc;
 	}
 	
Index: uspace/lib/usb/src/hidreq.c
===================================================================
--- uspace/lib/usb/src/hidreq.c	(revision 27b85d9ebdc66e9e29d0e2194cb70e62a1180a40)
+++ uspace/lib/usb/src/hidreq.c	(revision 8595577b1bae16ef32d246ec3defd163cf7519f0)
@@ -56,7 +56,5 @@
  * @retval EOK if successful.
  * @retval EINVAL if no HID device is given.
- * @return Other value inherited from one of functions 
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usb_control_request_set().
+ * @return Other value inherited from function usb_control_request_set().
  */
 int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no,
@@ -79,12 +77,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;
 	
 	uint16_t value = 0;
@@ -97,16 +88,8 @@
 	    USB_HIDREQ_SET_REPORT, value, iface_no, buffer, buf_size);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
@@ -123,7 +106,5 @@
  * @retval EOK if successful.
  * @retval EINVAL if no HID device is given.
- * @return Other value inherited from one of functions 
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usb_control_request_set().
+ * @return Other value inherited from function usb_control_request_set().
  */
 int usbhid_req_set_protocol(usb_pipe_t *ctrl_pipe, int iface_no,
@@ -146,12 +127,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;
 
 	usb_log_debug("Sending Set_Protocol request to the device ("
@@ -162,16 +136,8 @@
 	    USB_HIDREQ_SET_PROTOCOL, protocol, iface_no, NULL, 0);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
@@ -189,7 +155,5 @@
  * @retval EOK if successful.
  * @retval EINVAL if no HID device is given.
- * @return Other value inherited from one of functions 
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usb_control_request_set().
+ * @return Other value inherited from function usb_control_request_set().
  */
 int usbhid_req_set_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t duration)
@@ -211,12 +175,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;
 
 	usb_log_debug("Sending Set_Idle request to the device ("
@@ -229,16 +186,8 @@
 	    USB_HIDREQ_SET_IDLE, value, iface_no, NULL, 0);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
@@ -259,7 +208,5 @@
  * @retval EOK if successful.
  * @retval EINVAL if no HID device is given.
- * @return Other value inherited from one of functions 
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usb_control_request_set().
+ * @return Other value inherited from function usb_control_request_set().
  */
 int usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 
@@ -283,12 +230,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;
 
 	uint16_t value = 0;
@@ -302,16 +242,8 @@
 	    actual_size);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
@@ -328,7 +260,5 @@
  * @retval EOK if successful.
  * @retval EINVAL if no HID device is given.
- * @return Other value inherited from one of functions 
- *         usb_pipe_start_session(), usb_pipe_end_session(),
- *         usb_control_request_set().
+ * @return Other value inherited from function usb_control_request_set().
  */
 int usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
@@ -351,12 +281,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;	
 
 	usb_log_debug("Sending Get_Protocol request to the device ("
@@ -370,16 +293,8 @@
 	    USB_HIDREQ_GET_PROTOCOL, 0, iface_no, buffer, 1, &actual_size);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
@@ -427,12 +342,5 @@
 	 */
 	
-	int rc, sess_rc;
-	
-	sess_rc = usb_pipe_start_session(ctrl_pipe);
-	if (sess_rc != EOK) {
-		usb_log_warning("Failed to start a session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
-	}
+	int rc;
 
 	usb_log_debug("Sending Get_Idle request to the device ("
@@ -448,16 +356,8 @@
 	    &actual_size);
 
-	sess_rc = usb_pipe_end_session(ctrl_pipe);
-
-	if (rc != EOK) {
-		usb_log_warning("Error sending output report to the keyboard: "
-		    "%s.\n", str_error(rc));
-		return rc;
-	}
-
-	if (sess_rc != EOK) {
-		usb_log_warning("Error closing session: %s.\n",
-		    str_error(sess_rc));
-		return sess_rc;
+	if (rc != EOK) {
+		usb_log_warning("Error sending output report to the keyboard: "
+		    "%s.\n", str_error(rc));
+		return rc;
 	}
 	
