Index: uspace/lib/drv/generic/remote_usb.c
===================================================================
--- uspace/lib/drv/generic/remote_usb.c	(revision 317a4637d99500a6600c65568a00f718c274a6ea)
+++ uspace/lib/drv/generic/remote_usb.c	(revision 56bdd9a4306c6d99a59c72a07fe62501b10576c1)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Vojtech Horky
+ * Copyright (c) 2011 Jan Vesely
  * All rights reserved.
  *
@@ -39,4 +40,65 @@
 #include "ddf/driver.h"
 
+typedef enum {
+	IPC_M_USB_GET_MY_ADDRESS,
+	IPC_M_USB_GET_MY_INTERFACE,
+	IPC_M_USB_GET_HOST_CONTROLLER_HANDLE,
+} usb_iface_funcs_t;
+
+/** Tell USB address assigned to device.
+ * @param exch Vaid IPC exchange
+ * @param address Pointer to address storage place.
+ * @return Error code.
+ *
+ * Exch param is an open communication to device implementing usb_iface.
+ */
+int usb_get_my_address(async_exch_t *exch, usb_address_t *address)
+{
+	if (!exch)
+		return EINVAL;
+	sysarg_t addr;
+	const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_MY_ADDRESS, &addr);
+
+	if (ret == EOK && address != NULL)
+		*address = (usb_address_t) addr;
+	return ret;
+}
+/*----------------------------------------------------------------------------*/
+/** Tell interface number given device can use.
+ * @param[in] exch IPC communication exchange
+ * @param[in] handle Id of the device
+ * @param[out] usb_iface Assigned USB interface
+ * @return Error code.
+ */
+int usb_get_my_interface(async_exch_t *exch, int *usb_iface)
+{
+	if (!exch)
+		return EINVAL;
+	sysarg_t iface_no;
+	const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_MY_INTERFACE, &iface_no);
+	if (ret == EOK && usb_iface)
+		*usb_iface = (int)iface_no;
+	return ret;
+}
+/*----------------------------------------------------------------------------*/
+/** Tell devman handle of device host controller.
+ * @param[in] exch IPC communication exchange
+ * @param[out] hc_handle devman handle of the HC used by the target device.
+ * @return Error code.
+ */
+int usb_get_hc_handle(async_exch_t *exch, devman_handle_t *hc_handle)
+{
+	if (!exch)
+		return EINVAL;
+	devman_handle_t h;
+	const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
+	if (ret == EOK && hc_handle)
+		*hc_handle = (devman_handle_t)h;
+	return ret;
+}
+
 
 static void remote_usb_get_my_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
@@ -59,9 +121,9 @@
 };
 
-
+/*----------------------------------------------------------------------------*/
 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
