Index: uspace/app/usbinfo/dev.c
===================================================================
--- uspace/app/usbinfo/dev.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/app/usbinfo/dev.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -50,4 +50,5 @@
 
 	int rc;
+	bool transfer_started = false;
 
 	rc = usb_device_connection_initialize(&dev->wire, hc_handle, dev_addr);
@@ -76,11 +77,12 @@
 	}
 
-	rc = usb_pipe_start_session(&dev->ctrl_pipe);
+	rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
 	if (rc != EOK) {
 		fprintf(stderr,
-		    NAME ": failed to start session on control pipe: %s.\n",
+		    NAME ": failed to start transfer on control pipe: %s.\n",
 		    str_error(rc));
 		goto leave;
 	}
+	transfer_started = true;
 
 	rc = usb_request_get_device_descriptor(&dev->ctrl_pipe,
@@ -107,6 +109,6 @@
 
 leave:
-	if (usb_pipe_is_session_started(&dev->ctrl_pipe)) {
-		usb_pipe_end_session(&dev->ctrl_pipe);
+	if (transfer_started) {
+		usb_pipe_end_long_transfer(&dev->ctrl_pipe);
 	}
 
@@ -118,5 +120,5 @@
 void destroy_device(usbinfo_device_t *dev)
 {
-	usb_pipe_end_session(&dev->ctrl_pipe);
+	usb_pipe_end_long_transfer(&dev->ctrl_pipe);
 	free(dev);
 }
Index: uspace/doc/doxygroups.h
===================================================================
--- uspace/doc/doxygroups.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/doc/doxygroups.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -269,4 +269,10 @@
 
 	/**
+	 * @defgroup drvusbohci OHCI driver
+	 * @ingroup usb
+	 * @brief Driver for OHCI host controller.
+	 */
+
+	/**
 	 * @defgroup drvusbehci EHCI driver
 	 * @ingroup usb
@@ -275,5 +281,5 @@
 
 	/**
-	 * @defgroup drvusbfallback USB fallback driver.
+	 * @defgroup drvusbfallback USB fallback driver
 	 * @ingroup usb
 	 * @brief Fallback driver for any USB device.
Index: uspace/drv/ehci-hcd/hc_iface.c
===================================================================
--- uspace/drv/ehci-hcd/hc_iface.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/ehci-hcd/hc_iface.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -123,4 +123,5 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] address USB address of the device.
+ * @param[in] speed Endpoint speed (invalid means to use device one).
  * @param[in] endpoint Endpoint number.
  * @param[in] transfer_type USB transfer type.
@@ -131,5 +132,5 @@
  */
 static int register_endpoint(ddf_fun_t *fun,
-    usb_address_t address, usb_endpoint_t endpoint,
+    usb_address_t address, usb_speed_t speed, usb_endpoint_t endpoint,
     usb_transfer_type_t transfer_type, usb_direction_t direction,
     size_t max_packet_size, unsigned int interval)
@@ -165,5 +166,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
  *	by the caller).
@@ -174,5 +174,5 @@
  */
 static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size, void *data, size_t size,
+    void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -191,5 +191,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] data Buffer where to store the data (in USB endianess,
  *	allocated and deallocated by the caller).
@@ -200,5 +199,5 @@
  */
 static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size, void *data, size_t size,
+    void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -217,5 +216,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
  *	by the caller).
@@ -226,5 +224,5 @@
  */
 static int bulk_out(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size, void *data, size_t size,
+    void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -243,5 +241,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] data Buffer where to store the data (in USB endianess,
  *	allocated and deallocated by the caller).
@@ -252,5 +249,5 @@
  */
 static int bulk_in(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size, void *data, size_t size,
+    void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -269,5 +266,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
  *	and deallocated by the caller).
@@ -281,5 +277,4 @@
  */
 static int control_write(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
     void *data_buffer, size_t data_buffer_size,
@@ -300,5 +295,4 @@
  * @param[in] fun Device function the action was invoked on.
  * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] max_packet_size Max packet size for the transfer.
  * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
  *	and deallocated by the caller).
@@ -312,5 +306,4 @@
  */
 static int control_read(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
     void *data_buffer, size_t data_buffer_size,
Index: uspace/drv/ohci/iface.c
===================================================================
--- uspace/drv/ohci/iface.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/ohci/iface.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -197,6 +197,18 @@
 }
 /*----------------------------------------------------------------------------*/
-static int register_endpoint(
-    ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
+/** Register endpoint for bandwidth reservation.
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] address USB address of the device.
+ * @param[in] ep_speed Endpoint speed (invalid means to use device one).
+ * @param[in] endpoint Endpoint number.
+ * @param[in] transfer_type USB transfer type.
+ * @param[in] direction Endpoint data direction.
+ * @param[in] max_packet_size Max packet size of the endpoint.
+ * @param[in] interval Polling interval.
+ * @return Error code.
+ */
+static int register_endpoint(ddf_fun_t *fun,
+    usb_address_t address, usb_speed_t ep_speed, usb_endpoint_t endpoint,
     usb_transfer_type_t transfer_type, usb_direction_t direction,
     size_t max_packet_size, unsigned int interval)
@@ -204,6 +216,10 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	const usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, address);
+	if (address == hc->rh.address)
+		return EOK;
+	usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address);
+	if (speed >= USB_SPEED_MAX) {
+		speed = ep_speed;
+	}
 	const size_t size =
 	    (transfer_type == USB_TRANSFER_INTERRUPT
@@ -243,21 +259,31 @@
 	usb_log_debug("Unregister endpoint %d:%d %d.\n",
 	    address, endpoint, direction);
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    address, endpoint, direction, NULL);
+	if (ep != NULL) {
+		usb_device_keeper_del_ep(&hc->manager, address, ep);
+	}
 	return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
 	    endpoint, direction);
 }
 /*----------------------------------------------------------------------------*/
