Index: uspace/drv/nic/ar9271/ar9271.c
===================================================================
--- uspace/drv/nic/ar9271/ar9271.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ar9271/ar9271.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -33,4 +33,5 @@
  */
 
+#include <async.h>
 #include <ieee80211.h>
 #include <usb/classes/classes.h>
@@ -41,7 +42,7 @@
 #include <ddf/interrupt.h>
 #include <errno.h>
+#include <str_error.h>
 #include <nic.h>
 #include <macros.h>
-#include <thread.h>
 #include "ath_usb.h"
 #include "wmi.h"
@@ -733,5 +734,5 @@
  * @param ar9271 AR9271 device structure
  *
- * @return EOK if succeed, negative error code otherwise
+ * @return EOK if succeed, error code otherwise
  *
  */
@@ -784,5 +785,5 @@
 			free(buffer);
 			usb_log_error("Error while uploading firmware. "
-			    "Error: %d\n", rc);
+			    "Error: %s\n", str_error_name(rc));
 			return rc;
 		}
@@ -818,5 +819,5 @@
 	
 	/* Wait until firmware is ready - wait for 1 second to be sure. */
-	thread_sleep(1);
+	async_sleep(1);
 	
 	return rc;
@@ -836,5 +837,5 @@
 	if (rc != EOK) {
 		usb_log_error("Failed to create USB device: %s, "
-		    "ERR_NUM = %d\n", err_msg, rc);
+		    "ERR_NUM = %s\n", err_msg, str_error_name(rc));
 		return NULL;
 	}
@@ -853,6 +854,6 @@
 	if (rc != EOK) {
 		free(ar9271);
-		usb_log_error("Failed to initialize AR9271 structure: %d\n",
-		    rc);
+		usb_log_error("Failed to initialize AR9271 structure: %s\n",
+		    str_error_name(rc));
 		return NULL;
 	}
@@ -876,5 +877,5 @@
  * @param dev The device structure.
  *
- * @return EOK if succeed, negative error code otherwise
+ * @return EOK if succeed, error code otherwise
  */
 static int ar9271_add_device(ddf_dev_t *dev)
Index: uspace/drv/nic/ar9271/ath_usb.c
===================================================================
--- uspace/drv/nic/ar9271/ath_usb.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ar9271/ath_usb.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -35,5 +35,5 @@
 #include <usb/dev/pipes.h>
 #include <usb/debug.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <errno.h>
 #include "ath_usb.h"
@@ -56,5 +56,5 @@
  * @param usb_device  Connected USB device.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -107,5 +107,5 @@
  * @param buffer_size Buffer size.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -124,5 +124,5 @@
  * @param transferred_size Real size of read data.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -140,5 +140,5 @@
  * @param buffer_size Buffer size.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -173,5 +173,5 @@
  * @param transferred_size Real size of read data.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
Index: uspace/drv/nic/ar9271/htc.c
===================================================================
--- uspace/drv/nic/ar9271/htc.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ar9271/htc.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -36,4 +36,5 @@
 #include <byteorder.h>
 #include <errno.h>
+#include <str_error.h>
 #include "wmi.h"
 #include "htc.h"
@@ -149,5 +150,5 @@
  * @param endpoint_id Destination endpoint.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -172,5 +173,5 @@
  * @param endpoint_id Destination endpoint.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -195,5 +196,5 @@
  * @param transferred_size Real size of read data.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -215,5 +216,5 @@
  * @param transferred_size Real size of read data.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -235,5 +236,5 @@
  *
  * @return EOK if succeed, EINVAL when failed to connect service,
- *         negative error code otherwise.
+ *         error code otherwise.
  *
  */
@@ -264,5 +265,5 @@
 	if (rc != EOK) {
 		free(buffer);
-		usb_log_error("Failed to send HTC message. Error: %d\n", rc);
+		usb_log_error("Failed to send HTC message. Error: %s\n", str_error_name(rc));
 		return rc;
 	}
@@ -278,5 +279,5 @@
 		free(buffer);
 		usb_log_error("Failed to receive HTC service connect response. "
-		    "Error: %d\n", rc);
+		    "Error: %s\n", str_error_name(rc));
 		return rc;
 	}
@@ -308,5 +309,5 @@
  * @param htc_device HTC device structure.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -331,5 +332,5 @@
 		free(buffer);
 		usb_log_error("Failed to send HTC config message. "
-		    "Error: %d\n", rc);
+		    "Error: %s\n", str_error_name(rc));
 		return rc;
 	}