-	usb_iface_t *usb_iface = (usb_iface_t *) iface;
+	const usb_iface_t *usb_iface = (usb_iface_t *) iface;
 
 	if (usb_iface->get_my_address == NULL) {
@@ -71,16 +133,16 @@
 
 	usb_address_t address;
-	int rc = usb_iface->get_my_address(fun, &address);
-	if (rc != EOK) {
-		async_answer_0(callid, rc);
+	const int ret = usb_iface->get_my_address(fun, &address);
+	if (ret != EOK) {
+		async_answer_0(callid, ret);
 	} else {
 		async_answer_1(callid, EOK, address);
 	}
 }
-
+/*----------------------------------------------------------------------------*/
 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
-	usb_iface_t *usb_iface = (usb_iface_t *) iface;
+	const usb_iface_t *usb_iface = (usb_iface_t *) iface;
 
 	if (usb_iface->get_my_interface == NULL) {
@@ -90,16 +152,16 @@
 
 	int iface_no;
-	int rc = usb_iface->get_my_interface(fun, &iface_no);
-	if (rc != EOK) {
-		async_answer_0(callid, rc);
+	const int ret = usb_iface->get_my_interface(fun, &iface_no);
+	if (ret != EOK) {
+		async_answer_0(callid, ret);
 	} else {
 		async_answer_1(callid, EOK, iface_no);
 	}
 }
-
+/*----------------------------------------------------------------------------*/
 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
-	usb_iface_t *usb_iface = (usb_iface_t *) iface;
+	const usb_iface_t *usb_iface = (usb_iface_t *) iface;
 
 	if (usb_iface->get_hc_handle == NULL) {
@@ -109,14 +171,11 @@
 
 	devman_handle_t handle;
-	int rc = usb_iface->get_hc_handle(fun, &handle);
-	if (rc != EOK) {
-		async_answer_0(callid, rc);
+	const int ret = usb_iface->get_hc_handle(fun, &handle);
+	if (ret != EOK) {
+		async_answer_0(callid, ret);
 	}
 
 	async_answer_1(callid, EOK, (sysarg_t) handle);
 }
-
-
-
 /**
  * @}
Index: uspace/lib/drv/include/usb_iface.h
===================================================================
--- uspace/lib/drv/include/usb_iface.h	(revision 317a4637d99500a6600c65568a00f718c274a6ea)
+++ uspace/lib/drv/include/usb_iface.h	(revision 56bdd9a4306c6d99a59c72a07fe62501b10576c1)
@@ -39,52 +39,10 @@
 
 #include "ddf/driver.h"
+#include <async.h>
 #include <usb/usb.h>
-typedef enum {
-	/** Tell USB address assigned to device.
-	 * Parameters:
-	 * - devman handle id
-	 * Answer:
-	 * - EINVAL - unknown handle or handle not managed by this driver
-	 * - ENOTSUP - operation not supported (shall not happen)
-	 * - arbitrary error code if returned by remote implementation
-	 * - EOK - handle found, first parameter contains the USB address
-	 *
-	 * The handle must be the one used for binding USB address with
-	 * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller
-	 * (that this request would eventually reach) would not be able
-	 * to find it.
-	 * The problem is that this handle is actually assigned to the
-	 * function inside driver of the parent device (usually hub driver).
-	 * To bypass this problem, the initial caller specify handle as
-	 * zero and the first parent assigns the actual value.
-	 * See usb_iface_get_address_hub_child_impl() implementation
-	 * that could be assigned to device ops of a child device of in a
-	 * hub driver.
-	 * For example, the USB multi interface device driver (MID)
-	 * passes this initial zero without any modification because the
-	 * handle must be resolved by its parent.
-	 */
-	IPC_M_USB_GET_MY_ADDRESS,
 
-	/** Tell interface number given device can use.
-	 * Parameters
-	 * - devman handle id of the device
-	 * Answer:
-	 * - ENOTSUP - operation not supported (can also mean any interface)
-	 * - EOK - operation okay, first parameter contains interface number
-	 */
-	IPC_M_USB_GET_MY_INTERFACE,
-
-	/** Tell devman handle of device host controller.
-	 * Parameters:
-	 * - none
-	 * Answer:
-	 * - EOK - request processed without errors
-	 * - ENOTSUP - this indicates invalid USB driver
-	 * Parameters of the answer:
-	 * - devman handle of HC caller is physically connected to
-	 */
-	IPC_M_USB_GET_HOST_CONTROLLER_HANDLE
-} usb_iface_funcs_t;
+int usb_get_my_address(async_exch_t *, usb_address_t *);
+int usb_get_my_interface(async_exch_t *, int *);
+int usb_get_hc_handle(async_exch_t *, devman_handle_t *);
 
 /** USB device communication interface. */
@@ -95,5 +53,4 @@
 } usb_iface_t;
 
-
 #endif
 /**
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision 317a4637d99500a6600c65568a00f718c274a6ea)
+++ uspace/lib/usb/src/ddfiface.c	(revision 56bdd9a4306c6d99a59c72a07fe62501b10576c1)
@@ -36,4 +36,5 @@
 #include <devman.h>
 #include <async.h>
+#include <usb_iface.h>
 #include <usb/ddfiface.h>
 #include <usb/hc.h>
@@ -104,19 +105,15 @@
 
 	async_exch_t *exch = async_exchange_begin(parent_sess);
+	if (!exch) {
+		async_hangup(parent_sess);
+		return ENOMEM;
+	}
 
-	sysarg_t addr;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_MY_ADDRESS, &addr);
+	const int ret = usb_get_my_address(exch, address);
 
 	async_exchange_end(exch);
 	async_hangup(parent_sess);
 
-	if (rc != EOK)
-		return rc;
-
-	if (address != NULL)
-		*address = (usb_address_t) addr;
-
-	return EOK;
+	return ret;
 }
 
Index: uspace/lib/usb/src/hc.c
===================================================================
--- uspace/lib/usb/src/hc.c	(revision 317a4637d99500a6600c65568a00f718c274a6ea)
+++ uspace/lib/usb/src/hc.c	(revision 56bdd9a4306c6d99a59c72a07fe62501b10576c1)
@@ -181,18 +181,20 @@
 	if (!parent_sess)
 		return ENOMEM;
-	
+
 	async_exch_t *exch = async_exchange_begin(parent_sess);
-	
-	sysarg_t address;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_MY_ADDRESS, &address);
-	
+	if (!exch) {
+		async_hangup(parent_sess);
+		return ENOMEM;
+	}
+	usb_address_t address;
+	const int ret = usb_get_my_address(exch, &address);
+
 	async_exchange_end(exch);
 	async_hangup(parent_sess);
-	
-	if (rc != EOK)
-		return rc;
-	
-	return (usb_address_t) address;
+
+	if (ret != EOK)
+		return ret;
+
+	return address;
 }
 
@@ -231,21 +233,16 @@
 	if (!parent_sess)
 		return ENOMEM;
-	
+
 	async_exch_t *exch = async_exchange_begin(parent_sess);
-	
-	devman_handle_t h;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
-	
+	if (!exch) {
+		async_hangup(parent_sess);
+		return ENOMEM;
+	}
+	const int ret = usb_get_hc_handle(exch, hc_handle);
+
 	async_exchange_end(exch);
 	async_hangup(parent_sess);
-	
-	if (rc != EOK)
-		return rc;
-	
-	if (hc_handle != NULL)
-		*hc_handle = h;
-	
-	return EOK;
+
+	return ret;
 }
 
Index: uspace/lib/usbdev/src/pipes.c
===================================================================
--- uspace/lib/usbdev/src/pipes.c	(revision 317a4637d99500a6600c65568a00f718c274a6ea)
+++ uspace/lib/usbdev/src/pipes.c	(revision 56bdd9a4306c6d99a59c72a07fe62501b10576c1)
@@ -54,16 +54,15 @@
 static usb_address_t get_my_address(async_sess_t *sess, const ddf_dev_t *dev)
 {
+	assert(sess);
 	async_exch_t *exch = async_exchange_begin(sess);
-	
-	sysarg_t address;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_MY_ADDRESS, &address);
-	
+	if (!exch)
+		return ENOMEM;
+
+	usb_address_t address;
+	const int ret = usb_get_my_address(exch, &address);
+
 	async_exchange_end(exch);
-	
-	if (rc != EOK)
-		return rc;
-	
-	return (usb_address_t) address;
+
+	return (ret == EOK) ? address : ret;
 }
 
@@ -71,5 +70,5 @@
  *
  * @param device Device in question.
- * @return Interface number (negative code means any).
+ * @return Error code (ENOTSUP means any).
  */
 int usb_device_get_assigned_interface(const ddf_dev_t *device)
@@ -80,19 +79,16 @@
 	    IPC_FLAG_BLOCKING);
 	if (!parent_sess)
-		return -1;
-	
+		return ENOMEM;
+
 	async_exch_t *exch = async_exchange_begin(parent_sess);
-	
-	sysarg_t iface_no;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_MY_INTERFACE, &iface_no);
-	
-	async_exchange_end(exch);
-	async_hangup(parent_sess);
-	
-	if (rc != EOK)
-		return -1;
-	
-	return (int) iface_no;
+	if (!exch) {
+		async_hangup(parent_sess);
+		return ENOMEM;
+	}
+
+	int iface_no;
+	const int ret = usb_get_my_interface(exch, &iface_no);
+
+	return ret == EOK ? iface_no : ret;
 }
 