-/** Interrupt out transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
- * @param[in] data Source of data.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion
- * @param[in] arg Additional for callback function.
+/** Schedule interrupt out transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
+ *	by the caller).
+ * @param[in] size Size of the @p data buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int interrupt_out(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -276,17 +302,22 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Interrupt in transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
- * @param[out] data Data destination.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion
- * @param[in] arg Additional for callback function.
+/** Schedule interrupt in transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] data Buffer where to store the data (in USB endianess,
+ *	allocated and deallocated by the caller).
+ * @param[in] size Size of the @p data buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int interrupt_in(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -305,17 +336,22 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Bulk out transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
- * @param[in] data Source of data.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion
- * @param[in] arg Additional for callback function.
+/** Schedule bulk out transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
+ *	by the caller).
+ * @param[in] size Size of the @p data buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int bulk_out(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -334,17 +370,22 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Bulk in transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
- * @param[out] data Data destination.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion
- * @param[in] arg Additional for callback function.
+/** Schedule bulk in transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] data Buffer where to store the data (in USB endianess,
+ *	allocated and deallocated by the caller).
+ * @param[in] size Size of the @p data buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int bulk_in(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -363,19 +404,25 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Control write transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts.
- * @param[in] setup_data Data to send with SETUP transfer.
- * @param[in] setup_size Size of data to send with SETUP transfer (always 8B).
- * @param[in] data Source of data.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion.
- * @param[in] arg Additional for callback function.
+/** Schedule control write transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
+ *	and deallocated by the caller).
+ * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
+ * @param[in] data_buffer Data buffer (in USB endianess, allocated and
+ *	deallocated by the caller).
+ * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int control_write(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
+    ddf_fun_t *fun, usb_target_t target,
     void *setup_data, size_t setup_size, void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
@@ -397,19 +444,25 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Control read transaction interface function
- *
- * @param[in] fun DDF function that was called.
- * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts.
- * @param[in] setup_data Data to send with SETUP packet.
- * @param[in] setup_size Size of data to send with SETUP packet (should be 8B).
- * @param[out] data Source of data.
- * @param[in] size Size of data source.
- * @param[in] callback Function to call on transaction completion.
- * @param[in] arg Additional for callback function.
+/** Schedule control read transfer.
+ *
+ * The callback is supposed to be called once the transfer (on the wire) is
+ * complete regardless of the outcome.
+ * However, the callback could be called only when this function returns
+ * with success status (i.e. returns EOK).
+ *
+ * @param[in] fun Device function the action was invoked on.
+ * @param[in] target Target pipe (address and endpoint number) specification.
+ * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
+ *	and deallocated by the caller).
+ * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
+ * @param[in] data_buffer Buffer where to store the data (in USB endianess,
+ *	allocated and deallocated by the caller).
+ * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
+ * @param[in] callback Callback to be issued once the transfer is complete.
+ * @param[in] arg Pass-through argument to the callback.
  * @return Error code.
  */
 static int control_read(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
+    ddf_fun_t *fun, usb_target_t target,
     void *setup_data, size_t setup_size, void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/ohci/root_hub.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -115,5 +115,6 @@
 
 static const uint32_t hub_set_feature_valid_mask =
-	(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+	(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
+(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
 
 
@@ -587,4 +588,6 @@
 	if (!((1 << feature) & hub_set_feature_valid_mask))
 		return EINVAL;
+	if(feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
+		feature = USB_HUB_FEATURE_C_HUB_LOCAL_POWER << 16;
 	instance->registers->rh_status =
 		(instance->registers->rh_status | (1 << feature))
Index: uspace/drv/uhci-hcd/iface.c
===================================================================
--- uspace/drv/uhci-hcd/iface.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/uhci-hcd/iface.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -74,6 +74,6 @@
 	    name, target.address, target.endpoint, size, ep->max_packet_size);
 
-	assert(ep->speed ==
-	    usb_device_keeper_get_speed(&(*hc)->manager, target.address));
+//	assert(ep->speed ==
+//	    usb_device_keeper_get_speed(&(*hc)->manager, target.address));
 //	assert(ep->max_packet_size == max_packet_size);
 //	assert(ep->transfer_type == USB_TRANSFER_CONTROL);
@@ -198,5 +198,6 @@
 /*----------------------------------------------------------------------------*/
 static int register_endpoint(
-    ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
+    ddf_fun_t *fun, usb_address_t address, usb_speed_t ep_speed,
+    usb_endpoint_t endpoint,
     usb_transfer_type_t transfer_type, usb_direction_t direction,
     size_t max_packet_size, unsigned int interval)
@@ -204,7 +205,12 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	const usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, address);
-	const size_t size = max_packet_size;
+	usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, address);
+	if (speed >= USB_SPEED_MAX) {
+		speed = ep_speed;
+	}
+	const size_t size =
+	    (transfer_type == USB_TRANSFER_INTERRUPT
+	    || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?
+	    max_packet_size : 0;
 	int ret;
 
@@ -240,4 +246,9 @@
 	usb_log_debug("Unregister endpoint %d:%d %d.\n",
 	    address, endpoint, direction);
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    address, endpoint, direction, NULL);
+	if (ep != NULL) {
+		usb_device_keeper_del_ep(&hc->manager, address, ep);
+	}
 	return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
 	    endpoint, direction);
@@ -248,5 +259,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
  * @param[in] data Source of data.
  * @param[in] size Size of data source.
@@ -256,5 +266,5 @@
  */
 static int interrupt_out(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -277,5 +287,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
  * @param[out] data Data destination.
  * @param[in] size Size of data source.
@@ -285,5 +294,5 @@
  */
 static int interrupt_in(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -306,5 +315,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
  * @param[in] data Source of data.
  * @param[in] size Size of data source.
@@ -314,5 +322,5 @@
  */
 static int bulk_out(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
@@ -335,5 +343,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts
  * @param[out] data Data destination.
  * @param[in] size Size of data source.
@@ -343,5 +350,5 @@
  */
 static int bulk_in(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data,
+    ddf_fun_t *fun, usb_target_t target, void *data,
     size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
@@ -364,5 +371,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts.
  * @param[in] setup_data Data to send with SETUP transfer.
  * @param[in] setup_size Size of data to send with SETUP transfer (always 8B).
@@ -374,5 +380,5 @@
  */
 static int control_write(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
+    ddf_fun_t *fun, usb_target_t target,
     void *setup_data, size_t setup_size, void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
@@ -398,5 +404,4 @@
  * @param[in] fun DDF function that was called.
  * @param[in] target USB device to write to.
- * @param[in] max_packet_size maximum size of data packet the device accepts.
  * @param[in] setup_data Data to send with SETUP packet.
  * @param[in] setup_size Size of data to send with SETUP packet (should be 8B).
@@ -408,5 +413,5 @@
  */
 static int control_read(
-    ddf_fun_t *fun, usb_target_t target, size_t max_packet_size,
+    ddf_fun_t *fun, usb_target_t target,
     void *setup_data, size_t setup_size, void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
Index: uspace/drv/usbhub/Makefile
===================================================================
--- uspace/drv/usbhub/Makefile	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/Makefile	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -34,7 +34,7 @@
 SOURCES = \
 	main.c \
-	ports.c \
 	utils.c \
-	usbhub.c
+	usbhub.c \
+	ports.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/port_status.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -49,4 +49,14 @@
 
 /**
+ * structure holding hub status and changes flags.
+ * should not be accessed directly, use supplied getter/setter methods.
+ *
+ * For more information refer to table 11.16.2.5 in
+ * "Universal Serial Bus Specification Revision 1.1"
+ *
+ */
+typedef uint32_t usb_hub_status_t;
+
+/**
  * set values in request to be it a port status request
  * @param request
@@ -54,6 +64,6 @@
  */
 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;
@@ -63,4 +73,18 @@
 }
 
+/**
+ * set values in request to be it a port status request
+ * @param request
+ * @param port
+ */
+static inline void usb_hub_set_hub_status_request(
+	usb_device_request_setup_packet_t * request
+	) {
+	request->index = 0;
+	request->request_type = USB_HUB_REQ_TYPE_GET_HUB_STATUS;
+	request->request = USB_HUB_REQUEST_GET_STATUS;
+	request->value = 0;
+	request->length = 4;
+}
 
 /**
@@ -70,12 +94,11 @@
  */
 static inline usb_device_request_setup_packet_t *
-usb_hub_create_port_status_request(uint16_t port){
+usb_hub_create_port_status_request(uint16_t port) {
 	usb_device_request_setup_packet_t * result =
-		usb_new(usb_device_request_setup_packet_t);
-	usb_hub_set_port_status_request(result,port);
+		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_hub_set_port_status_request(result, port);
 	return result;
 }
 
-
 /**
  * set the device request to be a port feature enable request
@@ -85,7 +108,7 @@
  */
 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;
@@ -102,7 +125,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;
@@ -118,6 +141,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;
@@ -133,8 +156,8 @@
  */
 static inline usb_device_request_setup_packet_t *
-usb_hub_create_enable_port_request(uint16_t port){
+usb_hub_create_enable_port_request(uint16_t port) {
 	usb_device_request_setup_packet_t * result =
-		usb_new(usb_device_request_setup_packet_t);
-	usb_hub_set_enable_port_request(result,port);
+		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_hub_set_enable_port_request(result, port);
 	return result;
 }
@@ -146,6 +169,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;
@@ -161,8 +184,8 @@
  */
 static inline usb_device_request_setup_packet_t *
-usb_hub_create_disable_port_request(uint16_t port){
+usb_hub_create_disable_port_request(uint16_t port) {
 	usb_device_request_setup_packet_t * result =
-		usb_new(usb_device_request_setup_packet_t);
-	usb_hub_set_disable_port_request(result,port);
+		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_hub_set_disable_port_request(result, port);
 	return result;
 }
@@ -174,6 +197,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;
@@ -189,8 +212,8 @@
  */
 static inline usb_device_request_setup_packet_t *
-usb_hub_create_reset_port_request(uint16_t port){
+usb_hub_create_reset_port_request(uint16_t port) {
 	usb_device_request_setup_packet_t * result =
-		usb_new(usb_device_request_setup_packet_t);
-	usb_hub_set_reset_port_request(result,port);
+		malloc(sizeof(usb_device_request_setup_packet_t));
+	usb_hub_set_reset_port_request(result, port);
 	return result;
 }
@@ -202,6 +225,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;
@@ -217,6 +240,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;
@@ -226,146 +249,433 @@
 }
 
-
-/** get i`th bit of port status */
-static inline bool usb_port_get_bit(usb_port_status_t * status, int idx)
-{
-	return (((*status)>>(idx))%2);
-}
-
-/** set i`th bit of port status */
-static inline void usb_port_set_bit(
-	usb_port_status_t * status, int idx, bool value)
-{
-	(*status) = value?
-		               ((*status)|(1<<(idx))):
-		               ((*status)&(~(1<<(idx))));
-}
-
-//device connnected on port
-static inline bool usb_port_dev_connected(usb_port_status_t * status){
-	return usb_port_get_bit(status,0);
-}
-
-static inline void usb_port_set_dev_connected(usb_port_status_t * status,bool connected){
-	usb_port_set_bit(status,0,connected);
+/**
+ * get i`th bit of port status
+ * 
+ * @param status
+ * @param idx
+ * @return
+ */
+static inline bool usb_port_is_status(usb_port_status_t status, int idx) {
+	return (status&(1 << idx))!=0;
+}
+
+/**
+ * set i`th bit of port status
+ * 
+ * @param status
+ * @param idx
+ * @param value
+ */
+static inline void usb_port_status_set_bit(
+	usb_port_status_t * status, int idx, bool value) {
+	(*status) = value ?
+		((*status) | (1 << (idx))) :
+		((*status)&(~(1 << (idx))));
+}
+
+/**
+ * get i`th bit of hub status
+ * 
+ * @param status
+ * @param idx
+ * @return
+ */
+static inline bool usb_hub_is_status(usb_hub_status_t status, int idx) {
+	return (status&(1 << idx))!=0;
+}
+
+/**
+ * set i`th bit of hub status
+ * 
+ * @param status
+ * @param idx
+ * @param value
+ */
+static inline void usb_hub_status_set_bit(
+	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
-static inline bool usb_port_enabled(usb_port_status_t * status){
-	return usb_port_get_bit(status,1);
-}
-
-static inline void usb_port_set_enabled(usb_port_status_t * status,bool enabled){
-	usb_port_set_bit(status,1,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
-static inline bool usb_port_suspended(usb_port_status_t * status){
-	return usb_port_get_bit(status,2);
-}
-
-static inline void usb_port_set_suspended(usb_port_status_t * status,bool suspended){
-	usb_port_set_bit(status,2,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
-static inline bool usb_port_over_current(usb_port_status_t * status){
-	return usb_port_get_bit(status,3);
-}
-
-static inline void usb_port_set_over_current(usb_port_status_t * status,bool value){
-	usb_port_set_bit(status,3,value);
+/**
+ * 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
-static inline bool usb_port_reset(usb_port_status_t * status){
-	return usb_port_get_bit(status,4);
-}
-
-static inline void usb_port_set_reset(usb_port_status_t * status,bool value){
-	usb_port_set_bit(status,4,value);
+/**
+ * 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
-static inline bool usb_port_powered(usb_port_status_t * status){
-	return usb_port_get_bit(status,8);
-}
-
-static inline void usb_port_set_powered(usb_port_status_t * status,bool powered){
-	usb_port_set_bit(status,8,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
-static inline bool usb_port_low_speed(usb_port_status_t * status){
-	return usb_port_get_bit(status,9);
-}
-
-static inline void usb_port_set_low_speed(usb_port_status_t * status,bool low_speed){
-	usb_port_set_bit(status,9,low_speed);
-}
-
-//low speed device attached
-static inline bool usb_port_high_speed(usb_port_status_t * status){
-	return usb_port_get_bit(status,10);
-}
-
-static inline void usb_port_set_high_speed(usb_port_status_t * status,bool high_speed){
-	usb_port_set_bit(status,10,high_speed);
-}
-
-static inline usb_speed_t usb_port_speed(usb_port_status_t * status){
-	if(usb_port_low_speed(status))
+/**
+ * low speed device on the port indicator
+ * 
+ * @param status
+ * @return true if low speed device is attached
+ */
+static inline bool usb_port_low_speed(usb_port_status_t status) {
+	return usb_port_is_status(status, 9);
+}
+
+/**
+ * set low speed device connected bit in port status
+ * 
+ * @param status
+ * @param low_speed value of the bit
+ */
+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
+ *
+ * @param status
+ * @return true if high speed device is on port
+ */
+static inline bool usb_port_high_speed(usb_port_status_t status) {
+	return usb_port_is_status(status, 10);
+}
+
+/**
+ * set high speed device bit in port status
+ *
+ * @param status
+ * @param high_speed value of the bit
+ */
+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);
+}
+
+/**
+ * speed getter for port status
+ *
+ * @param status
+ * @return speed of usb device (for more see usb specification)
+ */
+static inline usb_speed_t usb_port_speed(usb_port_status_t status) {
+	if (usb_port_low_speed(status))
 		return USB_SPEED_LOW;
-	if(usb_port_high_speed(status))
+	if (usb_port_high_speed(status))
 		return USB_SPEED_HIGH;
 	return USB_SPEED_FULL;
 }
 
-
+#if 0
 //connect change
-static inline bool usb_port_connect_change(usb_port_status_t * status){
-	return usb_port_get_bit(status,16);
-}
-
-static inline void usb_port_set_connect_change(usb_port_status_t * status,bool change){
-	usb_port_set_bit(status,16,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
-static inline bool usb_port_enabled_change(usb_port_status_t * status){
-	return usb_port_get_bit(status,17);
-}
-
-static inline void usb_port_set_enabled_change(usb_port_status_t * status,bool change){
-	usb_port_set_bit(status,17,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
-static inline bool usb_port_suspend_change(usb_port_status_t * status){
-	return usb_port_get_bit(status,18);
-}
-
-static inline void usb_port_set_suspend_change(usb_port_status_t * status,bool change){
-	usb_port_set_bit(status,18,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
-static inline bool usb_port_overcurrent_change(usb_port_status_t * status){
-	return usb_port_get_bit(status,19);
-}
-
-static inline void usb_port_set_overcurrent_change(usb_port_status_t * status,bool change){
-	usb_port_set_bit(status,19,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
-static inline bool usb_port_reset_completed(usb_port_status_t * status){
-	return usb_port_get_bit(status,20);
-}
-
-static inline void usb_port_set_reset_completed(usb_port_status_t * status,bool completed){
-	usb_port_set_bit(status,20,completed);
-}
-
+/**
+ * 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 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/ports.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -33,10 +33,214 @@
  * Hub ports functions.
  */
-#include "port_status.h"
-#include <inttypes.h>
+
+#include <bool.h>
 #include <errno.h>
 #include <str_error.h>
-#include <usb/request.h>
+#include <inttypes.h>
+#include <fibril_synch.h>
+
 #include <usb/debug.h>
+
+#include "ports.h"
+#include "usbhub.h"
+#include "usbhub_private.h"
+#include "port_status.h"
+
+
+/** Information for fibril for device discovery. */
+struct add_device_phase1 {
+	usb_hub_info_t *hub;
+	size_t port;
+	usb_speed_t speed;
+};
+
+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);
+
+static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port,
+    usb_port_status_t *status);
+
+static int enable_port_callback(int port_no, void *arg);
+
+static int add_device_phase1_worker_fibril(void *arg);
+
+static int create_add_device_fibril(usb_hub_info_t *hub, size_t port,
+    usb_speed_t speed);
+
+/**
+ * Process interrupts on given hub port
+ *
+ * Accepts connection, over current and port reset change.
+ * @param hub hub representation
+ * @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 %d\n", port);
+	//determine type of change
+	//usb_pipe_t *pipe = hub->control_pipe;
+
+	int opResult;
+
+	usb_port_status_t status;
+	opResult = get_port_status(&hub->usb_device->ctrl_pipe, port, &status);
+	if (opResult != EOK) {
+		usb_log_error("Failed to get port %zu status: %s.\n",
+		    port, str_error(opResult));
+		return;
+	}
+	//connection change
+	if (usb_port_is_status(status, USB_HUB_FEATURE_C_PORT_CONNECTION)) {
+		bool device_connected = usb_port_is_status(status,
+		    USB_HUB_FEATURE_PORT_CONNECTION);
+		usb_log_debug("Connection change on port %zu: %s.\n", port,
+		    device_connected ? "device attached" : "device removed");
+
+		if (device_connected) {
+			opResult = create_add_device_fibril(hub, port,
+			    usb_port_speed(status));
+			if (opResult != EOK) {
+				usb_log_error(
+				    "Cannot handle change on port %zu: %s.\n",
+				    str_error(opResult));
+			}
+		} else {
+			usb_hub_removed_device(hub, port);
+		}
+	}
+	//over current
+	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_hub_port_over_current(hub, port, status);
+	}
+	//port reset
+	if (usb_port_is_status(status, USB_HUB_FEATURE_C_PORT_RESET)) {
+		usb_hub_port_reset_completed(hub, port, status);
+	}
+	usb_log_debug("status x%x : %d\n ", status, status);
+
+	usb_port_status_set_bit(
+	    &status, USB_HUB_FEATURE_C_PORT_CONNECTION,false);
+	usb_port_status_set_bit(
+	    &status, USB_HUB_FEATURE_PORT_RESET,false);
+	usb_port_status_set_bit(
+	    &status, USB_HUB_FEATURE_C_PORT_RESET,false);
+	usb_port_status_set_bit(
+	    &status, USB_HUB_FEATURE_C_PORT_OVER_CURRENT,false);
+	/// \TODO what about port power change?
+	if (status >> 16) {
+		usb_log_info("there was unsupported change on port %d: %X\n",
+			port, status);
+
+	}
+}
+
+
+/**
+ * routine called when a device on port has been removed
+ *
+ * If the device on port had default address, it releases default address.
+ * Otherwise does not do anything, because DDF does not allow to remove device
+ * from it`s device tree.
+ * @param hub hub representation
+ * @param port port number, starting from 1
+ */
+static void usb_hub_removed_device(
+	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);
+	if (opResult != EOK) {
+		usb_log_warning("could not clear port-change-connection flag\n");
+	}
+	/** \TODO remove device from device manager - not yet implemented in
+	 * devide manager
+	 */
+
+	//close address
+	//if (hub->attached_devs[port].address != 0) {
+	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;
+		 */
+	} else {
+		usb_log_warning("this is strange, disconnected device had "
+			"no address\n");
+		//device was disconnected before it`s port was reset -
+		//return default address
+		usb_hub_release_default_address(hub);
+	}
+}
+
+
+/**
+ * Process port reset change
+ *
+ * After this change port should be enabled, unless some problem occured.
+ * This functions triggers second phase of enabling new device.
+ * @param hub
+ * @param port
+ * @param 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", port);
+	if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) {
+		/* Finalize device adding. */
+		usb_hub_port_t *the_port = hub->ports + port;
+		fibril_mutex_lock(&the_port->reset_mutex);
+		the_port->reset_completed = true;
+		fibril_condvar_broadcast(&the_port->reset_cv);
+		fibril_mutex_unlock(&the_port->reset_mutex);
+	} else {
+		usb_log_warning(
+		    "Port %zu reset complete but port not enabled.\n",
+		    port);
+	}
+}
+
+/**
+ * Process over current condition on port.
+ *
+ * Turn off the power on the port.
+ *
+ * @param hub hub representation
+ * @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) {
+	int opResult;
+	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);
+		if (opResult != EOK) {
+			usb_log_error("cannot power off port %d;  %d\n",
+				port, opResult);
+		}
+	}else{
+		opResult = usb_hub_set_port_feature(hub->control_pipe,
+			port, USB_HUB_FEATURE_PORT_POWER);
+		if (opResult != EOK) {
+			usb_log_error("cannot power on port %d;  %d\n",
+				port, opResult);
+		}
+	}
+}
 
 /** Retrieve port status.
@@ -73,11 +277,4 @@
 }
 
-/** Information for fibril for device discovery. */
-struct add_device_phase1 {
-	usb_hub_info_t *hub;
-	size_t port;
-	usb_speed_t speed;
-};
-
 /** Callback for enabling a specific port.
  *
@@ -91,5 +288,5 @@
 static int enable_port_callback(int port_no, void *arg)
 {
-	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
+	usb_hub_info_t *hub = arg;
 	int rc;
 	usb_device_request_setup_packet_t request;
@@ -156,5 +353,5 @@
 	data->hub->ports[data->port].attached_device.address = new_address;
 
-	usb_log_info("Detected new device on `%s' (port %zu), " \
+	usb_log_info("Detected new device on `%s' (port %zu), "
 	    "address %d (handle %" PRIun ").\n",
 	    data->hub->usb_device->ddf_dev->name, data->port,
@@ -166,4 +363,5 @@
 	return EOK;
 }
+
 
 /** Start device adding when connection change is detected.
@@ -176,5 +374,5 @@
  * @return Error code.
  */
-static int add_device_phase1_new_fibril(usb_hub_info_t *hub, size_t port,
+static int create_add_device_fibril(usb_hub_info_t *hub, size_t port,
     usb_speed_t speed)
 {
@@ -213,118 +411,4 @@
 }
 
-/** Process change on a single port.
- *
- * @param hub Hub to which the port belongs.
- * @param port Port index (starting at 1).
- */
-static void process_port_change(usb_hub_info_t *hub, size_t port)
-{
-	int rc;
-
-	usb_port_status_t port_status;
-
-	rc = get_port_status(&hub->usb_device->ctrl_pipe, port, &port_status);
-	if (rc != EOK) {
-		usb_log_error("Failed to get port %zu status: %s.\n",
-		    port, str_error(rc));
-		return;
-	}
-
-	/*
-	 * Check exact nature of the change.
-	 */
-	usb_log_debug("Port %zu change status: %x.\n", port,
-	    (unsigned int) port_status);
-
-	if (usb_port_connect_change(&port_status)) {
-		bool device_connected = usb_port_dev_connected(&port_status);
-		usb_log_debug("Connection change on port %zu: %s.\n", port,
-		    device_connected ? "device attached" : "device removed");
-
-		if (device_connected) {
-			rc = add_device_phase1_new_fibril(hub, port,
-			    usb_port_speed(&port_status));
-			if (rc != EOK) {
-				usb_log_error(
-				    "Cannot handle change on port %zu: %s.\n",
-				    str_error(rc));
-			}
-		} else {
-			usb_hub_removed_device(hub, port);
-		}
-	}
-
-	if (usb_port_overcurrent_change(&port_status)) {
-		if (usb_port_over_current(&port_status)) {
-			usb_log_warning("Overcurrent on port %zu.\n", port);
-			usb_hub_over_current(hub, port);
-		} else {
-			usb_log_debug("Overcurrent on port %zu autoresolved.\n",
-			    port);
-		}
-	}
-
-	if (usb_port_reset_completed(&port_status)) {
-		usb_log_debug("Port %zu reset complete.\n", port);
-		if (usb_port_enabled(&port_status)) {
-			/* Finalize device adding. */
-			usb_hub_port_t *the_port = hub->ports + port;
-			fibril_mutex_lock(&the_port->reset_mutex);
-			the_port->reset_completed = true;
-			fibril_condvar_broadcast(&the_port->reset_cv);
-			fibril_mutex_unlock(&the_port->reset_mutex);
-		} else {
-			usb_log_warning(
-			    "Port %zu reset complete but port not enabled.\n",
-			    port);
-		}
-	}
-
-	usb_port_set_connect_change(&port_status, false);
-	usb_port_set_reset(&port_status, false);
-	usb_port_set_reset_completed(&port_status, false);
-	usb_port_set_dev_connected(&port_status, false);
-	if (port_status >> 16) {
-		usb_log_warning("Unsupported change on port %zu: %x.\n",
-		    port, (unsigned int) port_status);
-	}
-}
-
-
-/** Callback for polling hub for port changes.
- *
- * @param dev Device where the change occured.
- * @param change_bitmap Bitmap of changed ports.
- * @param change_bitmap_size Size of the bitmap in bytes.
- * @param arg Custom argument, points to @c usb_hub_info_t.
- * @return Whether to continue polling.
- */
-bool hub_port_changes_callback(usb_device_t *dev,
-    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg)
-{
-	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
-
-	/* FIXME: check that we received enough bytes. */
-	if (change_bitmap_size == 0) {
-		goto leave;
-	}
-
-	size_t port;
-	for (port = 1; port < hub->port_count + 1; port++) {
-		bool change = (change_bitmap[port / 8] >> (port % 8)) % 2;
-		if (change) {
-			process_port_change(hub, port);
-		}
-	}
-
-
-leave:
-	/* FIXME: proper interval. */
-	async_usleep(1000 * 1000 * 10 );
-
-	return true;
-}
-
-
 /**
  * @}
Index: uspace/drv/usbhub/ports.h
===================================================================
--- uspace/drv/usbhub/ports.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/ports.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -36,13 +36,8 @@
 #define DRV_USBHUB_PORTS_H
 
-#include <ipc/devman.h>
-#include <usb/usb.h>
-#include <ddf/driver.h>
-#include <fibril_synch.h>
-
+#include <usb/devdrv.h>
 #include <usb/hub.h>
 
-#include <usb/pipes.h>
-#include <usb/devdrv.h>
+typedef struct usb_hub_info_t usb_hub_info_t;
 
 /** Information about single port on a hub. */
@@ -72,5 +67,8 @@
 }
 
-bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
+
+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 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/usbhub.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -37,4 +37,5 @@
 #include <errno.h>
 #include <str_error.h>
+#include <inttypes.h>
 
 #include <usb_iface.h>
@@ -53,11 +54,152 @@
 #include "usb/classes/classes.h"
 
-static int usb_hub_trigger_connecting_non_removable_devices(
-		usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);
-
+
+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_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);
+
+
+/// \TODO malloc checking
 
 //*********************************************
 //
 //  hub driver code, initialization
+//
+//*********************************************
+
+/**
+ * Initialize hub device driver fibril
+ *
+ * Creates hub representation and fibril that periodically checks hub`s status.
+ * Hub representation is passed to the fibril.
+ * @param usb_dev generic usb device information
+ * @return error code
+ */
+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);
+	//create hc connection
+	usb_log_debug("Initializing USB wire abstraction.\n");
+	int opResult = usb_hc_connection_initialize_from_device(
+	    &hub_info->connection,
+	    hub_info->usb_device->ddf_dev);
+	if (opResult != EOK) {
+		usb_log_error("could not initialize connection to device, "
+		    "errno %d\n",
+		    opResult);
+		free(hub_info);
+		return opResult;
+	}
+
+	usb_pipe_start_session(hub_info->control_pipe);
+	//set hub configuration
+	opResult = usb_hub_set_configuration(hub_info);
+	if (opResult != EOK) {
+		usb_log_error("could not set hub configuration, errno %d\n",
+		    opResult);
+		free(hub_info);
+		return opResult;
+	}
+	//get port count and create attached_devs
+	opResult = usb_hub_process_hub_specific_info(hub_info);
+	if (opResult != EOK) {
+		usb_log_error("could process hub specific info, errno %d\n",
+		    opResult);
+		free(hub_info);
+		return opResult;
+	}
+	usb_pipe_end_session(hub_info->control_pipe);
+
+	/// \TODO what is this?
+	usb_log_debug("Creating `hub' function.\n");
+	ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
+	    fun_exposed, "hub");
+	assert(hub_fun != NULL);
+	hub_fun->ops = NULL;
+
+	opResult = ddf_fun_bind(hub_fun);
+	assert(opResult == EOK);
+	opResult = ddf_fun_add_to_class(hub_fun, "hub");
+	assert(opResult == EOK);
+
+	opResult = usb_hub_start_hub_fibril(hub_info);
+	if(opResult!=EOK)
+		free(hub_info);
+	return opResult;
+}
+
+
+/** Callback for polling hub for changes.
+ *
+ * @param dev Device where the change occured.
+ * @param change_bitmap Bitmap of changed ports.
+ * @param change_bitmap_size Size of the bitmap in bytes.
+ * @param arg Custom argument, points to @c usb_hub_info_t.
+ * @return Whether to continue polling.
+ */
+bool hub_port_changes_callback(usb_device_t *dev,
+    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) {
+	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
+
+	/* FIXME: check that we received enough bytes. */
+	if (change_bitmap_size == 0) {
+		goto leave;
+	}
+
+	bool change;
+	change = ((uint8_t*) change_bitmap)[0] & 1;
+	if (change) {
+		usb_hub_process_global_interrupt(hub);
+	}
+
+	size_t port;
+	for (port = 1; port < hub->port_count + 1; port++) {
+		bool change = (change_bitmap[port / 8] >> (port % 8)) % 2;
+		if (change) {
+			usb_hub_process_interrupt(hub, port);
+		}
+	}
+leave:
+	/* FIXME: proper interval. */
+	async_usleep(1000 * 1000 * 10);
+
+	return true;
+}
+
+/**
+ * release default address used by given hub
+ *
+ * Also unsets hub->is_default_address_used. Convenience wrapper function.
+ * @note hub->connection MUST be open for communication
+ * @param hub hub representation
+ * @return error code
+ */
+int usb_hub_release_default_address(usb_hub_info_t * hub) {
+	int opResult = usb_hc_release_default_address(&hub->connection);
+	if (opResult != EOK) {
+		usb_log_error("could not release default address, errno %d\n",
+		    opResult);
+		return opResult;
+	}
+	hub->is_default_address_used = false;
+	return EOK;
+}
+
+
+//*********************************************
+//
+//  support functions
 //
 //*********************************************
@@ -71,6 +213,6 @@
  */
 static usb_hub_info_t * usb_hub_info_create(usb_device_t * usb_dev) {
-	usb_hub_info_t * result = usb_new(usb_hub_info_t);
-	if(!result) return NULL;
+	usb_hub_info_t * result = malloc(sizeof(usb_hub_info_t));
+	if (!result) return NULL;
 	result->usb_device = usb_dev;
 	result->status_change_pipe = usb_dev->pipes[0].pipe;
@@ -90,29 +232,21 @@
  * @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");
 	void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
 	usb_hub_descriptor_t * descriptor;
-
-	/* this was one fix of some bug, should not be needed anymore
-	 * these lines allow to reset hub once more, it can be used as
-	 * brute-force initialization for non-removable devices
-	int opResult = usb_request_set_configuration(&result->endpoints.control, 1);
-	if(opResult!=EOK){
-		usb_log_error("could not set default configuration, errno %d",opResult);
-		return opResult;
-	}
-	 */
+	int opResult;
+
 	size_t received_size;
-	int opResult = usb_request_get_descriptor(&hub_info->usb_device->ctrl_pipe,
-			USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
-			USB_DESCTYPE_HUB,
-			0, 0, serialized_descriptor,
-			USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
-
-	if (opResult != EOK) {
-		usb_log_error("failed when receiving hub descriptor, badcode = %d\n",
-				opResult);
+	opResult = usb_request_get_descriptor(hub_info->control_pipe,
+	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
+	    USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
+
+	if (opResult != EOK) {
+		usb_log_error("failed when receiving hub descriptor, "
+		    "badcode = %d\n",
+		    opResult);
 		free(serialized_descriptor);
 		return opResult;
@@ -120,17 +254,17 @@
 	usb_log_debug2("deserializing descriptor\n");
 	descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
-	if(descriptor==NULL){
+	if (descriptor == NULL) {
 		usb_log_warning("could not deserialize descriptor \n");
 		return opResult;
 	}
-	usb_log_debug("setting port count to %d\n",descriptor->ports_count);
+	usb_log_debug("setting port count to %d\n", descriptor->ports_count);
 	hub_info->port_count = descriptor->ports_count;
-	hub_info->ports = malloc(sizeof(usb_hub_port_t) * (hub_info->port_count+1));
+	/// \TODO this is not semantically correct
+	hub_info->ports = malloc(
+	    sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
 	size_t port;
 	for (port = 0; port < hub_info->port_count + 1; port++) {
 		usb_hub_port_init(&hub_info->ports[port]);
 	}
-	//handle non-removable devices
-	usb_hub_trigger_connecting_non_removable_devices(hub_info, descriptor);
 	usb_log_debug2("freeing data\n");
 	free(serialized_descriptor);
@@ -139,4 +273,5 @@
 	return EOK;
 }
+
 /**
  * Set configuration of hub
@@ -147,5 +282,5 @@
  * @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
@@ -153,5 +288,5 @@
 	usb_log_debug("hub has %d configurations\n",
 	    std_descriptor->configuration_count);
-	if(std_descriptor->configuration_count<1){
+	if (std_descriptor->configuration_count < 1) {
 		usb_log_error("there are no configurations available\n");
 		return EINVAL;
@@ -173,5 +308,5 @@
 	}
 	usb_log_debug("\tused configuration %d\n",
-			config_descriptor->configuration_number);
+	    config_descriptor->configuration_number);
 
 	return EOK;
@@ -179,56 +314,13 @@
 
 /**
- * Initialize hub device driver fibril
- *
- * Creates hub representation and fibril that periodically checks hub`s status.
- * Hub representation is passed to the fibril.
- * @param usb_dev generic usb device information
- * @return error code
- */
-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);
-	//create hc connection
-	usb_log_debug("Initializing USB wire abstraction.\n");
-	int opResult = usb_hc_connection_initialize_from_device(
-			&hub_info->connection,
-			hub_info->usb_device->ddf_dev);
-	if(opResult != EOK){
-		usb_log_error("could not initialize connection to device, errno %d\n",
-				opResult);
-		free(hub_info);
-		return opResult;
-	}
-	
-	usb_pipe_start_session(hub_info->control_pipe);
-	//set hub configuration
-	opResult = usb_hub_set_configuration(hub_info);
-	if(opResult!=EOK){
-		usb_log_error("could not set hub configuration, errno %d\n",opResult);
-		free(hub_info);
-		return opResult;
-	}
-	//get port count and create attached_devs
-	opResult = usb_hub_process_hub_specific_info(hub_info);
-	if(opResult!=EOK){
-		usb_log_error("could not set hub configuration, errno %d\n",opResult);
-		free(hub_info);
-		return opResult;
-	}
-	usb_pipe_end_session(hub_info->control_pipe);
-
-
-	/// \TODO what is this?
-	usb_log_debug("Creating `hub' function.\n");
-	ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
-			fun_exposed, "hub");
-	assert(hub_fun != NULL);
-	hub_fun->ops = NULL;
-
-	int rc = ddf_fun_bind(hub_fun);
-	assert(rc == EOK);
-	rc = ddf_fun_add_to_class(hub_fun, "hub");
-	assert(rc == EOK);
-
+ * create and start fibril with hub control loop
+ *
+ * Before the fibril is started, the control pipe and host controller
+ * connection of the hub is open.
+ *
+ * @param hub_info hub representing structure
+ * @return error code
+ */
+static int usb_hub_start_hub_fibril(usb_hub_info_t * hub_info){
 	/*
 	 * The processing will require opened control pipe and connection
@@ -239,20 +331,20 @@
 	 * auto destruction, this could work better.
 	 */
-	rc = usb_pipe_start_session(&usb_dev->ctrl_pipe);
+	int rc = usb_pipe_start_session(hub_info->control_pipe);
 	if (rc != EOK) {
 		usb_log_error("Failed to start session on control pipe: %s.\n",
 		    str_error(rc));
-		goto leave;
+		return rc;
 	}
 	rc = usb_hc_connection_open(&hub_info->connection);
 	if (rc != EOK) {
-		usb_pipe_end_session(&usb_dev->ctrl_pipe);
+		usb_pipe_end_session(hub_info->control_pipe);
 		usb_log_error("Failed to open connection to HC: %s.\n",
 		    str_error(rc));
-		goto leave;
+		return rc;
 	}
 
 	rc = usb_device_auto_poll(hub_info->usb_device, 0,
-	    hub_port_changes_callback, ((hub_info->port_count+1) / 8) + 1,
+	    hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1,
 	    NULL, hub_info);
 	if (rc != EOK) {
@@ -266,197 +358,119 @@
 	    hub_info->usb_device->ddf_dev->name, hub_info->port_count);
 	return EOK;
-
-leave:
-	free(hub_info);
-
-	return rc;
-}
-
-
-//*********************************************
-//
-//  hub driver code, main loop and port handling
-//
-//*********************************************
-
-/**
- * triggers actions to connect non0removable devices
- *
- * This will trigger operations leading to activated non-removable device.
- * Control pipe of the hub must be open fo communication.
- * @param hub hub representation
- * @param descriptor usb hub descriptor
- * @return error code
- */
-static int usb_hub_trigger_connecting_non_removable_devices(usb_hub_info_t * hub,
-		usb_hub_descriptor_t * descriptor)
-{
-	usb_log_info("attaching non-removable devices(if any)\n");
-	usb_device_request_setup_packet_t request;
+}
+
+//*********************************************
+//
+//  change handling functions
+//
+//*********************************************
+
+
+/**
+ * process hub over current change
+ *
+ * This means either to power off the hub or power it on.
+ * @param hub_info hub instance
+ * @param status hub status bitmask
+ * @return error code
+ */
+static int usb_process_hub_over_current(usb_hub_info_t * hub_info,
+    usb_hub_status_t status) {
 	int opResult;
-	size_t rcvd_size;
-	usb_port_status_t status;
-	uint8_t * non_removable_dev_bitmap = descriptor->devices_removable;
-	int port;
-	for(port=1;port<=descriptor->ports_count;++port){
-		bool is_non_removable =
-				((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;
-		if(is_non_removable){
-			usb_log_debug("non-removable device on port %d\n",port);
-			usb_hub_set_port_status_request(&request, port);
-			opResult = usb_pipe_control_read(
-					hub->control_pipe,
-					&request, sizeof(usb_device_request_setup_packet_t),
-					&status, 4, &rcvd_size
-					);
+	if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_OVER_CURRENT)){
+		opResult = usb_hub_clear_feature(hub_info->control_pipe,
+		    USB_HUB_FEATURE_HUB_LOCAL_POWER);
+		if (opResult != EOK) {
+			usb_log_error("cannot power off hub: %d\n",
+			    opResult);
+		}
+	} else {
+		opResult = usb_hub_set_feature(hub_info->control_pipe,
+		    USB_HUB_FEATURE_HUB_LOCAL_POWER);
+		if (opResult != EOK) {
+			usb_log_error("cannot power on hub: %d\n",
+			    opResult);
+		}
+	}
+	return opResult;
+}
+
+/**
+ * process hub power change
+ *
+ * If the power has been lost, reestablish it.
+ * If it was reestablished, re-power all ports.
+ * @param hub_info hub instance
+ * @param status hub status bitmask
+ * @return error code
+ */
+static int usb_process_hub_power_change(usb_hub_info_t * hub_info,
+    usb_hub_status_t status) {
+	int opResult;
+	if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
+		//restart power on hub
+		opResult = usb_hub_set_feature(hub_info->control_pipe,
+		    USB_HUB_FEATURE_HUB_LOCAL_POWER);
+		if (opResult != EOK) {
+			usb_log_error("cannot power on hub: %d\n",
+			    opResult);
+		}
+	} else {//power reestablished on hub- restart ports
+		size_t port;
+		for (port = 0; port < hub_info->port_count; ++port) {
+			opResult = usb_hub_set_port_feature(
+			    hub_info->control_pipe,
+			    port, USB_HUB_FEATURE_PORT_POWER);
 			if (opResult != EOK) {
-				usb_log_error("could not get port status of port %d errno:%d\n",
-						port, opResult);
-				return opResult;
-			}
-			//set the status change bit, so it will be noticed in driver loop
-			if(usb_port_dev_connected(&status)){
-				usb_hub_set_disable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_PORT_CONNECTION);
-				opResult = usb_pipe_control_read(
-						hub->control_pipe,
-						&request, sizeof(usb_device_request_setup_packet_t),
-						&status, 4, &rcvd_size
-						);
-				if (opResult != EOK) {
-					usb_log_warning(
-							"could not clear port connection on port %d errno:%d\n",
-							port, opResult);
-				}
-				usb_log_debug("cleared port connection\n");
-				usb_hub_set_enable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_PORT_ENABLE);
-				opResult = usb_pipe_control_read(
-						hub->control_pipe,
-						&request, sizeof(usb_device_request_setup_packet_t),
-						&status, 4, &rcvd_size
-						);
-				if (opResult != EOK) {
-					usb_log_warning(
-							"could not set port enabled on port %d errno:%d\n",
-							port, opResult);
-				}
-				usb_log_debug("port set to enabled - should lead to connection change\n");
+				usb_log_error("cannot power on port %d;  %d\n",
+				    port, opResult);
 			}
 		}
 	}
-	/// \TODO this is just a debug code
-	for(port=1;port<=descriptor->ports_count;++port){
-		bool is_non_removable =
-				((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;
-		if(is_non_removable){
-			usb_log_debug("port %d is non-removable\n",port);
-			usb_port_status_t status;
-			size_t rcvd_size;
-			usb_device_request_setup_packet_t request;
-			//int opResult;
-			usb_hub_set_port_status_request(&request, port);
-			//endpoint 0
-			opResult = usb_pipe_control_read(
-					hub->control_pipe,
-					&request, sizeof(usb_device_request_setup_packet_t),
-					&status, 4, &rcvd_size
-					);
-			if (opResult != EOK) {
-				usb_log_error("could not get port status %d\n",opResult);
-			}
-			if (rcvd_size != sizeof (usb_port_status_t)) {
-				usb_log_error("received status has incorrect size\n");
-			}
-			//something connected/disconnected
-			if (usb_port_connect_change(&status)) {
-				usb_log_debug("some connection changed\n");
-			}
-			usb_log_debug("status: %s\n",usb_debug_str_buffer(
-					(uint8_t *)&status,4,4));
-		}
-	}
-	return EOK;
-}
-
-
-/**
- * release default address used by given hub
- *
- * Also unsets hub->is_default_address_used. Convenience wrapper function.
- * @note hub->connection MUST be open for communication
- * @param hub hub representation
- * @return error code
- */
-static int usb_hub_release_default_address(usb_hub_info_t * hub){
-	int opResult = usb_hc_release_default_address(&hub->connection);
-	if(opResult!=EOK){
-		usb_log_error("could not release default address, errno %d\n",opResult);
-		return opResult;
-	}
-	hub->is_default_address_used = false;
-	return EOK;
-}
-
-/**
- * routine called when a device on port has been removed
- *
- * If the device on port had default address, it releases default address.
- * Otherwise does not do anything, because DDF does not allow to remove device
- * from it`s device tree.
- * @param hub hub representation
- * @param port port number, starting from 1
- */
-void usb_hub_removed_device(
-    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);
-	if(opResult != EOK){
-		usb_log_warning("could not clear port-change-connection flag\n");
-	}
-	/** \TODO remove device from device manager - not yet implemented in
-	 * devide manager
-	 */
-	
-	//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;
-		 */
-	}else{
-		usb_log_warning("this is strange, disconnected device had no address\n");
-		//device was disconnected before it`s port was reset - return default address
-		usb_hub_release_default_address(hub);
-	}
-}
-
-
-/**
- * Process over current condition on port.
- * 
- * Turn off the power on the port.
- *
- * @param hub hub representation
- * @param port port number, starting from 1
- */
-void usb_hub_over_current( usb_hub_info_t * hub,
-		uint16_t port){
+	return opResult;
+}
+
+/**
+ * process hub interrupts
+ *
+ * The change can be either in the over-current condition or
+ * local-power lost condition.
+ * @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");
+	usb_pipe_t *pipe = hub_info->control_pipe;
 	int opResult;
-	opResult = usb_hub_clear_port_feature(hub->control_pipe,
-	    port, USB_HUB_FEATURE_PORT_POWER);
-	if(opResult!=EOK){
-		usb_log_error("cannot power off port %d;  %d\n",
-				port, opResult);
-	}
-}
-
+
+	usb_port_status_t status;
+	size_t rcvd_size;
+	usb_device_request_setup_packet_t request;
+	//int opResult;
+	usb_hub_set_hub_status_request(&request);
+	//endpoint 0
+
+	opResult = usb_pipe_control_read(
+	    pipe,
+	    &request, sizeof (usb_device_request_setup_packet_t),
+	    &status, 4, &rcvd_size
+	    );
+	if (opResult != EOK) {
+		usb_log_error("could not get hub status\n");
+		return;
+	}
+	if (rcvd_size != sizeof (usb_port_status_t)) {
+		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_process_hub_over_current(hub_info, status);
+	}
+	if (
+	    usb_hub_is_status(status,16+USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) {
+		usb_process_hub_power_change(hub_info, status);
+	}
+}
 
 /**
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/usbhub.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -37,13 +37,15 @@
 
 #include <ipc/devman.h>
-#include <usb/usb.h>
 #include <ddf/driver.h>
 
-#define NAME "usbhub"
-
 #include <usb/hub.h>
+#include <usb/classes/hub.h>
 
 #include <usb/pipes.h>
 #include <usb/devdrv.h>
+
+#include <fibril_synch.h>
+
+#define NAME "usbhub"
 
 #include "ports.h"
@@ -52,11 +54,11 @@
 
 /** Information about attached hub. */
-typedef struct {
+struct usb_hub_info_t{
 	/** Number of ports. */
 	size_t port_count;
 
-	/** Ports. */
+	/** attached device handles, for each port one */
 	usb_hub_port_t *ports;
-	
+
 	/** connection to hcd */
 	usb_hc_connection_t connection;
@@ -87,24 +89,14 @@
 	/** generic usb device data*/
 	usb_device_t * usb_device;
-} usb_hub_info_t;
+};
 
-/**
- * function running the hub-controlling loop.
- * @param hub_info_param hub info pointer
- */
-int usb_hub_control_loop(void * hub_info_param);
-
-/**
- * Check changes on specified hub
- * @param hub_info_param pointer to usb_hub_info_t structure
- * @return error code if there is problem when initializing communication with
- * hub, EOK otherwise
- */
-int usb_hub_check_hub_changes(usb_hub_info_t * hub_info_param);
-
-void usb_hub_removed_device(usb_hub_info_t *, uint16_t);
-void usb_hub_over_current(usb_hub_info_t *, uint16_t);
+//int usb_hub_control_loop(void * hub_info_param);
 
 int usb_hub_add_device(usb_device_t * usb_dev);
+
+bool hub_port_changes_callback(usb_device_t *dev,
+    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg);
+
+int usb_hub_release_default_address(usb_hub_info_t * hub);
 
 #endif
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -54,16 +54,6 @@
 //
 //************
-#define usb_new(type) (type*)malloc(sizeof(type))
 
 
-/**
- * Create hub structure instance
- *
- * Set the address and port count information most importantly.
- *
- * @param device
- * @param hc host controller phone
- * @return
- */
 usb_hub_info_t * usb_create_hub_info(ddf_dev_t * device);
 
@@ -110,4 +100,71 @@
 
 /**
+ * Clear feature on hub port.
+ *
+ * @param hc Host controller telephone
+ * @param address Hub address
+ * @param port_index Port
+ * @param feature Feature selector
+ * @return Operation result
+ */
+static inline int usb_hub_set_port_feature(usb_pipe_t *pipe,
+    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,
+		.request = USB_DEVREQ_SET_FEATURE,
+		.length = 0,
+		.index = port_index
+	};
+	clear_request.value = feature;
+	return usb_pipe_control_write(pipe, &clear_request,
+	    sizeof(clear_request), NULL, 0);
+}
+
+
+/**
+ * Clear feature on hub port.
+ *
+ * @param pipe pipe to hub control endpoint
+ * @param feature Feature selector
+ * @return Operation result
+ */
+static inline int usb_hub_clear_feature(usb_pipe_t *pipe,
+    usb_hub_class_feature_t feature) {
+
+	usb_device_request_setup_packet_t clear_request = {
+		.request_type = USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE,
+		.request = USB_DEVREQ_CLEAR_FEATURE,
+		.length = 0,
+		.index = 0
+	};
+	clear_request.value = feature;
+	return usb_pipe_control_write(pipe, &clear_request,
+	    sizeof(clear_request), NULL, 0);
+}
+
+/**
+ * Clear feature on hub port.
+ *
+ * @param pipe pipe to hub control endpoint
+ * @param feature Feature selector
+ * @return Operation result
+ */
+static inline int usb_hub_set_feature(usb_pipe_t *pipe,
+    usb_hub_class_feature_t feature) {
+
+	usb_device_request_setup_packet_t clear_request = {
+		.request_type = USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE,
+		.request = USB_DEVREQ_SET_FEATURE,
+		.length = 0,
+		.index = 0
+	};
+	clear_request.value = feature;
+	return usb_pipe_control_write(pipe, &clear_request,
+	    sizeof(clear_request), NULL, 0);
+}
+
+/**
  * create uint8_t array with serialized descriptor
  *
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbhub/utils.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -60,7 +60,7 @@
 	size_t size = 7;
 	//variable size according to port count
-	size_t var_size = descriptor->ports_count / 8 + ((descriptor->ports_count % 8 > 0) ? 1 : 0);
+	size_t var_size = (descriptor->ports_count+7)/8;
 	size += 2 * var_size;
-	uint8_t * result = (uint8_t*) malloc(size);
+	uint8_t * result = malloc(size);
 	//size
 	result[0] = size;
@@ -84,13 +84,15 @@
 }
 
-usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor) {
-	uint8_t * sdescriptor = (uint8_t*) serialized_descriptor;
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(
+void * serialized_descriptor) {
+	uint8_t * sdescriptor = serialized_descriptor;
 
 	if (sdescriptor[1] != USB_DESCTYPE_HUB) {
-		usb_log_warning("trying to deserialize wrong descriptor %x\n",sdescriptor[1]);
+		usb_log_warning("trying to deserialize wrong descriptor %x\n",
+		    sdescriptor[1]);
 		return NULL;
 	}
 
-	usb_hub_descriptor_t * result = usb_new(usb_hub_descriptor_t);
+	usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t));
 	
 
@@ -100,6 +102,5 @@
 	result->pwr_on_2_good_time = sdescriptor[5];
 	result->current_requirement = sdescriptor[6];
-	size_t var_size = result->ports_count / 8 + ((result->ports_count % 8 > 0)
-			? 1 : 0);
+	size_t var_size = (result->ports_count+7) / 8;
 	result->devices_removable = (uint8_t*) malloc(var_size);
 
Index: uspace/drv/usbmid/main.c
===================================================================
--- uspace/drv/usbmid/main.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/usbmid/main.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -55,7 +55,7 @@
 	int rc;
 
-	rc = usb_pipe_start_session(&dev->ctrl_pipe);
+	rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
 	if (rc != EOK) {
-		usb_log_error("Failed to start session on control pipe: %s.\n",
+		usb_log_error("Failed to start transfer on control pipe: %s.\n",
 		    str_error(rc));
 		return rc;
@@ -64,9 +64,5 @@
 	bool accept = usbmid_explore_device(dev);
 
-	rc = usb_pipe_end_session(&dev->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_warning("Failed to end session on control pipe: %s.\n",
-		    str_error(rc));
-	}
+	usb_pipe_end_long_transfer(&dev->ctrl_pipe);
 
 	if (!accept) {
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/drv/vhc/connhost.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -257,5 +257,4 @@
 
 static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
@@ -267,5 +266,4 @@
 
 static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
@@ -277,5 +275,4 @@
 
 static int control_write(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
     void *data, size_t data_size,
@@ -295,5 +292,4 @@
 
 static int control_read(ddf_fun_t *fun, usb_target_t target,
-    size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
     void *data, size_t data_size,
Index: uspace/lib/drv/generic/remote_usbhc.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhc.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/drv/generic/remote_usbhc.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -270,5 +270,4 @@
 	}
 
-	size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
 	usb_target_t target = {
 		.address = DEV_IPC_GET_ARG1(*call),
@@ -300,5 +299,5 @@
 	trans->size = len;
 
-	rc = transfer_func(fun, target, max_packet_size,
+	rc = transfer_func(fun, target,
 	    buffer, len,
 	    callback_out, trans);
@@ -326,5 +325,4 @@
 	}
 
-	size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
 	usb_target_t target = {
 		.address = DEV_IPC_GET_ARG1(*call),
@@ -348,5 +346,5 @@
 	trans->size = len;
 
-	int rc = transfer_func(fun, target, max_packet_size,
+	int rc = transfer_func(fun, target,
 	    trans->buffer, len,
 	    callback_in, trans);
@@ -414,5 +412,4 @@
 	};
 	size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
-	size_t max_packet_size = DEV_IPC_GET_ARG4(*call);
 
 	int rc;
@@ -450,5 +447,5 @@
 	trans->size = data_buffer_len;
 
-	rc = usb_iface->control_write(fun, target, max_packet_size,
+	rc = usb_iface->control_write(fun, target,
 	    setup_packet, setup_packet_len,
 	    data_buffer, data_buffer_len,
@@ -477,5 +474,4 @@
 		.endpoint = DEV_IPC_GET_ARG2(*call)
 	};
-	size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
 
 	int rc;
@@ -515,5 +511,5 @@
 	}
 
-	rc = usb_iface->control_read(fun, target, max_packet_size,
+	rc = usb_iface->control_read(fun, target,
 	    setup_packet, setup_packet_len,
 	    trans->buffer, trans->size,
@@ -537,21 +533,32 @@
 	}
 
-#define INIT_FROM_HIGH_DATA(type, var, arg_no) \
-	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / 256
-#define INIT_FROM_LOW_DATA(type, var, arg_no) \
-	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % 256
-
-	INIT_FROM_HIGH_DATA(usb_address_t, address, 1);
-	INIT_FROM_LOW_DATA(usb_endpoint_t, endpoint, 1);
-	INIT_FROM_HIGH_DATA(usb_transfer_type_t, transfer_type, 2);
-	INIT_FROM_LOW_DATA(usb_direction_t, direction, 2);
-
-#undef INIT_FROM_HIGH_DATA
-#undef INIT_FROM_LOW_DATA
-
-	size_t max_packet_size = (size_t) DEV_IPC_GET_ARG3(*call);
-	unsigned int interval  = (unsigned int) DEV_IPC_GET_ARG4(*call);
-
-	int rc = usb_iface->register_endpoint(fun, address, endpoint,
+#define _INIT_FROM_HIGH_DATA2(type, var, arg_no) \
+	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16)
+#define _INIT_FROM_LOW_DATA2(type, var, arg_no) \
+	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 16)
+#define _INIT_FROM_HIGH_DATA3(type, var, arg_no) \
+	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) / (1 << 16)
+#define _INIT_FROM_MIDDLE_DATA3(type, var, arg_no) \
+	type var = (type) (DEV_IPC_GET_ARG##arg_no(*call) / (1 << 8)) % (1 << 8)
+#define _INIT_FROM_LOW_DATA3(type, var, arg_no) \
+	type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 8)
+
+	_INIT_FROM_HIGH_DATA2(usb_address_t, address, 1);
+	_INIT_FROM_LOW_DATA2(usb_endpoint_t, endpoint, 1);
+
+	_INIT_FROM_HIGH_DATA3(usb_speed_t, speed, 2);
+	_INIT_FROM_MIDDLE_DATA3(usb_transfer_type_t, transfer_type, 2);
+	_INIT_FROM_LOW_DATA3(usb_direction_t, direction, 2);
+
+	_INIT_FROM_HIGH_DATA2(size_t, max_packet_size, 3);
+	_INIT_FROM_LOW_DATA2(unsigned int, interval, 3);
+
+#undef _INIT_FROM_HIGH_DATA2
+#undef _INIT_FROM_LOW_DATA2
+#undef _INIT_FROM_HIGH_DATA3
+#undef _INIT_FROM_MIDDLE_DATA3
+#undef _INIT_FROM_LOW_DATA3
+
+	int rc = usb_iface->register_endpoint(fun, address, speed, endpoint,
 	    transfer_type, direction, max_packet_size, interval);
 
Index: uspace/lib/drv/include/usbhc_iface.h
===================================================================
--- uspace/lib/drv/include/usbhc_iface.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/drv/include/usbhc_iface.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -66,5 +66,4 @@
  *   - argument #1 is target address
  *   - argument #2 is target endpoint
- *   - argument #3 is max packet size of the endpoint
  * - this call is immediately followed by IPC data read (async version)
  * - the call is not answered until the device returns some data (or until
@@ -169,9 +168,12 @@
 	/** Register endpoint attributes at host controller.
 	 * This is used to reserve portion of USB bandwidth.
+	 * When speed is invalid, speed of the device is used.
 	 * Parameters:
-	 * - USB address + endpoint number (ADDR * 256 + EP)
-	 * - transfer type + direction (TYPE * 256 + DIR)
-	 * - maximum packet size
-	 * - interval (in milliseconds)
+	 * - USB address + endpoint number
+	 *   - packed as ADDR << 16 + EP
+	 * - speed + transfer type + direction
+	 *   - packed as ( SPEED << 8 + TYPE ) << 8 + DIR
+	 * - maximum packet size + interval (in milliseconds)
+	 *   - packed as MPS << 16 + INT
 	 * Answer:
 	 * - EOK - reservation successful
@@ -202,5 +204,5 @@
 
 /** Out transfer processing function prototype. */
-typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t, size_t,
+typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t,
     void *, size_t,
     usbhc_iface_transfer_out_callback_t, void *);
@@ -210,5 +212,5 @@
 
 /** In transfer processing function prototype. */
-typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t, size_t,
+typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t,
     void *, size_t,
     usbhc_iface_transfer_in_callback_t, void *);
@@ -222,5 +224,6 @@
 	int (*release_address)(ddf_fun_t *, usb_address_t);
 
-	int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
+	int (*register_endpoint)(ddf_fun_t *,
+	    usb_address_t, usb_speed_t, usb_endpoint_t,
 	    usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
 	int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
@@ -234,10 +237,8 @@
 
 	int (*control_write)(ddf_fun_t *, usb_target_t,
-	    size_t,
 	    void *, size_t, void *, size_t,
 	    usbhc_iface_transfer_out_callback_t, void *);
 
 	int (*control_read)(ddf_fun_t *, usb_target_t,
-	    size_t,
 	    void *, size_t, void *, size_t,
 	    usbhc_iface_transfer_in_callback_t, void *);
Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/Makefile	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -43,4 +43,5 @@
 	src/hidparser.c \
 	src/hub.c \
+	src/pipepriv.c \
 	src/pipes.c \
 	src/pipesinit.c \
Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -43,4 +43,6 @@
  */
 typedef enum {
+	USB_HUB_FEATURE_HUB_LOCAL_POWER = 0,
+	USB_HUB_FEATURE_HUB_OVER_CURRENT = 1,
 	USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
 	USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
@@ -59,4 +61,5 @@
 	/* USB_HUB_FEATURE_ = , */
 } usb_hub_class_feature_t;
+
 
 /** Header of standard hub descriptor without the "variadic" part. */
Index: uspace/lib/usb/include/usb/devdrv.h
===================================================================
--- uspace/lib/usb/include/usb/devdrv.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/include/usb/devdrv.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -169,4 +169,12 @@
     usb_polling_callback_t, size_t, usb_polling_terminted_callback_t, void *);
 
+int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
+int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
+    usb_endpoint_description_t **, uint8_t *, size_t, int, int,
+    usb_endpoint_mapping_t **, size_t *);
+int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
+
+size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
+
 #endif
 /**
Index: uspace/lib/usb/include/usb/host/device_keeper.h
===================================================================
--- uspace/lib/usb/include/usb/host/device_keeper.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/include/usb/host/device_keeper.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -73,4 +73,6 @@
 void usb_device_keeper_add_ep(
     usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep);
+void usb_device_keeper_del_ep(
+    usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep);
 
 void usb_device_keeper_reserve_default_address(
Index: uspace/lib/usb/include/usb/pipes.h
===================================================================
--- uspace/lib/usb/include/usb/pipes.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/include/usb/pipes.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -42,4 +42,5 @@
 #include <ipc/devman.h>
 #include <ddf/driver.h>
+#include <fibril_synch.h>
 
 /** Abstraction of a physical connection to the device.
@@ -59,6 +60,14 @@
  * This endpoint must be bound with existing usb_device_connection_t
  * (i.e. the wire to send data over).
+ *
+ * Locking order: if you want to lock both mutexes
+ * (@c guard and @c hc_phone_mutex), lock @c guard first.
+ * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
+ * only.
  */
 typedef struct {
+	/** Guard of the whole pipe. */
+	fibril_mutex_t guard;
+
 	/** The connection used for sending the data. */
 	usb_device_connection_t *wire;
@@ -78,6 +87,16 @@
 	/** Phone to the host controller.
 	 * Negative when no session is active.
+	 * It is an error to access this member without @c hc_phone_mutex
+	 * being locked.
+	 * If call over the phone is to be made, it must be preceeded by
+	 * call to pipe_add_ref() [internal libusb function].
 	 */
 	int hc_phone;
+
+	/** Guard for serialization of requests over the phone. */
+	fibril_mutex_t hc_phone_mutex;
+
+	/** Number of active transfers over the pipe. */
+	int refcount;
 } usb_pipe_t;
 
@@ -134,4 +153,6 @@
 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
     size_t, uint8_t *, size_t, usb_device_connection_t *);
+int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
+    unsigned int, usb_hc_connection_t *);
 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
@@ -140,4 +161,7 @@
 int usb_pipe_end_session(usb_pipe_t *);
 bool usb_pipe_is_session_started(usb_pipe_t *);
+
+int usb_pipe_start_long_transfer(usb_pipe_t *);
+void usb_pipe_end_long_transfer(usb_pipe_t *);
 
 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/include/usb/usb.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -77,5 +77,7 @@
 	USB_SPEED_FULL,
 	/** USB 2.0 high speed (480Mbits/s). */
-	USB_SPEED_HIGH
+	USB_SPEED_HIGH,
+	/** Psuedo-speed serving as a boundary. */
+	USB_SPEED_MAX
 } usb_speed_t;
 
Index: uspace/lib/usb/src/devdrv.c
===================================================================
--- uspace/lib/usb/src/devdrv.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/devdrv.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -72,14 +72,4 @@
 }
 
-/** Log out of memory error on given device.
- *
- * @param dev Device causing the trouble.
- */
-static void usb_log_oom(ddf_dev_t *dev)
-{
-	usb_log_error("Out of memory when adding device `%s'.\n",
-	    dev->name);
-}
-
 /** Count number of pipes the driver expects.
  *
@@ -108,93 +98,25 @@
  */
 static int initialize_other_pipes(usb_endpoint_description_t **endpoints,
-    usb_device_t *dev)
-{
-	int rc;
-
-	size_t pipe_count = count_other_pipes(endpoints);
-	if (pipe_count == 0) {
-		return EOK;
-	}
-
-	dev->pipes = malloc(sizeof(usb_endpoint_mapping_t) * pipe_count);
-	if (dev->pipes == NULL) {
-		usb_log_oom(dev->ddf_dev);
-		return ENOMEM;
-	}
-
-	size_t i;
-
-	/* Initialize to NULL first for rollback purposes. */
-	for (i = 0; i < pipe_count; i++) {
-		dev->pipes[i].pipe = NULL;
-	}
-
-	for (i = 0; i < pipe_count; i++) {
-		dev->pipes[i].pipe = malloc(sizeof(usb_pipe_t));
-		if (dev->pipes[i].pipe == NULL) {
-			usb_log_oom(dev->ddf_dev);
-			rc = ENOMEM;
-			goto rollback;
-		}
-
-		dev->pipes[i].description = endpoints[i];
-		dev->pipes[i].interface_no = dev->interface_no;
-		dev->pipes[i].interface_setting = 0;
-	}
-
-	rc = usb_pipe_initialize_from_configuration(dev->pipes, pipe_count,
+    usb_device_t *dev, int alternate_setting)
+{
+	usb_endpoint_mapping_t *pipes;
+	size_t pipes_count;
+
+	int rc = usb_device_create_pipes(dev->ddf_dev, &dev->wire, endpoints,
 	    dev->descriptors.configuration, dev->descriptors.configuration_size,
-	    &dev->wire);
-	if (rc != EOK) {
-		usb_log_error("Failed initializing USB endpoints: %s.\n",
-		    str_error(rc));
-		goto rollback;
-	}
-
-	/* Register the endpoints. */
-	usb_hc_connection_t hc_conn;
-	rc = usb_hc_connection_initialize_from_device(&hc_conn, dev->ddf_dev);
+	    dev->interface_no, alternate_setting,
+	    &pipes, &pipes_count);
+
 	if (rc != EOK) {
 		usb_log_error(
-		    "Failed initializing connection to host controller: %s.\n",
-		    str_error(rc));
-		goto rollback;
-	}
-	rc = usb_hc_connection_open(&hc_conn);
-	if (rc != EOK) {
-		usb_log_error("Failed to connect to host controller: %s.\n",
-		    str_error(rc));
-		goto rollback;
-	}
-	for (i = 0; i < pipe_count; i++) {
-		if (dev->pipes[i].present) {
-			rc = usb_pipe_register(dev->pipes[i].pipe,
-			    dev->pipes[i].descriptor->poll_interval,
-			    &hc_conn);
-			/* Ignore error when operation not supported by HC. */
-			if ((rc != EOK) && (rc != ENOTSUP)) {
-				/* FIXME: what shall we do? */
-				dev->pipes[i].present = false;
-				free(dev->pipes[i].pipe);
-				dev->pipes[i].pipe = NULL;
-			}
-		}
-	}
-	/* Ignoring errors here. */
-	usb_hc_connection_close(&hc_conn);
-
-	dev->pipes_count = pipe_count;
+		    "Failed to create endpoint pipes for `%s': %s.\n",
+		    dev->ddf_dev->name, str_error(rc));
+		return rc;
+	}
+
+	dev->pipes = pipes;
+	dev->pipes_count = pipes_count;
 
 	return EOK;
-
-rollback:
-	for (i = 0; i < pipe_count; i++) {
-		if (dev->pipes[i].pipe != NULL) {
-			free(dev->pipes[i].pipe);
-		}
-	}
-	free(dev->pipes);
-
-	return rc;
 }
 
@@ -239,38 +161,30 @@
 
 	/*
-	 * For further actions, we need open session on default control pipe.
+	 * We will do some querying of the device, it is worth to prepare
+	 * the long transfer.
 	 */
-	rc = usb_pipe_start_session(&dev->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_error("Failed to start an IPC session: %s.\n",
+	rc = usb_pipe_start_long_transfer(&dev->ctrl_pipe);
+	if (rc != EOK) {
+		usb_log_error("Failed to start transfer: %s.\n",
 		    str_error(rc));
 		return rc;
 	}
 
-	/* Get the device descriptor. */
-	rc = usb_request_get_device_descriptor(&dev->ctrl_pipe,
-	    &dev->descriptors.device);
-	if (rc != EOK) {
-		usb_log_error("Failed to retrieve device descriptor: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	/* Get the full configuration descriptor. */
-	rc = usb_request_get_full_configuration_descriptor_alloc(
-	    &dev->ctrl_pipe, 0, (void **) &dev->descriptors.configuration,
-	    &dev->descriptors.configuration_size);
-	if (rc != EOK) {
-		usb_log_error("Failed retrieving configuration descriptor: %s. %s\n",
+	/* Retrieve the descriptors. */
+	rc = usb_device_retrieve_descriptors(&dev->ctrl_pipe,
+	    &dev->descriptors);
+	if (rc != EOK) {
+		usb_log_error("Failed to retrieve standard device " \
+		    "descriptors of %s: %s.\n",
 		    dev->ddf_dev->name, str_error(rc));
 		return rc;
 	}
 
+
 	if (driver->endpoints != NULL) {
-		rc = initialize_other_pipes(driver->endpoints, dev);
-	}
-
-	/* No checking here. */
-	usb_pipe_end_session(&dev->ctrl_pipe);
+		rc = initialize_other_pipes(driver->endpoints, dev, 0);
+	}
+
+	usb_pipe_end_long_transfer(&dev->ctrl_pipe);
 
 	/* Rollback actions. */
@@ -291,8 +205,10 @@
  * @return Number of alternate interfaces for @p interface_no interface.
  */
-static size_t count_alternate_interfaces(uint8_t *config_descr,
-    size_t config_descr_size, int interface_no)
+size_t usb_interface_count_alternates(uint8_t *config_descr,
+    size_t config_descr_size, uint8_t interface_no)
 {
 	assert(config_descr != NULL);
+	assert(config_descr_size > 0);
+
 	usb_dp_parser_t dp_parser = {
 		.nesting = usb_dp_standard_descriptor_nesting
@@ -343,5 +259,5 @@
 
 	alternates->alternative_count
-	    = count_alternate_interfaces(dev->descriptors.configuration,
+	    = usb_interface_count_alternates(dev->descriptors.configuration,
 	    dev->descriptors.configuration_size, dev->interface_no);
 
@@ -457,36 +373,10 @@
 static int destroy_current_pipes(usb_device_t *dev)
 {
-	size_t i;
-	int rc;
-
-	/* TODO: this shall be done under some device mutex. */
-
-	/* First check that no session is opened. */
-	for (i = 0; i < dev->pipes_count; i++) {
-		if (usb_pipe_is_session_started(dev->pipes[i].pipe)) {
-			return EBUSY;
-		}
-	}
-
-	/* Prepare connection to HC. */
-	usb_hc_connection_t hc_conn;
-	rc = usb_hc_connection_initialize_from_device(&hc_conn, dev->ddf_dev);
-	if (rc != EOK) {
-		return rc;
-	}
-	rc = usb_hc_connection_open(&hc_conn);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	/* Destroy the pipes. */
-	for (i = 0; i < dev->pipes_count; i++) {
-		usb_pipe_unregister(dev->pipes[i].pipe, &hc_conn);
-		free(dev->pipes[i].pipe);
-	}
-
-	usb_hc_connection_close(&hc_conn);
-
-	free(dev->pipes);
+	int rc = usb_device_destroy_pipes(dev->ddf_dev,
+	    dev->pipes, dev->pipes_count);
+	if (rc != EOK) {
+		return rc;
+	}
+
 	dev->pipes = NULL;
 	dev->pipes_count = 0;
@@ -535,7 +425,218 @@
 
 	/* Create new pipes. */
-	rc = initialize_other_pipes(endpoints, dev);
+	rc = initialize_other_pipes(endpoints, dev, (int) alternate_setting);
 
 	return rc;
+}
+
+/** Retrieve basic descriptors from the device.
+ *
+ * @param[in] ctrl_pipe Control pipe with opened session.
+ * @param[out] descriptors Where to store the descriptors.
+ * @return Error code.
+ */
+int usb_device_retrieve_descriptors(usb_pipe_t *ctrl_pipe,
+    usb_device_descriptors_t *descriptors)
+{
+	assert(descriptors != NULL);
+	assert(usb_pipe_is_session_started(ctrl_pipe));
+
+	descriptors->configuration = NULL;
+
+	int rc;
+
+	/* Get the device descriptor. */
+	rc = usb_request_get_device_descriptor(ctrl_pipe, &descriptors->device);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/* Get the full configuration descriptor. */
+	rc = usb_request_get_full_configuration_descriptor_alloc(
+	    ctrl_pipe, 0, (void **) &descriptors->configuration,
+	    &descriptors->configuration_size);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	return EOK;
+}
+
+/** Create pipes for a device.
+ *
+ * This is more or less a wrapper that does following actions:
+ * - allocate and initialize pipes
+ * - map endpoints to the pipes based on the descriptions
+ * - registers endpoints with the host controller
+ *
+ * @param[in] dev Generic DDF device backing the USB one.
+ * @param[in] wire Initialized backing connection to the host controller.
+ * @param[in] endpoints Endpoints description, NULL terminated.
+ * @param[in] config_descr Configuration descriptor of active configuration.
+ * @param[in] config_descr_size Size of @p config_descr in bytes.
+ * @param[in] interface_no Interface to map from.
+ * @param[in] interface_setting Interface setting (default is usually 0).
+ * @param[out] pipes_ptr Where to store array of created pipes
+ *	(not NULL terminated).
+ * @param[out] pipes_count_ptr Where to store number of pipes
+ *	(set to if you wish to ignore the count).
+ * @return Error code.
+ */
+int usb_device_create_pipes(ddf_dev_t *dev, usb_device_connection_t *wire,
+    usb_endpoint_description_t **endpoints,
+    uint8_t *config_descr, size_t config_descr_size,
+    int interface_no, int interface_setting,
+    usb_endpoint_mapping_t **pipes_ptr, size_t *pipes_count_ptr)
+{
+	assert(dev != NULL);
+	assert(wire != NULL);
+	assert(endpoints != NULL);
+	assert(config_descr != NULL);
+	assert(config_descr_size > 0);
+	assert(pipes_ptr != NULL);
+
+	size_t i;
+	int rc;
+
+	size_t pipe_count = count_other_pipes(endpoints);
+	if (pipe_count == 0) {
+		*pipes_ptr = NULL;
+		return EOK;
+	}
+
+	usb_endpoint_mapping_t *pipes
+	    = malloc(sizeof(usb_endpoint_mapping_t) * pipe_count);
+	if (pipes == NULL) {
+		return ENOMEM;
+	}
+
+	/* Initialize to NULL to allow smooth rollback. */
+	for (i = 0; i < pipe_count; i++) {
+		pipes[i].pipe = NULL;
+	}
+
+	/* Now allocate and fully initialize. */
+	for (i = 0; i < pipe_count; i++) {
+		pipes[i].pipe = malloc(sizeof(usb_pipe_t));
+		if (pipes[i].pipe == NULL) {
+			rc = ENOMEM;
+			goto rollback_free_only;
+		}
+		pipes[i].description = endpoints[i];
+		pipes[i].interface_no = interface_no;
+		pipes[i].interface_setting = interface_setting;
+	}
+
+	/* Find the mapping from configuration descriptor. */
+	rc = usb_pipe_initialize_from_configuration(pipes, pipe_count,
+	    config_descr, config_descr_size, wire);
+	if (rc != EOK) {
+		goto rollback_free_only;
+	}
+
+	/* Register the endpoints with HC. */
+	usb_hc_connection_t hc_conn;
+	rc = usb_hc_connection_initialize_from_device(&hc_conn, dev);
+	if (rc != EOK) {
+		goto rollback_free_only;
+	}
+
+	rc = usb_hc_connection_open(&hc_conn);
+	if (rc != EOK) {
+		goto rollback_free_only;
+	}
+
+	for (i = 0; i < pipe_count; i++) {
+		if (pipes[i].present) {
+			rc = usb_pipe_register(pipes[i].pipe,
+			    pipes[i].descriptor->poll_interval, &hc_conn);
+			if (rc != EOK) {
+				goto rollback_unregister_endpoints;
+			}
+		}
+	}
+
+	usb_hc_connection_close(&hc_conn);
+
+	*pipes_ptr = pipes;
+	if (pipes_count_ptr != NULL) {
+		*pipes_count_ptr = pipe_count;
+	}
+
+	return EOK;
+
+	/*
+	 * Jump here if something went wrong after endpoints have
+	 * been registered.
+	 * This is also the target when the registration of
+	 * endpoints fails.
+	 */
+rollback_unregister_endpoints:
+	for (i = 0; i < pipe_count; i++) {
+		if (pipes[i].present) {
+			usb_pipe_unregister(pipes[i].pipe, &hc_conn);
+		}
+	}
+
+	usb_hc_connection_close(&hc_conn);
+
+	/*
+	 * Jump here if something went wrong before some actual communication
+	 * with HC. Then the only thing that needs to be done is to free
+	 * allocated memory.
+	 */
+rollback_free_only:
+	for (i = 0; i < pipe_count; i++) {
+		if (pipes[i].pipe != NULL) {
+			free(pipes[i].pipe);
+		}
+	}
+	free(pipes);
+
+	return rc;
+}
+
+/** Destroy pipes previously created by usb_device_create_pipes.
+ *
+ * @param[in] dev Generic DDF device backing the USB one.
+ * @param[in] pipes Endpoint mapping to be destroyed.
+ * @param[in] pipes_count Number of endpoints.
+ */
+int usb_device_destroy_pipes(ddf_dev_t *dev,
+    usb_endpoint_mapping_t *pipes, size_t pipes_count)
+{
+	assert(dev != NULL);
+	assert(((pipes != NULL) && (pipes_count > 0))
+	    || ((pipes == NULL) && (pipes_count == 0)));
+
+	if (pipes_count == 0) {
+		return EOK;
+	}
+
+	int rc;
+
+	/* Prepare connection to HC to allow endpoint unregistering. */
+	usb_hc_connection_t hc_conn;
+	rc = usb_hc_connection_initialize_from_device(&hc_conn, dev);
+	if (rc != EOK) {
+		return rc;
+	}
+	rc = usb_hc_connection_open(&hc_conn);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/* Destroy the pipes. */
+	size_t i;
+	for (i = 0; i < pipes_count; i++) {
+		usb_pipe_unregister(pipes[i].pipe, &hc_conn);
+		free(pipes[i].pipe);
+	}
+
+	usb_hc_connection_close(&hc_conn);
+
+	free(pipes);
+
+	return EOK;
 }
 
Index: uspace/lib/usb/src/devpoll.c
===================================================================
--- uspace/lib/usb/src/devpoll.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/devpoll.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -77,16 +77,8 @@
 		int rc;
 
-		rc = usb_pipe_start_session(pipe);
-		if (rc != EOK) {
-			failed_attempts++;
-			continue;
-		}
-
 		size_t actual_size;
 		rc = usb_pipe_read(pipe, polling_data->buffer,
 		    polling_data->request_size, &actual_size);
 
-		/* Quit the session regardless of errors. */
-		usb_pipe_end_session(pipe);
 		
 //		if (rc == ESTALL) {
Index: uspace/lib/usb/src/host/device_keeper.c
===================================================================
--- uspace/lib/usb/src/host/device_keeper.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/host/device_keeper.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -56,6 +56,10 @@
 		instance->devices[i].control_used = 0;
 		instance->devices[i].handle = 0;
+		instance->devices[i].speed = USB_SPEED_MAX;
 		list_initialize(&instance->devices[i].endpoints);
 	}
+	// TODO: is this hack enough?
+	// (it is needed to allow smooth registration at default address)
+	instance->devices[0].occupied = true;
 }
 /*----------------------------------------------------------------------------*/
@@ -67,4 +71,15 @@
 	assert(instance->devices[address].occupied);
 	list_append(&ep->same_device_eps, &instance->devices[address].endpoints);
+	fibril_mutex_unlock(&instance->guard);
+}
+/*----------------------------------------------------------------------------*/
+void usb_device_keeper_del_ep(
+    usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep)
+{
+	assert(instance);
+	fibril_mutex_lock(&instance->guard);
+	assert(instance->devices[address].occupied);
+	list_remove(&ep->same_device_eps);
+	list_initialize(&ep->same_device_eps);
 	fibril_mutex_unlock(&instance->guard);
 }
Index: uspace/lib/usb/src/hub.c
===================================================================
--- uspace/lib/usb/src/hub.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/hub.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -40,4 +40,5 @@
 #include <errno.h>
 #include <assert.h>
+#include <usb/debug.h>
 
 /** Check that HC connection is alright.
@@ -55,4 +56,5 @@
 
 /** Tell host controller to reserve default address.
+ * @deprecated
  *
  * @param connection Opened connection to host controller.
@@ -65,4 +67,6 @@
 	CHECK_CONNECTION(connection);
 
+	usb_log_warning("usb_hc_reserve_default_address() considered obsolete");
+
 	return async_req_2_0(connection->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE),
@@ -71,4 +75,5 @@
 
 /** Tell host controller to release default address.
+ * @deprecated
  *
  * @param connection Opened connection to host controller.
@@ -78,4 +83,6 @@
 {
 	CHECK_CONNECTION(connection);
+
+	usb_log_warning("usb_hc_release_default_address() considered obsolete");
 
 	return async_req_1_0(connection->hc_phone,
@@ -235,25 +242,9 @@
 	}
 
-
-	/*
-	 * Reserve the default address.
-	 */
-	rc = usb_hc_reserve_default_address(&hc_conn, dev_speed);
-	if (rc != EOK) {
-		rc = EBUSY;
-		goto leave_release_free_address;
-	}
-
-	/*
-	 * Enable the port (i.e. allow signaling through this port).
-	 */
-	rc = enable_port(port_no, arg);
-	if (rc != EOK) {
-		goto leave_release_default_address;
-	}
-
-	/*
-	 * Change the address from default to the free one.
-	 * We need to create a new control pipe for that.
+	/*
+	 * We will not register control pipe on default address.
+	 * The registration might fail. That means that someone else already
+	 * registered that endpoint. We will simply wait and try again.
+	 * (Someone else already wants to add a new device.)
 	 */
 	usb_device_connection_t dev_conn;
@@ -262,5 +253,5 @@
 	if (rc != EOK) {
 		rc = ENOTCONN;
-		goto leave_release_default_address;
+		goto leave_release_free_address;
 	}
 
@@ -270,54 +261,50 @@
 	if (rc != EOK) {
 		rc = ENOTCONN;
+		goto leave_release_free_address;
+	}
+
+	do {
+		rc = usb_pipe_register_with_speed(&ctrl_pipe, dev_speed, 0,
+		    &hc_conn);
+		if (rc != EOK) {
+			/* Do not overheat the CPU ;-). */
+			async_usleep(10);
+		}
+	} while (rc != EOK);
+
+	/*
+	 * Endpoint is registered. We can enable the port and change
+	 * device address.
+	 */
+	rc = enable_port(port_no, arg);
+	if (rc != EOK) {
 		goto leave_release_default_address;
 	}
 
-	/* Before sending any traffic, we need to register this
-	 * endpoint.
+	rc = usb_pipe_probe_default_control(&ctrl_pipe);
+	if (rc != EOK) {
+		rc = ESTALL;
+		goto leave_release_default_address;
+	}
+
+	rc = usb_request_set_address(&ctrl_pipe, dev_addr);
+	if (rc != EOK) {
+		rc = ESTALL;
+		goto leave_release_default_address;
+	}
+
+	/*
+	 * Address changed. We can release the original endpoint, thus
+	 * allowing other to access the default address.
+	 */
+	unregister_control_endpoint_on_default_address(&hc_conn);
+
+	/*
+	 * Time to register the new endpoint.
 	 */
 	rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
 	if (rc != EOK) {
-		rc = EREFUSED;
-		goto leave_release_default_address;
-	}
-	rc = usb_pipe_probe_default_control(&ctrl_pipe);
-	if (rc != EOK) {
-		rc = ENOTCONN;
-		goto leave_release_default_address;
-	}
-
-	rc = usb_pipe_start_session(&ctrl_pipe);
-	if (rc != EOK) {
-		rc = ENOTCONN;
-		goto leave_unregister_endpoint;
-	}
-
-	rc = usb_request_set_address(&ctrl_pipe, dev_addr);
-	if (rc != EOK) {
-		rc = ESTALL;
-		goto leave_stop_session;
-	}
-
-	usb_pipe_end_session(&ctrl_pipe);
-
-	/*
-	 * Register the control endpoint for the new device.
-	 */
-	rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn);
-	if (rc != EOK) {
-		rc = EREFUSED;
-		goto leave_unregister_endpoint;
-	}
-
-	/*
-	 * Release the original endpoint.
-	 */
-	unregister_control_endpoint_on_default_address(&hc_conn);
-
-	/*
-	 * Once the address is changed, we can return the default address.
-	 */
-	usb_hc_release_default_address(&hc_conn);
-
+		goto leave_release_free_address;
+	}
 
 	/*
@@ -334,6 +321,4 @@
 	}
 
-
-
 	/*
 	 * And now inform the host controller about the handle.
@@ -367,13 +352,6 @@
 	 * Completely ignoring errors here.
 	 */
-
-leave_stop_session:
-	usb_pipe_end_session(&ctrl_pipe);
-
-leave_unregister_endpoint:
+leave_release_default_address:
 	usb_pipe_unregister(&ctrl_pipe, &hc_conn);
-
-leave_release_default_address:
-	usb_hc_release_default_address(&hc_conn);
 
 leave_release_free_address:
Index: uspace/lib/usb/src/pipepriv.c
===================================================================
--- uspace/lib/usb/src/pipepriv.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
+++ uspace/lib/usb/src/pipepriv.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusb
+ * @{
+ */
+/** @file
+ * Library internal functions on USB pipes (implementation).
+ */
+#include "pipepriv.h"
+#include <devman.h>
+#include <errno.h>
+#include <assert.h>
+
+/** Ensure exclusive access to the IPC phone of given pipe.
+ *
+ * @param pipe Pipe to be exclusively accessed.
+ */
+void pipe_start_transaction(usb_pipe_t *pipe)
+{
+	fibril_mutex_lock(&pipe->hc_phone_mutex);
+}
+
+/** Terminate exclusive access to the IPC phone of given pipe.
+ *
+ * @param pipe Pipe to be released from exclusive usage.
+ */
+void pipe_end_transaction(usb_pipe_t *pipe)
+{
+	fibril_mutex_unlock(&pipe->hc_phone_mutex);
+}
+
+/** Ensure exclusive access to the pipe as a whole.
+ *
+ * @param pipe Pipe to be exclusively accessed.
+ */
+void pipe_acquire(usb_pipe_t *pipe)
+{
+	fibril_mutex_lock(&pipe->guard);
+}
+
+/** Terminate exclusive access to the pipe as a whole.
+ *
+ * @param pipe Pipe to be released from exclusive usage.
+ */
+void pipe_release(usb_pipe_t *pipe)
+{
+	fibril_mutex_unlock(&pipe->guard);
+}
+
+/** Add reference of active transfers over the pipe.
+ *
+ * @param pipe The USB pipe.
+ * @return Error code.
+ * @retval EOK Currently always.
+ */
+int pipe_add_ref(usb_pipe_t *pipe)
+{
+another_try:
+	pipe_acquire(pipe);
+
+	if (pipe->refcount == 0) {
+		/* Need to open the phone by ourselves. */
+		int phone = devman_device_connect(pipe->wire->hc_handle, 0);
+		if (phone < 0) {
+			// TODO: treat some error as non-recoverable
+			// and return error from here
+			pipe_release(pipe);
+			goto another_try;
+		}
+		/*
+		 * No locking is needed, refcount is zero and whole pipe
+		 * mutex is locked.
+		 */
+		pipe->hc_phone = phone;
+	}
+	pipe->refcount++;
+
+	pipe_release(pipe);
+
+	return EOK;
+}
+
+/** Drop active transfer reference on the pipe.
+ *
+ * @param pipe The USB pipe.
+ */
+void pipe_drop_ref(usb_pipe_t *pipe)
+{
+	pipe_acquire(pipe);
+	assert(pipe->refcount > 0);
+	pipe->refcount--;
+	if (pipe->refcount == 0) {
+		/* We were the last users, let's hang-up. */
+		async_hangup(pipe->hc_phone);
+		pipe->hc_phone = -1;
+	}
+	pipe_release(pipe);
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/pipepriv.h
===================================================================
--- uspace/lib/usb/src/pipepriv.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
+++ uspace/lib/usb/src/pipepriv.h	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusb
+ * @{
+ */
+/** @file
+ * Library internal functions on USB pipes.
+ */
+#ifndef LIBUSB_PIPEPRIV_H_
+#define LIBUSB_PIPEPRIV_H_
+
+#include <usb/pipes.h>
+
+void pipe_acquire(usb_pipe_t *);
+void pipe_release(usb_pipe_t *);
+
+void pipe_start_transaction(usb_pipe_t *);
+void pipe_end_transaction(usb_pipe_t *);
+
+int pipe_add_ref(usb_pipe_t *);
+void pipe_drop_ref(usb_pipe_t *);
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/pipes.c
===================================================================
--- uspace/lib/usb/src/pipes.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/pipes.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -41,4 +41,5 @@
 #include <errno.h>
 #include <assert.h>
+#include "pipepriv.h"
 
 #define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */
@@ -241,4 +242,7 @@
  * necessary.
  *
+ * @deprecated
+ * Obsoleted with introduction of usb_pipe_start_long_transfer
+ *
  * @param pipe Endpoint pipe to start the session on.
  * @return Error code.
@@ -246,17 +250,5 @@
 int usb_pipe_start_session(usb_pipe_t *pipe)
 {
-	assert(pipe);
-
-	if (usb_pipe_is_session_started(pipe)) {
-		return EBUSY;
-	}
-
-	int phone = devman_device_connect(pipe->wire->hc_handle, 0);
-	if (phone < 0) {
-		return phone;
-	}
-
-	pipe->hc_phone = phone;
-
+	usb_log_warning("usb_pipe_start_session() was deprecated.\n");
 	return EOK;
 }
@@ -265,4 +257,7 @@
 /** Ends a session on the endpoint pipe.
  *
+ * @deprecated
+ * Obsoleted with introduction of usb_pipe_end_long_transfer
+ *
  * @see usb_pipe_start_session
  *
@@ -272,17 +267,5 @@
 int usb_pipe_end_session(usb_pipe_t *pipe)
 {
-	assert(pipe);
-
-	if (!usb_pipe_is_session_started(pipe)) {
-		return ENOENT;
-	}
-
-	int rc = async_hangup(pipe->hc_phone);
-	if (rc != EOK) {
-		return rc;
-	}
-
-	pipe->hc_phone = -1;
-
+	usb_log_warning("usb_pipe_end_session() was deprecated.\n");
 	return EOK;
 }
@@ -298,5 +281,34 @@
 bool usb_pipe_is_session_started(usb_pipe_t *pipe)
 {
-	return (pipe->hc_phone >= 0);
+	pipe_acquire(pipe);
+	bool started = pipe->refcount > 0;
+	pipe_release(pipe);
+	return started;
+}
+
+/** Prepare pipe for a long transfer.
+ *
+ * By a long transfer is mean transfer consisting of several
+ * requests to the HC.
+ * Calling such function is optional and it has positive effect of
+ * improved performance because IPC session is initiated only once.
+ *
+ * @param pipe Pipe over which the transfer will happen.
+ * @return Error code.
+ */
+int usb_pipe_start_long_transfer(usb_pipe_t *pipe)
+{
+	return pipe_add_ref(pipe);
+}
+
+/** Terminate a long transfer on a pipe.
+ *
+ * @see usb_pipe_start_long_transfer
+ *
+ * @param pipe Pipe where to end the long transfer.
+ */
+void usb_pipe_end_long_transfer(usb_pipe_t *pipe)
+{
+	pipe_drop_ref(pipe);
 }
 
Index: uspace/lib/usb/src/pipesinit.c
===================================================================
--- uspace/lib/usb/src/pipesinit.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/pipesinit.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -356,10 +356,13 @@
 	assert(connection);
 
+	fibril_mutex_initialize(&pipe->guard);
 	pipe->wire = connection;
 	pipe->hc_phone = -1;
+	fibril_mutex_initialize(&pipe->hc_phone_mutex);
 	pipe->endpoint_no = endpoint_no;
 	pipe->transfer_type = transfer_type;
 	pipe->max_packet_size = max_packet_size;
 	pipe->direction = direction;
+	pipe->refcount = 0;
 
 	return EOK;
@@ -413,10 +416,5 @@
 	int rc;
 
-	TRY_LOOP(failed_attempts) {
-		rc = usb_pipe_start_session(pipe);
-		if (rc == EOK) {
-			break;
-		}
-	}
+	rc = usb_pipe_start_long_transfer(pipe);
 	if (rc != EOK) {
 		return rc;
@@ -439,5 +437,5 @@
 		}
 	}
-	usb_pipe_end_session(pipe);
+	usb_pipe_end_long_transfer(pipe);
 	if (rc != EOK) {
 		return rc;
@@ -461,4 +459,25 @@
     usb_hc_connection_t *hc_connection)
 {
+	return usb_pipe_register_with_speed(pipe, USB_SPEED_MAX + 1,
+	    interval, hc_connection);
+}
+
+/** Register endpoint with a speed at the host controller.
+ *
+ * You will rarely need to use this function because it is needed only
+ * if the registered endpoint is of address 0 and there is no other way
+ * to tell speed of the device at address 0.
+ *
+ * @param pipe Pipe to be registered.
+ * @param speed Speed of the device
+ *	(invalid speed means use previously specified one).
+ * @param interval Polling interval.
+ * @param hc_connection Connection to the host controller (must be opened).
+ * @return Error code.
+ */
+int usb_pipe_register_with_speed(usb_pipe_t *pipe, usb_speed_t speed,
+    unsigned int interval,
+    usb_hc_connection_t *hc_connection)
+{
 	assert(pipe);
 	assert(hc_connection);
@@ -468,13 +487,15 @@
 	}
 
-#define _PACK(high, low) ((high) * 256 + (low))
-
-	return async_req_5_0(hc_connection->hc_phone,
+#define _PACK2(high, low) (((high) << 16) + (low))
+#define _PACK3(high, middle, low) (((((high) << 8) + (middle)) << 8) + (low))
+
+	return async_req_4_0(hc_connection->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_REGISTER_ENDPOINT,
-	    _PACK(pipe->wire->address, pipe->endpoint_no),
-	    _PACK(pipe->transfer_type, pipe->direction),
-	    pipe->max_packet_size, interval);
-
-#undef _PACK
+	    _PACK2(pipe->wire->address, pipe->endpoint_no),
+	    _PACK3(speed, pipe->transfer_type, pipe->direction),
+	    _PACK2(pipe->max_packet_size, interval));
+
+#undef _PACK2
+#undef _PACK3
 }
 
Index: uspace/lib/usb/src/pipesio.c
===================================================================
--- uspace/lib/usb/src/pipesio.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/pipesio.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -49,4 +49,5 @@
 #include <assert.h>
 #include <usbhc_iface.h>
+#include "pipepriv.h"
 
 /** Request an in transfer, no checking of input parameters.
@@ -78,13 +79,16 @@
 	}
 
+	/* Ensure serialization over the phone. */
+	pipe_start_transaction(pipe);
+
 	/*
 	 * Make call identifying target USB device and type of transfer.
 	 */
-	aid_t opening_request = async_send_4(pipe->hc_phone,
+	aid_t opening_request = async_send_3(pipe->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
 	    pipe->wire->address, pipe->endpoint_no,
-	    pipe->max_packet_size,
 	    NULL);
 	if (opening_request == 0) {
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -96,4 +100,10 @@
 	aid_t data_request = async_data_read(pipe->hc_phone, buffer, size,
 	    &data_request_call);
+
+	/*
+	 * Since now on, someone else might access the backing phone
+	 * without breaking the transfer IPC protocol.
+	 */
+	pipe_end_transaction(pipe);
 
 	if (data_request == 0) {
@@ -146,13 +156,9 @@
 
 	if (buffer == NULL) {
-			return EINVAL;
+		return EINVAL;
 	}
 
 	if (size == 0) {
 		return EINVAL;
-	}
-
-	if (!usb_pipe_is_session_started(pipe)) {
-		return EBADF;
 	}
 
@@ -165,8 +171,17 @@
 	}
 
+	int rc;
+	rc = pipe_add_ref(pipe);
+	if (rc != EOK) {
+		return rc;
+	}
+
+
 	size_t act_size = 0;
-	int rc;
 
 	rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
+
+	pipe_drop_ref(pipe);
+
 	if (rc != EOK) {
 		return rc;
@@ -210,13 +225,16 @@
 	}
 
+	/* Ensure serialization over the phone. */
+	pipe_start_transaction(pipe);
+
 	/*
 	 * Make call identifying target USB device and type of transfer.
 	 */
-	aid_t opening_request = async_send_4(pipe->hc_phone,
+	aid_t opening_request = async_send_3(pipe->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
 	    pipe->wire->address, pipe->endpoint_no,
-	    pipe->max_packet_size,
 	    NULL);
 	if (opening_request == 0) {
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -226,4 +244,11 @@
 	 */
 	int rc = async_data_write_start(pipe->hc_phone, buffer, size);
+
+	/*
+	 * Since now on, someone else might access the backing phone
+	 * without breaking the transfer IPC protocol.
+	 */
+	pipe_end_transaction(pipe);
+
 	if (rc != EOK) {
 		async_wait_for(opening_request, NULL);
@@ -260,8 +285,4 @@
 	}
 
-	if (!usb_pipe_is_session_started(pipe)) {
-		return EBADF;
-	}
-
 	if (pipe->direction != USB_DIRECTION_OUT) {
 		return EBADF;
@@ -272,5 +293,14 @@
 	}
 
-	int rc = usb_pipe_write_no_check(pipe, buffer, size);
+	int rc;
+
+	rc = pipe_add_ref(pipe);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	rc = usb_pipe_write_no_check(pipe, buffer, size);
+
+	pipe_drop_ref(pipe);
 
 	return rc;
@@ -293,11 +323,13 @@
     void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
 {
+	/* Ensure serialization over the phone. */
+	pipe_start_transaction(pipe);
+
 	/*
 	 * Make call identifying target USB device and control transfer type.
 	 */
-	aid_t opening_request = async_send_4(pipe->hc_phone,
+	aid_t opening_request = async_send_3(pipe->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ,
 	    pipe->wire->address, pipe->endpoint_no,
-	    pipe->max_packet_size,
 	    NULL);
 	if (opening_request == 0) {
@@ -311,4 +343,5 @@
 	    setup_buffer, setup_buffer_size);
 	if (rc != EOK) {
+		pipe_end_transaction(pipe);
 		async_wait_for(opening_request, NULL);
 		return rc;
@@ -322,4 +355,12 @@
 	    data_buffer, data_buffer_size,
 	    &data_request_call);
+
+	/*
+	 * Since now on, someone else might access the backing phone
+	 * without breaking the transfer IPC protocol.
+	 */
+	pipe_end_transaction(pipe);
+
+
 	if (data_request == 0) {
 		async_wait_for(opening_request, NULL);
@@ -379,8 +420,4 @@
 	}
 
-	if (!usb_pipe_is_session_started(pipe)) {
-		return EBADF;
-	}
-
 	if ((pipe->direction != USB_DIRECTION_BOTH)
 	    || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
@@ -388,8 +425,17 @@
 	}
 
+	int rc;
+
+	rc = pipe_add_ref(pipe);
+	if (rc != EOK) {
+		return rc;
+	}
+
 	size_t act_size = 0;
-	int rc = usb_pipe_control_read_no_check(pipe,
+	rc = usb_pipe_control_read_no_check(pipe,
 	    setup_buffer, setup_buffer_size,
 	    data_buffer, data_buffer_size, &act_size);
+
+	pipe_drop_ref(pipe);
 
 	if (rc != EOK) {
@@ -418,14 +464,17 @@
     void *data_buffer, size_t data_buffer_size)
 {
+	/* Ensure serialization over the phone. */
+	pipe_start_transaction(pipe);
+
 	/*
 	 * Make call identifying target USB device and control transfer type.
 	 */
-	aid_t opening_request = async_send_5(pipe->hc_phone,
+	aid_t opening_request = async_send_4(pipe->hc_phone,
 	    DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE,
 	    pipe->wire->address, pipe->endpoint_no,
 	    data_buffer_size,
-	    pipe->max_packet_size,
 	    NULL);
 	if (opening_request == 0) {
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -437,4 +486,5 @@
 	    setup_buffer, setup_buffer_size);
 	if (rc != EOK) {
+		pipe_end_transaction(pipe);
 		async_wait_for(opening_request, NULL);
 		return rc;
@@ -447,8 +497,15 @@
 		rc = async_data_write_start(pipe->hc_phone,
 		    data_buffer, data_buffer_size);
+
+		/* All data sent, pipe can be released. */
+		pipe_end_transaction(pipe);
+
 		if (rc != EOK) {
 			async_wait_for(opening_request, NULL);
 			return rc;
 		}
+	} else {
+		/* No data to send, we can release the pipe for others. */
+		pipe_end_transaction(pipe);
 	}
 
@@ -491,8 +548,4 @@
 	}
 
-	if (!usb_pipe_is_session_started(pipe)) {
-		return EBADF;
-	}
-
 	if ((pipe->direction != USB_DIRECTION_BOTH)
 	    || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
@@ -500,6 +553,15 @@
 	}
 
-	int rc = usb_pipe_control_write_no_check(pipe,
+	int rc;
+
+	rc = pipe_add_ref(pipe);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	rc = usb_pipe_control_write_no_check(pipe,
 	    setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
+
+	pipe_drop_ref(pipe);
 
 	return rc;
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 87906500fff813e7fa98e3c24caafe7911fef646)
+++ uspace/lib/usb/src/recognise.c	(revision 501e5df2482df5d8fad5599fc5f684cdc627c72e)
@@ -404,15 +404,5 @@
 	child->driver_data = dev_data;
 
-	rc = usb_pipe_start_session(&ctrl_pipe);
-	if (rc != EOK) {
-		goto failure;
-	}
-
 	rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
-	if (rc != EOK) {
-		goto failure;
-	}
-
-	rc = usb_pipe_end_session(&ctrl_pipe);
 	if (rc != EOK) {
 		goto failure;