@@ -344,5 +345,5 @@
 	if (rc != EOK) {
 		usb_log_error("Failed to receive HTC config response message. "
-		    "Error: %d\n", rc);
+		    "Error: %s\n", str_error_name(rc));
 	}
 	
@@ -356,5 +357,5 @@
  * @param htc_device HTC device structure.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -376,5 +377,5 @@
 	if (rc != EOK)
 		usb_log_error("Failed to send HTC setup complete message. "
-		    "Error: %d\n", rc);
+		    "Error: %s\n", str_error_name(rc));
 	
 	free(buffer);
@@ -390,5 +391,5 @@
  *
  * @return EOK if succeed, EINVAL if response error,
- *         negative error code otherwise.
+ *         error code otherwise.
  *
  */
@@ -404,5 +405,5 @@
 		free(buffer);
 		usb_log_error("Failed to receive HTC check ready message. "
-		    "Error: %d\n", rc);
+		    "Error: %s\n", str_error_name(rc));
 		return rc;
 	}
@@ -426,5 +427,5 @@
  * @param htc_device HTC device structure to be initialized.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -447,5 +448,5 @@
  * @param htc_device HTC device structure.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
Index: uspace/drv/nic/ar9271/hw.c
===================================================================
--- uspace/drv/nic/ar9271/hw.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ar9271/hw.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -49,5 +49,5 @@
  *
  * @return EOK if succeed, ETIMEOUT on timeout,
- *         negative error code otherwise.
+ *         error code otherwise.
  *
  */
@@ -215,5 +215,5 @@
  * @param ar9271 Device structure.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -636,5 +636,5 @@
  * @param ar9271 Device structure.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  */
 int hw_init(ar9271_t *ar9271)
Index: uspace/drv/nic/ar9271/wmi.c
===================================================================
--- uspace/drv/nic/ar9271/wmi.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ar9271/wmi.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -35,5 +35,6 @@
 #include <usb/debug.h>
 #include <errno.h>
-#include <malloc.h>
+#include <str_error.h>
+#include <stdlib.h>
 #include <mem.h>
 #include <byteorder.h>
@@ -46,5 +47,5 @@
  * @param res        Stored result.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -78,5 +79,5 @@
  * @param val        Value to be written
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -111,5 +112,5 @@
  * @param clear_bit  Bit to be cleared.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -145,5 +146,5 @@
  * @param set_bit    Bit to be set.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -160,5 +161,5 @@
  * @param clear_bit  Bit to be cleared.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -175,5 +176,5 @@
  * @param elements   Number of elements in array.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -219,5 +220,5 @@
  * @param response_buffer Buffer with response data.
  *
- * @return EOK if succeed, negative error code otherwise.
+ * @return EOK if succeed, error code otherwise.
  *
  */
@@ -245,5 +246,5 @@
 	if (rc != EOK) {
 		free(buffer);
-		usb_log_error("Failed to send WMI message. Error: %d\n", rc);
+		usb_log_error("Failed to send WMI message. Error: %s\n", str_error_name(rc));
 		return rc;
 	}
@@ -268,5 +269,5 @@
 			free(buffer);
 			usb_log_error("Failed to receive WMI message response. "
-			    "Error: %d\n", rc);
+			    "Error: %s\n", str_error_name(rc));
 			return rc;
 		}
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/e1k/e1k.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -33,4 +33,5 @@
  */
 
+#include <async.h>
 #include <assert.h>
 #include <stdio.h>
@@ -38,5 +39,4 @@
 #include <adt/list.h>
 #include <align.h>
-#include <thread.h>
 #include <byteorder.h>
 #include <as.h>
@@ -372,5 +372,5 @@
 		fibril_mutex_unlock(&e1000->ctrl_lock);
 		
-		thread_usleep(10);
+		async_usleep(10);
 		
 		fibril_mutex_lock(&e1000->ctrl_lock);
@@ -1237,10 +1237,9 @@
 /** Handle device interrupt
  *
- * @param iid   IPC call id
  * @param icall IPC call structure
  * @param dev   E1000 device
  *
  */
