Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ HelenOS.config	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -570,5 +570,5 @@
 
 % USB release build (less logging)
-! CONFIG_USB_RELEASE_BUILD (n/y)
+! CONFIG_USB_RELEASE_BUILD (y/n)
 
 % Start virtual USB host controller
@@ -576,5 +576,5 @@
 
 % Polling UHCI & OHCI (no interrupts)
-! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n)
+! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (n/y)
 
 % Run devman in kconsole (not recommended)
Index: uspace/drv/ehci-hcd/hc_iface.c
===================================================================
--- uspace/drv/ehci-hcd/hc_iface.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/ehci-hcd/hc_iface.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -48,32 +48,4 @@
 	    methodname, __FILE__, __LINE__)
 
-/** Reserve default address.
- *
- * This function may block the caller.
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] speed Speed of the device for which the default address is
- *	reserved.
- * @return Error code.
- */
-static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
-{
-	UNSUPPORTED("reserve_default_address");
-
-	return ENOTSUP;
-}
-
-/** Release default address.
- *
- * @param[in] fun Device function the action was invoked on.
- * @return Error code.
- */
-static int release_default_address(ddf_fun_t *fun)
-{
-	UNSUPPORTED("release_default_address");
-
-	return ENOTSUP;
-}
-
 /** Found free USB address.
  *
@@ -332,6 +304,4 @@
 /** Host controller interface implementation for EHCI. */
 usbhc_iface_t ehci_hc_iface = {
-	.reserve_default_address = reserve_default_address,
-	.release_default_address = release_default_address,
 	.request_address = request_address,
 	.bind_address = bind_address,
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/ohci/root_hub.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -117,5 +117,5 @@
  */
 static const uint32_t hub_clear_feature_by_writing_one_mask =
-   RHS_CLEAR_PORT_POWER;
+    RHS_CLEAR_PORT_POWER;
 
 /**
@@ -412,5 +412,5 @@
 	request->transfered_size = 4;
 	uint32_t data = instance->registers->rh_port_status[port - 1];
-	memcpy(request->data_buffer,&data,4);
+	memcpy(request->data_buffer, &data, 4);
 #if 0
 	int i;
@@ -445,5 +445,5 @@
 	uint32_t data = mask & instance->registers->rh_status;
 	//uint32_buffer[0] = mask & instance->registers->rh_status;
-	memcpy(request->data_buffer,&data,4);
+	memcpy(request->data_buffer, &data, 4);
 
 	return EOK;
@@ -499,5 +499,5 @@
 	    | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
 	bzero(bitmap, instance->interrupt_mask_size);
-	if ((instance->registers->rh_status & mask) !=0 ) {
+	if ((instance->registers->rh_status & mask) != 0) {
 		bitmap[0] = 1;
 	}
@@ -925,5 +925,6 @@
  * @return
  */
-static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request) {
+static int process_interrupt_mask_in_instance(rh_t *instance,
+    usb_transfer_batch_t * request) {
 	memcpy(request->data_buffer, instance->interrupt_buffer,
 	    instance->interrupt_mask_size);
@@ -945,5 +946,5 @@
  * @return
  */
-static bool is_zeros(void * buffer, size_t size) {
+static bool is_zeros(void *buffer, size_t size) {
 	if (!buffer) return true;
 	if (!size) return true;
Index: uspace/drv/uhci-rhd/port.h
===================================================================
--- uspace/drv/uhci-rhd/port.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/uhci-rhd/port.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -55,6 +55,5 @@
 
 /** UHCI port structure */
-typedef struct uhci_port
-{
+typedef struct uhci_port {
 	const char *id_string;
 	port_status_t *address;
@@ -68,6 +67,6 @@
 
 int uhci_port_init(
-  uhci_port_t *port, port_status_t *address, unsigned number,
-  unsigned usec, ddf_dev_t *rh);
+    uhci_port_t *port, port_status_t *address, unsigned number,
+    unsigned usec, ddf_dev_t *rh);
 
 void uhci_port_fini(uhci_port_t *port);
Index: uspace/drv/usbhid/generic/hiddev.c
===================================================================
--- uspace/drv/usbhid/generic/hiddev.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhid/generic/hiddev.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -99,5 +99,5 @@
 	usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data;
 	
-	usb_log_debug2("hid_dev: %p, Max input report size (%d).\n",
+	usb_log_debug2("hid_dev: %p, Max input report size (%zu).\n",
 	    hid_dev, hid_dev->max_input_report_size);
 	
@@ -226,5 +226,5 @@
 	}
 	
-	usb_log_debug("HID function created. Handle: %d\n", fun->handle);
+	usb_log_debug("HID function created. Handle: %" PRIun "\n", fun->handle);
 	
 	return EOK;
Index: uspace/drv/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbd/kbddev.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhid/kbd/kbddev.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -798,6 +798,6 @@
 	}
 	
-	usb_log_debug("%s function created. Handle: %d\n", HID_KBD_FUN_NAME,
-	    fun->handle);
+	usb_log_debug("%s function created. Handle: %" PRIun "\n",
+	    HID_KBD_FUN_NAME, fun->handle);
 	
 	usb_log_debug("Adding DDF function to class %s...\n", 
Index: uspace/drv/usbhid/multimedia/multimedia.c
===================================================================
--- uspace/drv/usbhid/multimedia/multimedia.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhid/multimedia/multimedia.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -211,5 +211,6 @@
 	}
 	
-	usb_log_debug("%s function created. Handle: %d\n", NAME, fun->handle);
+	usb_log_debug("%s function created (jandle: %" PRIun ").\n",
+	    NAME, fun->handle);
 	
 	rc = ddf_fun_add_to_class(fun, "keyboard");
Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/port_status.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -64,6 +64,5 @@
  */
 static inline void usb_hub_set_port_status_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS;
@@ -79,6 +78,5 @@
  */
 static inline void usb_hub_set_hub_status_request(
-	usb_device_request_setup_packet_t * request
-	) {
+    usb_device_request_setup_packet_t *request) {
 	request->index = 0;
 	request->request_type = USB_HUB_REQ_TYPE_GET_HUB_STATUS;
@@ -95,6 +93,6 @@
 static inline usb_device_request_setup_packet_t *
 usb_hub_create_port_status_request(uint16_t port) {
-	usb_device_request_setup_packet_t * result =
-		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_device_request_setup_packet_t *result =
+	    malloc(sizeof (usb_device_request_setup_packet_t));
 	usb_hub_set_port_status_request(result, port);
 	return result;
@@ -108,7 +106,6 @@
  */
 static inline void usb_hub_set_enable_port_feature_request(
-	usb_device_request_setup_packet_t * request, uint16_t port,
-	uint16_t feature_selector
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port,
+    uint16_t feature_selector) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -125,7 +122,7 @@
  */
 static inline void usb_hub_set_disable_port_feature_request(
-	usb_device_request_setup_packet_t * request, uint16_t port,
-	uint16_t feature_selector
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port,
+    uint16_t feature_selector
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -141,6 +138,6 @@
  */
 static inline void usb_hub_set_enable_port_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -157,6 +154,6 @@
 static inline usb_device_request_setup_packet_t *
 usb_hub_create_enable_port_request(uint16_t port) {
-	usb_device_request_setup_packet_t * result =
-		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_device_request_setup_packet_t *result =
+	    malloc(sizeof (usb_device_request_setup_packet_t));
 	usb_hub_set_enable_port_request(result, port);
 	return result;
@@ -169,6 +166,6 @@
  */
 static inline void usb_hub_set_disable_port_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -185,6 +182,6 @@
 static inline usb_device_request_setup_packet_t *
 usb_hub_create_disable_port_request(uint16_t port) {
-	usb_device_request_setup_packet_t * result =
-		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_device_request_setup_packet_t *result =
+	    malloc(sizeof (usb_device_request_setup_packet_t));
 	usb_hub_set_disable_port_request(result, port);
 	return result;
@@ -197,6 +194,6 @@
  */
 static inline void usb_hub_set_reset_port_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -213,6 +210,6 @@
 static inline usb_device_request_setup_packet_t *
 usb_hub_create_reset_port_request(uint16_t port) {
-	usb_device_request_setup_packet_t * result =
-		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_device_request_setup_packet_t *result =
+	    malloc(sizeof (usb_device_request_setup_packet_t));
 	usb_hub_set_reset_port_request(result, port);
 	return result;
@@ -225,6 +222,6 @@
  */
 static inline void usb_hub_set_power_port_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -240,6 +237,6 @@
  */
 static inline void usb_hub_unset_power_port_request(
-	usb_device_request_setup_packet_t * request, uint16_t port
-	) {
+    usb_device_request_setup_packet_t *request, uint16_t port
+    ) {
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
@@ -257,5 +254,5 @@
  */
 static inline bool usb_port_is_status(usb_port_status_t status, int idx) {
-	return (status&(1 << idx))!=0;
+	return (status & (1 << idx)) != 0;
 }
 
@@ -268,8 +265,8 @@
  */
 static inline void usb_port_status_set_bit(
-	usb_port_status_t * status, int idx, bool value) {
+    usb_port_status_t * status, int idx, bool value) {
 	(*status) = value ?
-		((*status) | (1 << (idx))) :
-		((*status)&(~(1 << (idx))));
+	    ((*status) | (1 << (idx))) :
+	    ((*status)&(~(1 << (idx))));
 }
 
@@ -282,5 +279,5 @@
  */
 static inline bool usb_hub_is_status(usb_hub_status_t status, int idx) {
-	return (status&(1 << idx))!=0;
+	return (status & (1 << idx)) != 0;
 }
 
@@ -293,141 +290,10 @@
  */
 static inline void usb_hub_status_set_bit(
-	usb_hub_status_t * status, int idx, bool value) {
+    usb_hub_status_t *status, int idx, bool value) {
 	(*status) = value ?
-		((*status) | (1 << (idx))) :
-		((*status)&(~(1 << (idx))));
-}
-
-
-#if 0
-/**
- * connection status geter for port status
- * 
- * @param status
- * @return true if there is something connected
- */
-static inline bool usb_port_dev_connected(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 0);
-}
-
-/**
- * set device connected bit in port status
- *
- * @param status
- * @param connected value of the bit
- */
-static inline void usb_port_set_dev_connected(usb_port_status_t * status, bool connected) {
-	usb_port_set_bit(status, 0, connected);
-}
-
-//port enabled
-
-/**
- * port enabled getter for port status
- * 
- * @param status
- * @return true if the port is enabled
- */
-static inline bool usb_port_enabled(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 1);
-}
-
-/**
- * set port enabled bit in port status
- *
- * @param status
- * @param enabled value of the bit
- */
-static inline void usb_port_set_enabled(usb_port_status_t * status, bool enabled) {
-	usb_port_set_bit(status, 1, enabled);
-}
-
-//port suspended
-/**
- * port suspended getter for port status
- *
- * @param status
- * @return true if port is suspended
- */
-static inline bool usb_port_suspended(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 2);
-}
-
-/**
- * set port suspended bit in port status
- *
- * @param status
- * @param suspended value of the bit
- */
-static inline void usb_port_set_suspended(usb_port_status_t * status, bool suspended) {
-	usb_port_set_bit(status, 2, suspended);
-}
-
-//over currect
-/**
- * over current condition indicator getter for port status
- *
- * @param status
- * @return true if there is opver-current condition on the hub
- */
-static inline bool usb_port_over_current(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 3);
-}
-
-/**
- * set over current indicator bit in port status
- *
- * @param status
- * @param value value of the bit
- */
-static inline void usb_port_set_over_current(usb_port_status_t * status, bool value) {
-	usb_port_set_bit(status, 3, value);
-}
-
-//port reset
-/**
- * port reset indicator getter for port status
- * 
- * @param status
- * @return true if port is reset
- */
-static inline bool usb_port_reset(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 4);
-}
-
-/**
- * set port reset bit in port status
- *
- * @param status
- * @param value value of the bit
- */
-static inline void usb_port_set_reset(usb_port_status_t * status, bool value) {
-	usb_port_set_bit(status, 4, value);
-}
-
-//powered
-/**
- * power state getter for port status
- *
- * @param status
- * @return true if port is powered
- */
-static inline bool usb_port_powered(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 8);
-}
-
-/**
- * set port powered bit in port status
- *
- * @param status
- * @param powered value of the bit
- */
-static inline void usb_port_set_powered(usb_port_status_t * status, bool powered) {
-	usb_port_set_bit(status, 8, powered);
-}
-
-#endif
-
-//low speed device attached
+	    ((*status) | (1 << (idx))) :
+	    ((*status)&(~(1 << (idx))));
+}
+
 /**
  * low speed device on the port indicator
@@ -446,9 +312,10 @@
  * @param low_speed value of the bit
  */
-static inline void usb_port_set_low_speed(usb_port_status_t * status, bool low_speed) {
+static inline void usb_port_set_low_speed(usb_port_status_t *status, bool low_speed) {
 	usb_port_status_set_bit(status, 9, low_speed);
 }
 
 //high speed device attached
+
 /**
  * high speed device on the port indicator
@@ -467,5 +334,5 @@
  * @param high_speed value of the bit
  */
-static inline void usb_port_set_high_speed(usb_port_status_t * status, bool high_speed) {
+static inline void usb_port_set_high_speed(usb_port_status_t *status, bool high_speed) {
 	usb_port_status_set_bit(status, 10, high_speed);
 }
@@ -485,197 +352,4 @@
 }
 
-#if 0
-//connect change
-/**
- * port connect change indicator
- *
- * @param status
- * @return true if connection has changed
- */
-static inline bool usb_port_connect_change(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 16);
-}
-
-/**
- * set connection change bit in port status
- * @param status
- * @param change value of the bit
- */
-static inline void usb_port_set_connect_change(usb_port_status_t * status, bool change) {
-	usb_port_set_bit(status, 16, change);
-}
-
-//port enable change
-/**
- * port enable change for port status
- *
- * @param status
- * @return true if the port has been enabled/disabled
- */
-static inline bool usb_port_enabled_change(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 17);
-}
-
-/**
- * set port enable change bit in port status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_port_set_enabled_change(usb_port_status_t * status, bool change) {
-	usb_port_set_bit(status, 17, change);
-}
-
-//suspend change
-/**
- * port suspend change for port status
- * 
- * @param status
- * @return ture if suspend status has changed
- */
-static inline bool usb_port_suspend_change(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 18);
-}
-
-/**
- * set port suspend change bit in port status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_port_set_suspend_change(usb_port_status_t * status, bool change) {
-	usb_port_set_bit(status, 18, change);
-}
-
-//over current change
-/**
- * over current change indicator
- * 
- * @param status
- * @return true if over-current condition on port has changed
- */
-static inline bool usb_port_overcurrent_change(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 19);
-}
-
-/**
- * set port over current change bit in port status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_port_set_overcurrent_change(usb_port_status_t * status, bool change) {
-	usb_port_set_bit(status, 19, change);
-}
-
-//reset change
-/**
- * port reset change indicator
- * @param status
- * @return true if port has been reset
- */
-static inline bool usb_port_reset_completed(usb_port_status_t * status) {
-	return usb_port_get_bit(status, 20);
-}
-
-/**
- * set port reset completed bit in port status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_port_set_reset_completed(usb_port_status_t * status, bool completed) {
-	usb_port_set_bit(status, 20, completed);
-}
-
-//local power status
-/**
- * local power lost indicator for hub status
- * 
- * @param status
- * @return true if hub is not powered
- */
-static inline bool usb_hub_local_power_lost(usb_hub_status_t * status) {
-	return usb_hub_get_bit(status, 0);
-}
-
-/**
- * set hub power lost bit in hub status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_hub_set_local_power_lost(usb_port_status_t * status,
-	bool power_lost) {
-	usb_hub_set_bit(status, 0, power_lost);
-}
-
-//over current ocndition
-/**
- * hub over-current indicator
- *
- * @param status
- * @return true if over-current condition occurred on hub
- */
-static inline bool usb_hub_over_current(usb_hub_status_t * status) {
-	return usb_hub_get_bit(status, 1);
-}
-
-/**
- * set hub over current bit in hub status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_hub_set_over_current(usb_port_status_t * status,
-	bool over_current) {
-	usb_hub_set_bit(status, 1, over_current);
-}
-
-//local power change
-/**
- * hub power change indicator
- *
- * @param status
- * @return true if local power status has been changed - power has been
- * dropped or re-established
- */
-static inline bool usb_hub_local_power_change(usb_hub_status_t * status) {
-	return usb_hub_get_bit(status, 16);
-}
-
-/**
- * set hub power change bit in hub status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_hub_set_local_power_change(usb_port_status_t * status,
-	bool change) {
-	usb_hub_set_bit(status, 16, change);
-}
-
-//local power status
-/**
- * hub over-current condition change indicator
- *
- * @param status
- * @return true if over-current condition has changed
- */
-static inline bool usb_hub_over_current_change(usb_hub_status_t * status) {
-	return usb_hub_get_bit(status, 17);
-}
-
-/**
- * set hub over current change bit in hub status
- *
- * @param status
- * @param change value of the bit
- */
-static inline void usb_hub_set_over_current_change(usb_port_status_t * status,
-	bool change) {
-	usb_hub_set_bit(status, 17, change);
-}
-#endif
 
 
Index: uspace/drv/usbhub/ports.c
===================================================================
--- uspace/drv/usbhub/ports.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/ports.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -47,5 +47,4 @@
 #include "port_status.h"
 
-
 /** Information for fibril for device discovery. */
 struct add_device_phase1 {
@@ -65,5 +64,5 @@
  * any function here and must be cleared by hand
  */
-static const int non_handled_changes[] =  {
+static const int non_handled_changes[] = {
 	USB_HUB_FEATURE_C_PORT_ENABLE,
 	USB_HUB_FEATURE_C_PORT_SUSPEND
@@ -71,11 +70,11 @@
 
 static void usb_hub_removed_device(
-	usb_hub_info_t * hub, uint16_t port);
-
-static void usb_hub_port_reset_completed(usb_hub_info_t * hub,
-	uint16_t port, uint32_t status);
-
-static void usb_hub_port_over_current(usb_hub_info_t * hub,
-	uint16_t port, uint32_t status);
+    usb_hub_info_t *hub, uint16_t port);
+
+static void usb_hub_port_reset_completed(usb_hub_info_t *hub,
+    uint16_t port, uint32_t status);
+
+static void usb_hub_port_over_current(usb_hub_info_t *hub,
+    uint16_t port, uint32_t status);
 
 static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port,
@@ -96,7 +95,7 @@
  * @param port port number, starting from 1
  */
-void usb_hub_process_interrupt(usb_hub_info_t * hub,
-	uint16_t port) {
-	usb_log_debug("interrupt at port %zu\n", (size_t) port);
+void usb_hub_process_interrupt(usb_hub_info_t *hub,
+    uint16_t port) {
+	usb_log_debug("Interrupt at port %zu\n", (size_t) port);
 	//determine type of change
 	//usb_pipe_t *pipe = hub->control_pipe;
@@ -134,5 +133,5 @@
 	if (usb_port_is_status(status, USB_HUB_FEATURE_C_PORT_OVER_CURRENT)) {
 		//check if it was not auto-resolved
-		usb_log_debug("overcurrent change on port\n");
+		usb_log_debug("Overcurrent change on port\n");
 		usb_hub_port_over_current(hub, port, status);
 	}
@@ -141,23 +140,24 @@
 		usb_hub_port_reset_completed(hub, port, status);
 	}
-	usb_log_debug("status x%x : %d\n ", status, status);
+	usb_log_debug("Status x%x : %d\n ", status, status);
 
 	usb_port_status_set_bit(
-	    &status, USB_HUB_FEATURE_C_PORT_CONNECTION,false);
+	    &status, USB_HUB_FEATURE_C_PORT_CONNECTION, false);
 	usb_port_status_set_bit(
-	    &status, USB_HUB_FEATURE_C_PORT_RESET,false);
+	    &status, USB_HUB_FEATURE_C_PORT_RESET, false);
 	usb_port_status_set_bit(
-	    &status, USB_HUB_FEATURE_C_PORT_OVER_CURRENT,false);
-	
+	    &status, USB_HUB_FEATURE_C_PORT_OVER_CURRENT, false);
+
 	//clearing not yet handled changes	
 	unsigned int feature_idx;
-	for(feature_idx = 0;feature_idx<non_handled_changes_count;
-	    ++feature_idx){
+	for (feature_idx = 0;
+	    feature_idx < non_handled_changes_count;
+	    ++feature_idx) {
 		unsigned int bit_idx = non_handled_changes[feature_idx];
-		if(status & (1<<bit_idx)){
+		if (status & (1 << bit_idx)) {
 			usb_log_info(
-			    "there was not yet handled change on port %d: %d"
+			    "There was not yet handled change on port %d: %d"
 			    ";clearing it\n",
-			port, bit_idx);
+			    port, bit_idx);
 			int opResult = usb_hub_clear_port_feature(
 			    hub->control_pipe,
@@ -165,18 +165,17 @@
 			if (opResult != EOK) {
 				usb_log_warning(
-				    "could not clear port flag %d: %d\n",
-				    bit_idx, opResult
+				    "Could not clear port flag %d: %s\n",
+				    bit_idx, str_error(opResult)
 				    );
 			}
 			usb_port_status_set_bit(
-			    &status, bit_idx,false);
+			    &status, bit_idx, false);
 		}
 	}
-	if(status>>16){
-		usb_log_info("there is still some unhandled change %X\n",
+	if (status >> 16) {
+		usb_log_info("There is still some unhandled change %X\n",
 		    status);
 	}
 }
-
 
 /**
@@ -190,10 +189,10 @@
  */
 static void usb_hub_removed_device(
-	usb_hub_info_t * hub, uint16_t port) {
+    usb_hub_info_t *hub, uint16_t port) {
 
 	int opResult = usb_hub_clear_port_feature(hub->control_pipe,
-		port, USB_HUB_FEATURE_C_PORT_CONNECTION);
+	    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
 	if (opResult != EOK) {
-		usb_log_warning("could not clear port-change-connection flag\n");
+		usb_log_warning("Could not clear port-change-connection flag\n");
 	}
 	/** \TODO remove device from device manager - not yet implemented in
@@ -202,17 +201,15 @@
 
 	//close address
-	if(hub->ports[port].attached_device.address >= 0){
-		/*uncomment this code to use it when DDF allows device removal
-		opResult = usb_hc_unregister_device(
-			&hub->connection,
-			hub->attached_devs[port].address);
-		if(opResult != EOK) {
-			dprintf(USB_LOG_LEVEL_WARNING, "could not release "
-				"address of "
-			    "removed device: %d", opResult);
-		}
-		hub->attached_devs[port].address = 0;
-		hub->attached_devs[port].handle = 0;
-		 */
+
+	usb_hub_port_t *the_port = hub->ports + port;
+
+	fibril_mutex_lock(&hub->port_mutex);
+
+	if (the_port->attached_device.address >= 0) {
+		usb_log_warning("Device unplug on `%s' (port %zu): " \
+		    "not implemented.\n", hub->usb_device->ddf_dev->name,
+		    (size_t) port);
+		the_port->attached_device.address = -1;
+		the_port->attached_device.handle = 0;
 	} else {
 		usb_log_warning("Device removed before being registered.\n");
@@ -223,5 +220,4 @@
 		 * port reset callback from new device wrapper.
 		 */
-		usb_hub_port_t *the_port = hub->ports + port;
 		fibril_mutex_lock(&the_port->reset_mutex);
 		the_port->reset_completed = true;
@@ -230,6 +226,7 @@
 		fibril_mutex_unlock(&the_port->reset_mutex);
 	}
-}
-
+
+	fibril_mutex_unlock(&hub->port_mutex);
+}
 
 /**
@@ -242,6 +239,6 @@
  * @param status
  */
-static void usb_hub_port_reset_completed(usb_hub_info_t * hub,
-	uint16_t port, uint32_t status){
+static void usb_hub_port_reset_completed(usb_hub_info_t *hub,
+    uint16_t port, uint32_t status) {
 	usb_log_debug("Port %zu reset complete.\n", (size_t) port);
 	if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) {
@@ -275,20 +272,20 @@
  * @param port port number, starting from 1
  */
-static void usb_hub_port_over_current(usb_hub_info_t * hub,
-	uint16_t port, uint32_t status) {
+static void usb_hub_port_over_current(usb_hub_info_t *hub,
+    uint16_t port, uint32_t status) {
 	int opResult;
-	if(usb_port_is_status(status, USB_HUB_FEATURE_PORT_OVER_CURRENT)){
+	if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_OVER_CURRENT)) {
 		opResult = usb_hub_clear_port_feature(hub->control_pipe,
-			port, USB_HUB_FEATURE_PORT_POWER);
+		    port, USB_HUB_FEATURE_PORT_POWER);
 		if (opResult != EOK) {
-			usb_log_error("cannot power off port %d;  %d\n",
-				port, opResult);
+			usb_log_error("Cannot power off port %d; %s\n",
+			    port, str_error(opResult));
 		}
-	}else{
+	} else {
 		opResult = usb_hub_set_port_feature(hub->control_pipe,
-			port, USB_HUB_FEATURE_PORT_POWER);
+		    port, USB_HUB_FEATURE_PORT_POWER);
 		if (opResult != EOK) {
-			usb_log_error("cannot power on port %d;  %d\n",
-				port, opResult);
+			usb_log_error("Cannot power on port %d; %s\n",
+			    port, str_error(opResult));
 		}
 	}
@@ -303,6 +300,5 @@
  */
 static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port,
-    usb_port_status_t *status)
-{
+    usb_port_status_t *status) {
 	size_t recv_size;
 	usb_device_request_setup_packet_t request;
@@ -311,6 +307,6 @@
 	usb_hub_set_port_status_request(&request, port);
 	int rc = usb_pipe_control_read(ctrl_pipe,
-	    &request, sizeof(usb_device_request_setup_packet_t),
-	    &status_tmp, sizeof(status_tmp), &recv_size);
+	    &request, sizeof (usb_device_request_setup_packet_t),
+	    &status_tmp, sizeof (status_tmp), &recv_size);
 	if (rc != EOK) {
 		return rc;
@@ -337,6 +333,5 @@
  * @return Error code.
  */
-static int enable_port_callback(int port_no, void *arg)
-{
+static int enable_port_callback(int port_no, void *arg) {
 	usb_hub_info_t *hub = arg;
 	int rc;
@@ -346,5 +341,5 @@
 	usb_hub_set_reset_port_request(&request, port_no);
 	rc = usb_pipe_control_write(hub->control_pipe,
-	    &request, sizeof(request), NULL, 0);
+	    &request, sizeof (request), NULL, 0);
 	if (rc != EOK) {
 		usb_log_warning("Port reset failed: %s.\n", str_error(rc));
@@ -376,6 +371,5 @@
  * @return 0 Always.
  */
-static int add_device_phase1_worker_fibril(void *arg)
-{
+static int add_device_phase1_worker_fibril(void *arg) {
 	struct add_device_phase1 *data
 	    = (struct add_device_phase1 *) arg;
@@ -396,6 +390,8 @@
 	}
 
+	fibril_mutex_lock(&data->hub->port_mutex);
 	data->hub->ports[data->port].attached_device.handle = child_handle;
 	data->hub->ports[data->port].attached_device.address = new_address;
+	fibril_mutex_unlock(&data->hub->port_mutex);
 
 	usb_log_info("Detected new device on `%s' (port %zu), "
@@ -407,7 +403,13 @@
 	free(arg);
 
+	fibril_mutex_lock(&data->hub->pending_ops_mutex);
+	assert(data->hub->pending_ops_count > 0);
+	data->hub->pending_ops_count--;
+	fibril_condvar_signal(&data->hub->pending_ops_cv);
+	fibril_mutex_unlock(&data->hub->pending_ops_mutex);
+
+
 	return EOK;
 }
-
 
 /** Start device adding when connection change is detected.
@@ -421,8 +423,7 @@
  */
 static int create_add_device_fibril(usb_hub_info_t *hub, size_t port,
-    usb_speed_t speed)
-{
+    usb_speed_t speed) {
 	struct add_device_phase1 *data
-	    = malloc(sizeof(struct add_device_phase1));
+	    = malloc(sizeof (struct add_device_phase1));
 	if (data == NULL) {
 		return ENOMEM;
@@ -452,4 +453,7 @@
 		return ENOMEM;
 	}
+	fibril_mutex_lock(&hub->pending_ops_mutex);
+	hub->pending_ops_count++;
+	fibril_mutex_unlock(&hub->pending_ops_mutex);
 	fibril_add_ready(fibril);
 
Index: uspace/drv/usbhub/ports.h
===================================================================
--- uspace/drv/usbhub/ports.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/ports.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -70,5 +70,5 @@
 
 
-void usb_hub_process_interrupt(usb_hub_info_t * hub,
+void usb_hub_process_interrupt(usb_hub_info_t *hub,
 	uint16_t port);
 
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/usbhub.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -56,22 +56,22 @@
 
 
-static usb_hub_info_t * usb_hub_info_create(usb_device_t * usb_dev);
-
-static int usb_hub_process_hub_specific_info(usb_hub_info_t * hub_info);
-
-static int usb_hub_set_configuration(usb_hub_info_t * hub_info);
-
-static int usb_hub_start_hub_fibril(usb_hub_info_t * hub_info);
-
-static int usb_process_hub_over_current(usb_hub_info_t * hub_info,
+static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev);
+
+static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info);
+
+static int usb_hub_set_configuration(usb_hub_info_t *hub_info);
+
+static int usb_hub_start_hub_fibril(usb_hub_info_t *hub_info);
+
+static int usb_process_hub_over_current(usb_hub_info_t *hub_info,
     usb_hub_status_t status);
 
-static int usb_process_hub_local_power_change(usb_hub_info_t * hub_info,
+static int usb_process_hub_local_power_change(usb_hub_info_t *hub_info,
     usb_hub_status_t status);
 
-static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info);
-
-static void usb_hub_polling_terminted_callback(usb_device_t * device,
-    bool was_error, void * data);
+static void usb_hub_process_global_interrupt(usb_hub_info_t *hub_info);
+
+static void usb_hub_polling_terminated_callback(usb_device_t *device,
+    bool was_error, void *data);
 
 
@@ -90,7 +90,7 @@
  * @return error code
  */
-int usb_hub_add_device(usb_device_t * usb_dev) {
+int usb_hub_add_device(usb_device_t *usb_dev) {
 	if (!usb_dev) return EINVAL;
-	usb_hub_info_t * hub_info = usb_hub_info_create(usb_dev);
+	usb_hub_info_t *hub_info = usb_hub_info_create(usb_dev);
 	//create hc connection
 	usb_log_debug("Initializing USB wire abstraction.\n");
@@ -99,7 +99,7 @@
 	    hub_info->usb_device->ddf_dev);
 	if (opResult != EOK) {
-		usb_log_error("could not initialize connection to device, "
-		    "errno %d\n",
-		    opResult);
+		usb_log_error("Could not initialize connection to device, "
+		    " %s\n",
+		    str_error(opResult));
 		free(hub_info);
 		return opResult;
@@ -109,6 +109,6 @@
 	opResult = usb_hub_set_configuration(hub_info);
 	if (opResult != EOK) {
-		usb_log_error("could not set hub configuration, errno %d\n",
-		    opResult);
+		usb_log_error("Could not set hub configuration, %s\n",
+		    str_error(opResult));
 		free(hub_info);
 		return opResult;
@@ -117,6 +117,6 @@
 	opResult = usb_hub_process_hub_specific_info(hub_info);
 	if (opResult != EOK) {
-		usb_log_error("could process hub specific info, errno %d\n",
-		    opResult);
+		usb_log_error("Could process hub specific info, %s\n",
+		    str_error(opResult));
 		free(hub_info);
 		return opResult;
@@ -135,9 +135,8 @@
 
 	opResult = usb_hub_start_hub_fibril(hub_info);
-	if(opResult!=EOK)
+	if (opResult != EOK)
 		free(hub_info);
 	return opResult;
 }
-
 
 /** Callback for polling hub for changes.
@@ -193,6 +192,6 @@
  * @return basic usb_hub_info_t structure
  */
-static usb_hub_info_t * usb_hub_info_create(usb_device_t * usb_dev) {
-	usb_hub_info_t * result = malloc(sizeof(usb_hub_info_t));
+static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev) {
+	usb_hub_info_t * result = malloc(sizeof (usb_hub_info_t));
 	if (!result) return NULL;
 	result->usb_device = usb_dev;
@@ -200,4 +199,12 @@
 	result->control_pipe = &usb_dev->ctrl_pipe;
 	result->is_default_address_used = false;
+
+	result->ports = NULL;
+	result->port_count = (size_t) - 1;
+	fibril_mutex_initialize(&result->port_mutex);
+
+	fibril_mutex_initialize(&result->pending_ops_mutex);
+	fibril_condvar_initialize(&result->pending_ops_cv);
+	result->pending_ops_count = 0;
 	return result;
 }
@@ -213,7 +220,7 @@
  * @return error code
  */
-static int usb_hub_process_hub_specific_info(usb_hub_info_t * hub_info) {
+static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info) {
 	// get hub descriptor
-	usb_log_debug("creating serialized descriptor\n");
+	usb_log_debug("Creating serialized descriptor\n");
 	uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
 	usb_hub_descriptor_t * descriptor;
@@ -227,11 +234,11 @@
 
 	if (opResult != EOK) {
-		usb_log_error("failed when receiving hub descriptor, "
-		    "badcode = %d\n",
-		    opResult);
+		usb_log_error("Failed when receiving hub descriptor, "
+		    "%s\n",
+		    str_error(opResult));
 		free(serialized_descriptor);
 		return opResult;
 	}
-	usb_log_debug2("deserializing descriptor\n");
+	usb_log_debug2("Deserializing descriptor\n");
 	descriptor = usb_create_deserialized_hub_desriptor(
 	    serialized_descriptor);
@@ -244,10 +251,10 @@
 	/// \TODO this is not semantically correct
 	bool is_power_switched =
-	    ((descriptor->hub_characteristics & 1) ==0);
+	    ((descriptor->hub_characteristics & 1) == 0);
 	bool has_individual_port_powering =
-	    ((descriptor->hub_characteristics & 1) !=0);
+	    ((descriptor->hub_characteristics & 1) != 0);
 	hub_info->ports = malloc(
 	    sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
-	if(!hub_info->ports){
+	if (!hub_info->ports) {
 		return ENOMEM;
 	}
@@ -256,13 +263,13 @@
 		usb_hub_port_init(&hub_info->ports[port]);
 	}
-	if(is_power_switched){
-		usb_log_debug("is_power_switched\n");
-		
-		if(!has_individual_port_powering){
-			usb_log_debug("!has_individual_port_powering\n");
+	if (is_power_switched) {
+		usb_log_debug("Hub power switched\n");
+
+		if (!has_individual_port_powering) {
+			usb_log_debug("Has_global 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: %s\n",
+				usb_log_error("Cannot power hub: %s\n",
 				    str_error(opResult));
 			}
@@ -270,5 +277,5 @@
 
 		for (port = 1; port <= hub_info->port_count; ++port) {
-			usb_log_debug("Powering port %zu.\n",port);
+			usb_log_debug("Powering port %zu.\n", port);
 			opResult = usb_hub_set_port_feature(hub_info->control_pipe,
 			    port, USB_HUB_FEATURE_PORT_POWER);
@@ -278,9 +285,9 @@
 			}
 		}
-		
-	}else{
-		usb_log_debug("!is_power_switched, not going to be powered\n");
-	}
-	usb_log_debug2("freeing data\n");
+
+	} else {
+		usb_log_debug("Power not switched, not going to be powered\n");
+	}
+	usb_log_debug2("Freeing data\n");
 	free(descriptor);
 	return EOK;
@@ -295,12 +302,12 @@
  * @return error code
  */
-static int usb_hub_set_configuration(usb_hub_info_t * hub_info) {
+static int usb_hub_set_configuration(usb_hub_info_t *hub_info) {
 	//device descriptor
 	usb_standard_device_descriptor_t *std_descriptor
 	    = &hub_info->usb_device->descriptors.device;
-	usb_log_debug("hub has %d configurations\n",
+	usb_log_debug("Hub has %d configurations\n",
 	    std_descriptor->configuration_count);
 	if (std_descriptor->configuration_count < 1) {
-		usb_log_error("there are no configurations available\n");
+		usb_log_error("There are no configurations available\n");
 		return EINVAL;
 	}
@@ -320,5 +327,5 @@
 		return opResult;
 	}
-	usb_log_debug("\tused configuration %d\n",
+	usb_log_debug("\tUsed configuration %d\n",
 	    config_descriptor->configuration_number);
 
@@ -335,10 +342,10 @@
  * @return error code
  */
-static int usb_hub_start_hub_fibril(usb_hub_info_t * hub_info){
+static int usb_hub_start_hub_fibril(usb_hub_info_t *hub_info) {
 	int rc;
 
 	rc = usb_device_auto_poll(hub_info->usb_device, 0,
 	    hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1,
-	    usb_hub_polling_terminted_callback, hub_info);
+	    usb_hub_polling_terminated_callback, hub_info);
 	if (rc != EOK) {
 		usb_log_error("Failed to create polling fibril: %s.\n",
@@ -359,5 +366,4 @@
 //*********************************************
 
-
 /**
  * process hub over current change
@@ -368,18 +374,18 @@
  * @return error code
  */
-static int usb_process_hub_over_current(usb_hub_info_t * hub_info,
+static int usb_process_hub_over_current(usb_hub_info_t *hub_info,
     usb_hub_status_t status) {
 	int opResult;
-	if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_OVER_CURRENT)){
+	if (usb_hub_is_status(status, USB_HUB_FEATURE_HUB_OVER_CURRENT)) {
 		//poweroff all ports
 		unsigned int port;
-		for(port = 1;port <= hub_info->port_count;++port){
+		for (port = 1; port <= hub_info->port_count; ++port) {
 			opResult = usb_hub_clear_port_feature(
-			    hub_info->control_pipe,port,
+			    hub_info->control_pipe, port,
 			    USB_HUB_FEATURE_PORT_POWER);
 			if (opResult != EOK) {
 				usb_log_warning(
-				    "cannot power off port %d;  %d\n",
-				    port, opResult);
+				    "Cannot power off port %d;  %s\n",
+				    port, str_error(opResult));
 			}
 		}
@@ -387,12 +393,12 @@
 		//power all ports
 		unsigned int port;
-		for(port = 1;port <= hub_info->port_count;++port){
+		for (port = 1; port <= hub_info->port_count; ++port) {
 			opResult = usb_hub_set_port_feature(
-			    hub_info->control_pipe,port,
+			    hub_info->control_pipe, port,
 			    USB_HUB_FEATURE_PORT_POWER);
 			if (opResult != EOK) {
 				usb_log_warning(
-				    "cannot power off port %d;  %d\n",
-				    port, opResult);
+				    "Cannot power off port %d;  %s\n",
+				    port, str_error(opResult));
 			}
 		}
@@ -409,13 +415,13 @@
  * @return error code
  */
-static int usb_process_hub_local_power_change(usb_hub_info_t * hub_info,
+static int usb_process_hub_local_power_change(usb_hub_info_t *hub_info,
     usb_hub_status_t status) {
 	int opResult = EOK;
 	opResult = usb_hub_clear_feature(hub_info->control_pipe,
 	    USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
-		if (opResult != EOK) {
-		usb_log_error("cannnot clear hub power change flag: "
-		    "%d\n",
-		    opResult);
+	if (opResult != EOK) {
+		usb_log_error("Cannnot clear hub power change flag: "
+		    "%s\n",
+		    str_error(opResult));
 	}
 	return opResult;
@@ -429,6 +435,6 @@
  * @param hub_info hub instance
  */
-static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info) {
-	usb_log_debug("global interrupt on a hub\n");
+static void usb_hub_process_global_interrupt(usb_hub_info_t *hub_info) {
+	usb_log_debug("Global interrupt on a hub\n");
 	usb_pipe_t *pipe = hub_info->control_pipe;
 	int opResult;
@@ -447,18 +453,19 @@
 	    );
 	if (opResult != EOK) {
-		usb_log_error("could not get hub status\n");
+		usb_log_error("Could not get hub status: %s\n",
+		    str_error(opResult));
 		return;
 	}
 	if (rcvd_size != sizeof (usb_port_status_t)) {
-		usb_log_error("received status has incorrect size\n");
+		usb_log_error("Received status has incorrect size\n");
 		return;
 	}
 	//port reset
 	if (
-	    usb_hub_is_status(status,16+USB_HUB_FEATURE_C_HUB_OVER_CURRENT)) {
+	    usb_hub_is_status(status, 16 + USB_HUB_FEATURE_C_HUB_OVER_CURRENT)) {
 		usb_process_hub_over_current(hub_info, status);
 	}
 	if (
-	    usb_hub_is_status(status,16+USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) {
+	    usb_hub_is_status(status, 16 + USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) {
 		usb_process_hub_local_power_change(hub_info, status);
 	}
@@ -473,10 +480,43 @@
  * @param data pointer to usb_hub_info_t structure
  */
-static void usb_hub_polling_terminted_callback(usb_device_t * device,
-    bool was_error, void * data){
-	usb_hub_info_t * hub_info = data;
-	if(!hub_info) return;
-	free(hub_info->ports);
-	free(hub_info);
+static void usb_hub_polling_terminated_callback(usb_device_t *device,
+    bool was_error, void *data) {
+	usb_hub_info_t * hub = data;
+	assert(hub);
+
+	fibril_mutex_lock(&hub->pending_ops_mutex);
+
+	/* The device is dead. However there might be some pending operations
+	 * that we need to wait for.
+	 * One of them is device adding in progress.
+	 * The respective fibril is probably waiting for status change
+	 * in port reset (port enable) callback.
+	 * Such change would never come (otherwise we would not be here).
+	 * Thus, we would flush all pending port resets.
+	 */
+	if (hub->pending_ops_count > 0) {
+		fibril_mutex_lock(&hub->port_mutex);
+		size_t port;
+		for (port = 0; port < hub->port_count; port++) {
+			usb_hub_port_t *the_port = hub->ports + port;
+			fibril_mutex_lock(&the_port->reset_mutex);
+			the_port->reset_completed = true;
+			the_port->reset_okay = false;
+			fibril_condvar_broadcast(&the_port->reset_cv);
+			fibril_mutex_unlock(&the_port->reset_mutex);
+		}
+		fibril_mutex_unlock(&hub->port_mutex);
+	}
+	/* And now wait for them. */
+	while (hub->pending_ops_count > 0) {
+		fibril_condvar_wait(&hub->pending_ops_cv,
+		    &hub->pending_ops_mutex);
+	}
+	fibril_mutex_unlock(&hub->pending_ops_mutex);
+
+	usb_device_destroy(hub->usb_device);
+
+	free(hub->ports);
+	free(hub);
 }
 
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/usbhub.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -51,8 +51,6 @@
 #include "ports.h"
 
-
-
 /** Information about attached hub. */
-struct usb_hub_info_t{
+struct usb_hub_info_t {
 	/** Number of ports. */
 	size_t port_count;
@@ -60,4 +58,6 @@
 	/** attached device handles, for each port one */
 	usb_hub_port_t *ports;
+
+	fibril_mutex_t port_mutex;
 
 	/** connection to hcd */
@@ -89,9 +89,20 @@
 	/** generic usb device data*/
 	usb_device_t * usb_device;
+
+	/** Number of pending operations on the mutex to prevent shooting
+	 * ourselves in the foot.
+	 * When the hub is disconnected but we are in the middle of some
+	 * operation, we cannot destroy this structure right away because
+	 * the pending operation might use it.
+	 */
+	size_t pending_ops_count;
+	/** Guard for pending_ops_count. */
+	fibril_mutex_t pending_ops_mutex;
+	/** Condition variable for pending_ops_count. */
+	fibril_condvar_t pending_ops_cv;
+
 };
 
-//int usb_hub_control_loop(void * hub_info_param);
-
-int usb_hub_add_device(usb_device_t * usb_dev);
+int usb_hub_add_device(usb_device_t *usb_dev);
 
 bool hub_port_changes_callback(usb_device_t *dev,
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -65,6 +65,6 @@
  */
 static inline void usb_hub_set_descriptor_request(
-usb_device_request_setup_packet_t * request
-){
+    usb_device_request_setup_packet_t * request
+    ) {
 	request->index = 0;
 	request->request_type = USB_HUB_REQ_TYPE_GET_DESCRIPTOR;
@@ -87,5 +87,5 @@
     int port_index,
     usb_hub_class_feature_t feature) {
-	
+
 	usb_device_request_setup_packet_t clear_request = {
 		.request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
@@ -96,5 +96,5 @@
 	clear_request.value = feature;
 	return usb_pipe_control_write(pipe, &clear_request,
-	    sizeof(clear_request), NULL, 0);
+	    sizeof (clear_request), NULL, 0);
 }
 
@@ -120,7 +120,6 @@
 	clear_request.value = feature;
 	return usb_pipe_control_write(pipe, &clear_request,
-	    sizeof(clear_request), NULL, 0);
+	    sizeof (clear_request), NULL, 0);
 }
-
 
 /**
@@ -142,5 +141,5 @@
 	clear_request.value = feature;
 	return usb_pipe_control_write(pipe, &clear_request,
-	    sizeof(clear_request), NULL, 0);
+	    sizeof (clear_request), NULL, 0);
 }
 
@@ -163,5 +162,5 @@
 	clear_request.value = feature;
 	return usb_pipe_control_write(pipe, &clear_request,
-	    sizeof(clear_request), NULL, 0);
+	    sizeof (clear_request), NULL, 0);
 }
 
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbhub/utils.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -62,14 +62,14 @@
  * @return newly created serializd descriptor pointer
  */
-void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * descriptor) {
+void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t *descriptor) {
 	//base size
 	size_t size = 7;
 	//variable size according to port count
-	size_t var_size = (descriptor->ports_count+7)/8;
+	size_t var_size = (descriptor->ports_count + 7) / 8;
 	size += 2 * var_size;
 	uint8_t * result = malloc(size);
 	//size
-	if(result)
-		usb_serialize_hub_descriptor(descriptor,result);
+	if (result)
+		usb_serialize_hub_descriptor(descriptor, result);
 	return result;
 }
@@ -82,5 +82,5 @@
  * @param serialized_descriptor
  */
-void usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor,
+void usb_serialize_hub_descriptor(usb_hub_descriptor_t *descriptor,
     void * serialized_descriptor) {
 	//base size
@@ -88,5 +88,5 @@
 	size_t size = 7;
 	//variable size according to port count
-	size_t var_size = (descriptor->ports_count+7)/8;
+	size_t var_size = (descriptor->ports_count + 7) / 8;
 	size += 2 * var_size;
 	//size
@@ -110,5 +110,4 @@
 }
 
-
 /**
  * create deserialized desriptor structure out of serialized descriptor
@@ -121,5 +120,5 @@
  */
 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor(
-void * serialized_descriptor) {
+    void *serialized_descriptor) {
 	uint8_t * sdescriptor = serialized_descriptor;
 
@@ -130,7 +129,7 @@
 	}
 
-	usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t));
-	if(result)
-		usb_deserialize_hub_desriptor(serialized_descriptor,result);
+	usb_hub_descriptor_t * result = malloc(sizeof (usb_hub_descriptor_t));
+	if (result)
+		usb_deserialize_hub_desriptor(serialized_descriptor, result);
 	return result;
 }
@@ -144,5 +143,5 @@
  */
 void usb_deserialize_hub_desriptor(
-void * serialized_descriptor, usb_hub_descriptor_t * descriptor) {
+    void * serialized_descriptor, usb_hub_descriptor_t *descriptor) {
 	uint8_t * sdescriptor = serialized_descriptor;
 	descriptor->ports_count = sdescriptor[2];
@@ -151,5 +150,5 @@
 	descriptor->pwr_on_2_good_time = sdescriptor[5];
 	descriptor->current_requirement = sdescriptor[6];
-	size_t var_size = (descriptor->ports_count+7) / 8;
+	size_t var_size = (descriptor->ports_count + 7) / 8;
 	//descriptor->devices_removable = (uint8_t*) malloc(var_size);
 
Index: uspace/drv/usbmouse/init.c
===================================================================
--- uspace/drv/usbmouse/init.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbmouse/init.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -39,4 +39,5 @@
 #include <usb/hid/hid.h>
 #include <usb/dev/request.h>
+#include <usb/hid/request.h>
 #include <errno.h>
 
@@ -126,8 +127,6 @@
 	
 	/* Set the boot protocol. */
-	rc = usb_control_request_set(&dev->ctrl_pipe,
-	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
-	    USB_HIDREQ_SET_PROTOCOL, USB_HID_PROTOCOL_BOOT, dev->interface_no,
-	    NULL, 0);
+	rc = usbhid_req_set_protocol(&dev->ctrl_pipe, dev->interface_no,
+	    USB_HID_PROTOCOL_BOOT);
 	if (rc != EOK) {
 		goto leave;
Index: uspace/drv/usbmouse/mouse.c
===================================================================
--- uspace/drv/usbmouse/mouse.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/drv/usbmouse/mouse.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -117,4 +117,6 @@
 	async_hangup(mouse->console_phone);
 	mouse->console_phone = -1;
+
+	usb_device_destroy(dev);
 }
 
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/lib/drv/generic/driver.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -405,5 +405,6 @@
 				/* The interface has not such method */
 				printf("%s: driver_connection_gen error - "
-				    "invalid interface method (%d).\n",
+				    "invalid interface method "
+				    "(index %" PRIun ").\n",
 				    driver->name, iface_method_idx);
 				async_answer_0(callid, ENOTSUP);
Index: uspace/lib/drv/include/usbhc_iface.h
===================================================================
--- uspace/lib/drv/include/usbhc_iface.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/lib/drv/include/usbhc_iface.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -212,6 +212,4 @@
 /** USB host controller communication interface. */
 typedef struct {
-	int (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
-	int (*release_default_address)(ddf_fun_t *);
 	int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
 	int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
Index: uspace/lib/usbdev/include/usb/dev/driver.h
===================================================================
--- uspace/lib/usbdev/include/usb/dev/driver.h	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/lib/usbdev/include/usb/dev/driver.h	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -168,4 +168,5 @@
 int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
 int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
+void usb_device_destroy(usb_device_t *);
 
 size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
Index: uspace/lib/usbdev/src/devdrv.c
===================================================================
--- uspace/lib/usbdev/src/devdrv.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/lib/usbdev/src/devdrv.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -533,4 +533,30 @@
 }
 
+/** Destroy instance of a USB device.
+ *
+ * @param dev Device to be destroyed.
+ */
+void usb_device_destroy(usb_device_t *dev)
+{
+	if (dev == NULL) {
+		return;
+	}
+
+	/* Ignore errors and hope for the best. */
+	usb_device_destroy_pipes(dev->ddf_dev, dev->pipes, dev->pipes_count);
+	if (dev->descriptors.configuration != NULL) {
+		free(dev->descriptors.configuration);
+	}
+
+	if (dev->alternate_interfaces != NULL) {
+		if (dev->alternate_interfaces->alternatives != NULL) {
+			free(dev->alternate_interfaces->alternatives);
+		}
+		free(dev->alternate_interfaces);
+	}
+
+	free(dev);
+}
+
 /**
  * @}
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision ee7e7c938e9c9fc3ee28e22c006c58cff0af78e2)
+++ uspace/srv/hid/console/console.c	(revision 3dfdcb7a268cced0bd9725c94906e5ec64bced86)
@@ -57,4 +57,5 @@
 #include <io/style.h>
 #include <io/screenbuffer.h>
+#include <inttypes.h>
 
 #include "console.h"
@@ -67,4 +68,9 @@
 /** Interval for checking for new keyboard (1/4s). */
 #define HOTPLUG_WATCH_INTERVAL (1000 * 250)
+
+/* Kernel defines 32 but does not export it. */
+#define MAX_IPC_OUTGOING_PHONES 128
+/** To allow proper phone closing. */
+static ipc_callid_t driver_phones[MAX_IPC_OUTGOING_PHONES] = { 0 };
 
 /** Phone to the keyboard driver. */
@@ -90,4 +96,6 @@
 	                               contents and related settings. */
 } console_t;
+
+
 
 /** Array of data for virtual consoles */
@@ -401,4 +409,17 @@
 }
 
+static void close_driver_phone(ipc_callid_t hash)
+{
+	int i;
+	for (i = 0; i < MAX_IPC_OUTGOING_PHONES; i++) {
+		if (driver_phones[i] == hash) {
+			printf("Device %" PRIxn " gone.\n", hash);
+			driver_phones[i] = 0;
+			async_hangup(i);
+			return;
+		}
+	}
+}
+
 /** Handler for keyboard */
 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
@@ -415,4 +436,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
+			close_driver_phone(iid);
 			return;
 		case KBD_EVENT:
@@ -458,4 +480,5 @@
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
+			close_driver_phone(iid);
 			return;
 		case MEVENT_BUTTON:
@@ -715,4 +738,25 @@
 }
 
+static int async_connect_to_me_hack(int phone, sysarg_t arg1, sysarg_t arg2,
+sysarg_t arg3, async_client_conn_t client_receiver, ipc_callid_t *hash)
+{
+	sysarg_t task_hash;
+	sysarg_t phone_hash;
+	int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
+	    NULL, NULL, NULL, &task_hash, &phone_hash);
+	if (rc != EOK)
+		return rc;
+
+	if (client_receiver != NULL)
+		async_new_connection(task_hash, phone_hash, phone_hash, NULL,
+		    client_receiver);
+
+	if (hash != NULL) {
+		*hash = phone_hash;
+	}
+
+	return EOK;
+}
+
 static int connect_keyboard_or_mouse(const char *devname,
     async_client_conn_t handler, const char *path)
@@ -729,5 +773,7 @@
 	}
 	
-	int rc = async_connect_to_me(phone, SERVICE_CONSOLE, 0, 0, handler);
+	ipc_callid_t hash;
+	int rc = async_connect_to_me_hack(phone, SERVICE_CONSOLE, 0, phone,
+	    handler, &hash);
 	if (rc != EOK) {
 		printf(NAME ": " \
@@ -737,5 +783,7 @@
 	}
 	
-	printf(NAME ": found %s \"%s\".\n", devname, path);
+	driver_phones[phone] = hash;
+
+	printf(NAME ": found %s \"%s\" (%" PRIxn ").\n", devname, path, hash);
 
 	return phone;