-static void e1000_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
+static void e1000_interrupt_handler(ipc_call_t *icall,
     ddf_dev_t *dev)
 {
@@ -1260,9 +1259,10 @@
  * @param nic Driver data
  *
- * @return IRQ capability handle if the handler was registered
- * @return Negative error code otherwise
- *
- */
-inline static int e1000_register_int_handler(nic_t *nic)
+ * @param[out] handle  IRQ capability handle if the handler was registered
+ *
+ * @return An error code otherwise
+ *
+ */
+inline static int e1000_register_int_handler(nic_t *nic, cap_handle_t *handle)
 {
 	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
@@ -1275,9 +1275,9 @@
 	e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC;
 	
-	int cap = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
-	    e1000_interrupt_handler, &e1000_irq_code);
+	int rc = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
+	    e1000_interrupt_handler, &e1000_irq_code, handle);
 	
 	fibril_mutex_unlock(&irq_reg_mutex);
-	return cap;
+	return rc;
 }
 
@@ -1370,5 +1370,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -1524,5 +1524,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -1725,5 +1725,5 @@
 	
 	/* Wait for the reset */
-	thread_usleep(20);
+	async_usleep(20);
 	
 	/* check if RST_BIT cleared */
@@ -1813,5 +1813,5 @@
 	 * transfers to descriptors.
 	 */
-	thread_usleep(100);
+	async_usleep(100);
 	
 	return EOK;
@@ -1940,5 +1940,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -1965,5 +1965,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -1993,5 +1993,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -2107,5 +2107,5 @@
  *
  * @return EOK if successed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -2165,7 +2165,7 @@
 	ddf_fun_set_ops(fun, &e1000_dev_ops);
 	
-	int irq_cap = e1000_register_int_handler(nic);
-	if (irq_cap < 0) {
-		rc = irq_cap;
+	int irq_cap;
+	rc = e1000_register_int_handler(nic, &irq_cap);
+	if (rc != EOK) {
 		goto err_fun_create;
 	}
@@ -2239,5 +2239,5 @@
 	uint32_t eerd = E1000_REG_READ(e1000, E1000_EERD);
 	while ((eerd & e1000->info.eerd_done) == 0) {
-		thread_usleep(1);
+		async_usleep(1);
 		eerd = E1000_REG_READ(e1000, E1000_EERD);
 	}
@@ -2255,5 +2255,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  *
  */
@@ -2289,5 +2289,5 @@
  *
  * @return EOK if succeed
- * @return Negative error code otherwise
+ * @return An error code otherwise
  */
 static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
Index: uspace/drv/nic/ne2k/dp8390.c
===================================================================
--- uspace/drv/nic/ne2k/dp8390.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ne2k/dp8390.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -55,9 +55,9 @@
 
 #include <assert.h>
+#include <async.h>
 #include <byteorder.h>
 #include <errno.h>
 #include <stdio.h>
 #include <ddi.h>
-#include <thread.h>
 #include "dp8390.h"
 
@@ -172,7 +172,7 @@
 	/* Reset the ethernet card */
 	uint8_t val = pio_read_8(ne2k->port + NE2K_RESET);
-	thread_usleep(2000);
+	async_usleep(2000);
 	pio_write_8(ne2k->port + NE2K_RESET, val);
-	thread_usleep(2000);
+	async_usleep(2000);
 	
 	/* Reset the DP8390 */
Index: uspace/drv/nic/ne2k/ne2k.c
===================================================================
--- uspace/drv/nic/ne2k/ne2k.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/ne2k/ne2k.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -122,7 +122,7 @@
 };
 
-static void ne2k_interrupt_handler(ipc_callid_t, ipc_call_t *, ddf_dev_t *);
-
-static int ne2k_register_interrupt(nic_t *nic_data)
+static void ne2k_interrupt_handler(ipc_call_t *, ddf_dev_t *);
+
+static int ne2k_register_interrupt(nic_t *nic_data, cap_handle_t *handle)
 {
 	ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
@@ -160,7 +160,6 @@
 	}
 
-	int irq_cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
-		ne2k->irq, ne2k_interrupt_handler, &ne2k->code);
-	return irq_cap;
+	return register_interrupt_handler(nic_get_ddf_dev(nic_data),
+		ne2k->irq, ne2k_interrupt_handler, &ne2k->code, handle);
 }
 
@@ -228,6 +227,5 @@
 	ne2k->probed = true;
 	
-	int irq_cap = ne2k_register_interrupt(nic_data);
-	if (irq_cap < 0)
+	if (ne2k_register_interrupt(nic_data, NULL) != EOK)
 		return EINVAL;
 	
@@ -239,10 +237,8 @@
 }
 
-void ne2k_interrupt_handler(ipc_callid_t iid, ipc_call_t *call, ddf_dev_t *dev)
+void ne2k_interrupt_handler(ipc_call_t *call, ddf_dev_t *dev)
 {
 	nic_t *nic_data = DRIVER_DATA(dev);
 	ne2k_interrupt(nic_data, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
-	
-	async_answer_0(iid, EOK);
 }
 
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -28,7 +28,7 @@
 
 #include <assert.h>
+#include <async.h>
 #include <errno.h>
 #include <align.h>
-#include <thread.h>
 #include <byteorder.h>
 #include <libarch/barrier.h>
@@ -217,5 +217,5 @@
  *  @param address  The place to store the address
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 inline static void rtl8139_hw_get_addr(rtl8139_t *rtl8139,
@@ -435,5 +435,5 @@
 	memory_barrier();
 	while(pio_read_8(io_base + CR) & CR_RST) {
-		thread_usleep(1);
+		async_usleep(1);
 		read_barrier();
 	}
@@ -816,11 +816,9 @@
 /** Handle device interrupt
  *
- * @param iid    The IPC call id
  * @param icall  The IPC call structure
  * @param dev    The rtl8139 device
  *
  */
-static void rtl8139_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
-    ddf_dev_t *dev)
+static void rtl8139_interrupt_handler(ipc_call_t *icall, ddf_dev_t *dev)
 {
 	assert(dev);
@@ -844,8 +842,9 @@
  *  @param nic_data  The driver data
  *
- *  @return IRQ capability handle if the handler was registered.
- *  @return Negative error code otherwise.
- */
-inline static int rtl8139_register_int_handler(nic_t *nic_data)
+ *  @param[out] handle  IRQ capability handle if the handler was registered.
+ *
+ *  @return An error code otherwise.
+ */
+inline static int rtl8139_register_int_handler(nic_t *nic_data, cap_handle_t *handle)
 {
 	rtl8139_t *rtl8139 = nic_get_specific(nic_data);
@@ -858,10 +857,10 @@
 	rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR;
 	rtl8139_irq_code.cmds[3].addr = rtl8139->io_addr + IMR;
-	int cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
-	    rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code);
+	int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
+	    rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code, handle);
 
 	RTL8139_IRQ_STRUCT_UNLOCK();
 
-	return cap;
+	return rc;
 }
 
@@ -1026,5 +1025,5 @@
  *  @param hw_resources  Devices hardware resources
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 static int rtl8139_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t
@@ -1066,5 +1065,5 @@
  *  @param dev  The device structure
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 static int rtl8139_get_resource_info(ddf_dev_t *dev)
@@ -1148,5 +1147,5 @@
  *  @param dev  The device information
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 static int rtl8139_device_initialize(ddf_dev_t *dev)
@@ -1207,5 +1206,5 @@
  * @param dev  The RTL8139 device.
  *
- * @return EOK if successed, negative error code otherwise
+ * @return EOK if successed, error code otherwise
  */
 static int rtl8139_pio_enable(ddf_dev_t *dev)
@@ -1257,5 +1256,5 @@
  * @param dev  The RTL8139 device.
  *
- * @return EOK if added successfully, negative error code otherwise
+ * @return EOK if added successfully, error code otherwise
  */
 int rtl8139_dev_add(ddf_dev_t *dev)
@@ -1289,7 +1288,7 @@
 
 	/* Register interrupt handler */
-	int irq_cap = rtl8139_register_int_handler(nic_data);
-	if (irq_cap < 0) {
-		rc = irq_cap;
+	int irq_cap;
+	rc = rtl8139_register_int_handler(nic_data, &irq_cap);
+	if (rc != EOK) {
 		goto err_pio;
 	}
@@ -1340,5 +1339,5 @@
  *  @param max_len  Maximal addresss length to store
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 static int rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
Index: uspace/drv/nic/rtl8139/general.c
===================================================================
--- uspace/drv/nic/rtl8139/general.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/rtl8139/general.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -81,5 +81,5 @@
  *  @param time        The requested time
  *
- *  @return EOK if succeed, negative error code otherwise
+ *  @return EOK if succeed, error code otherwise
  */
 int rtl8139_timer_act_init(rtl8139_timer_act_t * ta, uint32_t timer_freq,
Index: uspace/drv/nic/rtl8169/driver.c
===================================================================
--- uspace/drv/nic/rtl8169/driver.c	(revision b3c396907c3dfb9b7afd227215a7bd6a7416d6dd)
+++ uspace/drv/nic/rtl8169/driver.c	(revision 132ab5d1e75253f9bae910b2748a4c13efe7e71f)
@@ -28,5 +28,7 @@
 
 #include <assert.h>
+#include <async.h>
 #include <errno.h>
+#include <str_error.h>
 #include <align.h>
 #include <byteorder.h>
@@ -34,5 +36,4 @@
 
 #include <as.h>
-#include <thread.h>
 #include <ddf/log.h>
 #include <ddf/interrupt.h>
@@ -42,7 +43,4 @@
 #include <nic.h>
 #include <pci_dev_iface.h>
-
-#include <sysinfo.h>
-#include <ipc/ns.h>
 
 #include <str.h>
@@ -75,7 +73,6 @@
 static int rtl8169_on_stopped(nic_t *nic_data);
 static void rtl8169_send_frame(nic_t *nic_data, void *data, size_t size);
-static void rtl8169_irq_handler(ipc_callid_t iid, ipc_call_t *icall,
-    ddf_dev_t *dev);
-static inline int rtl8169_register_int_handler(nic_t *nic_data);
+static void rtl8169_irq_handler(ipc_call_t *icall, ddf_dev_t *dev);
+static inline int rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle);
 static inline void rtl8169_get_hwaddr(rtl8169_t *rtl8169, nic_address_t *addr);
 static inline void rtl8169_set_hwaddr(rtl8169_t *rtl8169, const nic_address_t *addr);
@@ -363,5 +360,5 @@
 }
 
-inline static int rtl8169_register_int_handler(nic_t *nic_data)
+inline static int rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle)
 {
 	rtl8169_t *rtl8169 = nic_get_specific(nic_data);
@@ -371,8 +368,8 @@
 	rtl8169_irq_code.cmds[2].addr = rtl8169->regs + ISR;
 	rtl8169_irq_code.cmds[3].addr = rtl8169->regs + IMR;
-	int irq_cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
-	    rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code);
-
-	return irq_cap;
+	int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
+	    rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code, handle);
+
+	return rc;
 }
 
@@ -431,8 +428,8 @@
 		goto err_pio;
 
-	int irq_cap = rtl8169_register_int_handler(nic_data);
-	if (irq_cap < 0) {
-		rc = irq_cap;
-		ddf_msg(LVL_ERROR, "Failed to register IRQ handler (%d)", rc);
+	int irq_cap;
+	rc = rtl8169_register_int_handler(nic_data, &irq_cap);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed to register IRQ handler (%s)", str_error_name(rc));
 		goto err_irq;
 	}
@@ -710,5 +707,5 @@
 	rc = rtl8169_allocate_buffers(rtl8169);
 	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Error allocating buffers: %d", rc);
+		ddf_msg(LVL_ERROR, "Error allocating buffers: %s", str_error_name(rc));
 		return 0;
 	}
@@ -767,5 +764,5 @@
 	memory_barrier();
 	while (pio_read_8(rtl8169->regs + CR) & CR_RST) {
-		thread_usleep(1);
+		async_usleep(1);
 		read_barrier();
 	}
@@ -1035,6 +1032,5 @@
 }
 
-static void rtl8169_irq_handler(ipc_callid_t iid, ipc_call_t *icall,
-    ddf_dev_t *dev)
+static void rtl8169_irq_handler(ipc_call_t *icall, ddf_dev_t *dev)
 {
 	assert(dev);
@@ -1181,5 +1177,5 @@
 	do {
 		phyar = pio_read_32(rtl8169->regs + PHYAR);
-		thread_usleep(20);
+		async_usleep(20);
 	} while ((phyar & PHYAR_RW_WRITE) == 0);
 
@@ -1199,8 +1195,8 @@
 	do {
 		phyar = pio_read_32(rtl8169->regs + PHYAR);
-		thread_usleep(20);
+		async_usleep(20);
 	} while ((phyar & PHYAR_RW_WRITE) != 0);
 
-	thread_usleep(20);
+	async_usleep(20);
 }
 
