Index: uspace/lib/drv/generic/dev_iface.c
===================================================================
--- uspace/lib/drv/generic/dev_iface.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/dev_iface.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -42,5 +42,4 @@
 #include "remote_hw_res.h"
 #include "remote_pio_window.h"
-#include "remote_char_dev.h"
 #include "remote_clock_dev.h"
 #include "remote_led_dev.h"
@@ -63,5 +62,4 @@
 		[HW_RES_DEV_IFACE] = &remote_hw_res_iface,
 		[PIO_WINDOW_DEV_IFACE] = &remote_pio_window_iface,
-		[CHAR_DEV_IFACE] = &remote_char_dev_iface,
 		[NIC_DEV_IFACE] = &remote_nic_iface,
 		[IEEE80211_DEV_IFACE] = &remote_ieee80211_iface,
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/driver.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -124,5 +124,5 @@
 	
 	char *dev_name = NULL;
-	int rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
+	errno_t rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
 	if (rc != EOK) {
 		async_answer_0(iid, rc);
@@ -157,5 +157,5 @@
 	(void) parent_fun_handle;
 	
-	int res = driver->driver_ops->dev_add(dev);
+	errno_t res = driver->driver_ops->dev_add(dev);
 	
 	if (res != EOK) {
@@ -189,5 +189,5 @@
 	}
 	
-	int rc;
+	errno_t rc;
 	
 	if (driver->driver_ops->dev_remove != NULL)
@@ -204,5 +204,5 @@
 	
 	dev_del_ref(dev);
-	async_answer_0(iid, (sysarg_t) rc);
+	async_answer_0(iid, rc);
 }
 
@@ -222,5 +222,5 @@
 	}
 	
-	int rc;
+	errno_t rc;
 	
 	if (driver->driver_ops->dev_gone != NULL)
@@ -237,5 +237,5 @@
 	
 	dev_del_ref(dev);
-	async_answer_0(iid, (sysarg_t) rc);
+	async_answer_0(iid, rc);
 }
 
@@ -263,5 +263,5 @@
 	
 	/* Call driver entry point */
-	int rc;
+	errno_t rc;
 	
 	if (driver->driver_ops->fun_online != NULL)
@@ -272,5 +272,5 @@
 	fun_del_ref(fun);
 	
-	async_answer_0(iid, (sysarg_t) rc);
+	async_answer_0(iid, rc);
 }
 
@@ -298,5 +298,5 @@
 	
 	/* Call driver entry point */
-	int rc;
+	errno_t rc;
 	
 	if (driver->driver_ops->fun_offline != NULL)
@@ -305,5 +305,5 @@
 		rc = ENOTSUP;
 	
-	async_answer_0(iid, (sysarg_t) rc);
+	async_answer_0(iid, rc);
 }
 
@@ -414,5 +414,5 @@
 	 */
 	
-	int ret = EOK;
+	errno_t ret = EOK;
 	/* Open device function */
 	if (fun->ops != NULL && fun->ops->open != NULL)
@@ -676,5 +676,5 @@
  * @return	EOK on success, ENOMEM if out of memory
  */
-int ddf_fun_set_name(ddf_fun_t *dev, const char *name)
+errno_t ddf_fun_set_name(ddf_fun_t *dev, const char *name)
 {
 	assert(dev->name == NULL);
@@ -822,8 +822,8 @@
  * @param fun Function to bind
  *
- * @return EOK on success or negative error code
- *
- */
-int ddf_fun_bind(ddf_fun_t *fun)
+ * @return EOK on success or an error code
+ *
+ */
+errno_t ddf_fun_bind(ddf_fun_t *fun)
 {
 	assert(fun->bound == false);
@@ -832,5 +832,5 @@
 	
 	add_to_functions_list(fun);
-	int res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
+	errno_t res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
 	    fun->dev->handle, &fun->handle);
 	if (res != EOK) {
@@ -850,12 +850,12 @@
  * @param fun Function to unbind
  *
- * @return EOK on success or negative error code
- *
- */
-int ddf_fun_unbind(ddf_fun_t *fun)
+ * @return EOK on success or an error code
+ *
+ */
+errno_t ddf_fun_unbind(ddf_fun_t *fun)
 {
 	assert(fun->bound == true);
 	
-	int res = devman_remove_function(fun->handle);
+	errno_t res = devman_remove_function(fun->handle);
 	if (res != EOK)
 		return res;
@@ -871,12 +871,12 @@
  * @param fun Function to online
  *
- * @return EOK on success or negative error code
- *
- */
-int ddf_fun_online(ddf_fun_t *fun)
+ * @return EOK on success or an error code
+ *
+ */
+errno_t ddf_fun_online(ddf_fun_t *fun)
 {
 	assert(fun->bound == true);
 	
-	int res = devman_drv_fun_online(fun->handle);
+	errno_t res = devman_drv_fun_online(fun->handle);
 	if (res != EOK)
 		return res;
@@ -889,12 +889,12 @@
  * @param fun Function to offline
  *
- * @return EOK on success or negative error code
- *
- */
-int ddf_fun_offline(ddf_fun_t *fun)
+ * @return EOK on success or an error code
+ *
+ */
+errno_t ddf_fun_offline(ddf_fun_t *fun)
 {
 	assert(fun->bound == true);
 	
-	int res = devman_drv_fun_offline(fun->handle);
+	errno_t res = devman_drv_fun_offline(fun->handle);
 	if (res != EOK)
 		return res;
@@ -916,5 +916,5 @@
  *
  */
-int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
+errno_t ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
     int match_score)
 {
@@ -963,5 +963,5 @@
  *
  */
-int ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name)
+errno_t ddf_fun_add_to_category(ddf_fun_t *fun, const char *cat_name)
 {
 	assert(fun->bound == true);
@@ -984,5 +984,5 @@
 	 */
 	port_id_t port;
-	int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
+	errno_t rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
 	    NULL, &port);
 	if (rc != EOK) {
Index: uspace/lib/drv/generic/interrupt.c
===================================================================
--- uspace/lib/drv/generic/interrupt.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/interrupt.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -43,12 +43,13 @@
 #include "private/driver.h"
 
-int register_interrupt_handler(ddf_dev_t *dev, int irq,
-    interrupt_handler_t *handler, const irq_code_t *irq_code)
+errno_t register_interrupt_handler(ddf_dev_t *dev, int irq,
+    interrupt_handler_t *handler, const irq_code_t *irq_code,
+    cap_handle_t *handle)
 {
 	return async_irq_subscribe(irq, (async_notification_handler_t) handler,
-	    dev, irq_code);
+	    dev, irq_code, handle);
 }
 
-int unregister_interrupt_handler(ddf_dev_t *dev, int cap)
+errno_t unregister_interrupt_handler(ddf_dev_t *dev, cap_handle_t cap)
 {
 	return async_irq_unsubscribe(cap);
Index: uspace/lib/drv/generic/log.c
===================================================================
--- uspace/lib/drv/generic/log.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/log.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -40,5 +40,5 @@
  *
  */
-int ddf_log_init(const char *drv_name)
+errno_t ddf_log_init(const char *drv_name)
 {
 	return log_init(drv_name);
Index: uspace/lib/drv/generic/logbuf.c
===================================================================
--- uspace/lib/drv/generic/logbuf.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/logbuf.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -35,4 +35,5 @@
 #include <ddf/log.h>
 #include <assert.h>
+#include <str.h>
 
 /** Formatting string for printing number of not-printed items. */
Index: uspace/lib/drv/generic/private/driver.h
===================================================================
--- uspace/lib/drv/generic/private/driver.h	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/private/driver.h	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -57,5 +57,5 @@
 	
 	/** Device name */
-	const char *name;
+	char *name;
 	
 	/** Driver-specific data associated with this device */
@@ -84,5 +84,5 @@
 	
 	/** Function name */
-	const char *name;
+	char *name;
 	
 	/** List of device ids for driver matching */
Index: uspace/lib/drv/generic/private/remote_char_dev.h
===================================================================
--- uspace/lib/drv/generic/private/remote_char_dev.h	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2010 Lenka Trochtova
- * 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 libdrv
- * @{
- */
-/** @file
- */
-
-#ifndef LIBDRV_REMOTE_CHAR_DEV_H_
-#define LIBDRV_REMOTE_CHAR_DEV_H_
-
-extern remote_iface_t remote_char_dev_iface;
-
-#endif
-
-/**
- * @}
- */
Index: uspace/lib/drv/generic/remote_ahci.c
===================================================================
--- uspace/lib/drv/generic/remote_ahci.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_ahci.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -39,4 +39,5 @@
 #include <stdio.h>
 #include <macros.h>
+#include <str.h>
 #include "ahci_iface.h"
 #include "ddf/driver.h"
@@ -65,5 +66,5 @@
 	
 	char devn[MAX_NAME_LENGTH];
-	int rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH);
+	errno_t rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH);
 	if (rc != EOK)
 		return NULL;
@@ -83,5 +84,5 @@
 }
 
-int ahci_get_sata_device_name(async_sess_t *sess, size_t sata_dev_name_length,
+errno_t ahci_get_sata_device_name(async_sess_t *sess, size_t sata_dev_name_length,
     char *sata_dev_name)
 {
@@ -95,5 +96,5 @@
 	async_data_read_start(exch, sata_dev_name, sata_dev_name_length);
 	
-	sysarg_t rc;
+	errno_t rc;
 	async_wait_for(req, &rc);
 	
@@ -101,5 +102,5 @@
 }
 
-int ahci_get_num_blocks(async_sess_t *sess, uint64_t *blocks)
+errno_t ahci_get_num_blocks(async_sess_t *sess, uint64_t *blocks)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
@@ -109,5 +110,5 @@
 	sysarg_t blocks_hi;
 	sysarg_t blocks_lo;
-	int rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
+	errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
 	    IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo);
 	
@@ -122,5 +123,5 @@
 }
 
-int ahci_get_block_size(async_sess_t *sess, size_t *blocks_size)
+errno_t ahci_get_block_size(async_sess_t *sess, size_t *blocks_size)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
@@ -129,5 +130,5 @@
 	
 	sysarg_t bs;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
 	    IPC_M_AHCI_GET_BLOCK_SIZE, &bs);
 	
@@ -140,5 +141,5 @@
 }
 
-int ahci_read_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
+errno_t ahci_read_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
     void *buf)
 {
@@ -155,5 +156,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t rc;
+	errno_t rc;
 	async_wait_for(req, &rc);
 	
@@ -161,5 +162,5 @@
 }
 
-int ahci_write_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
+errno_t ahci_write_blocks(async_sess_t *sess, uint64_t blocknum, size_t count,
     void* buf)
 {
@@ -175,5 +176,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t rc;
+	errno_t rc;
 	async_wait_for(req, &rc);
 	
@@ -227,5 +228,5 @@
 	}	
 	
-	const int ret = ahci_iface->get_sata_device_name(fun,
+	const errno_t ret = ahci_iface->get_sata_device_name(fun,
 	    sata_dev_name_length, sata_dev_name);
 	
@@ -251,5 +252,5 @@
 	
 	uint64_t blocks;
-	const int ret = ahci_iface->get_num_blocks(fun, &blocks);
+	const errno_t ret = ahci_iface->get_num_blocks(fun, &blocks);
 	
 	if (ret != EOK)
@@ -270,5 +271,5 @@
 	
 	size_t blocks;
-	const int ret = ahci_iface->get_block_size(fun, &blocks);
+	const errno_t ret = ahci_iface->get_block_size(fun, &blocks);
 	
 	if (ret != EOK)
@@ -302,5 +303,5 @@
 	const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call);
 	
-	const int ret = ahci_iface->read_blocks(fun, blocknum, cnt, buf);
+	const errno_t ret = ahci_iface->read_blocks(fun, blocknum, cnt, buf);
 	
 	async_answer_0(callid, ret);
@@ -331,5 +332,5 @@
 	const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call);
 	
-	const int ret = ahci_iface->write_blocks(fun, blocknum, cnt, buf);
+	const errno_t ret = ahci_iface->write_blocks(fun, blocknum, cnt, buf);
 	
 	async_answer_0(callid, ret);
Index: uspace/lib/drv/generic/remote_audio_mixer.c
===================================================================
--- uspace/lib/drv/generic/remote_audio_mixer.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_audio_mixer.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -94,10 +94,10 @@
  * @return Error code.
  */
-int audio_mixer_get_info(async_exch_t *exch, const char **name, unsigned *items)
+errno_t audio_mixer_get_info(async_exch_t *exch, char **name, unsigned *items)
 {
 	if (!exch)
 		return EINVAL;
 	sysarg_t name_size, itemc;
-	const int ret = async_req_1_2(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
+	const errno_t ret = async_req_1_2(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
 	    IPC_M_AUDIO_MIXER_GET_INFO, &name_size, &itemc);
 	if (ret == EOK && name) {
@@ -109,5 +109,5 @@
 			return ENOMEM;
 		}
-		const int ret =
+		const errno_t ret =
 		    async_data_read_start(exch, name_place, name_size);
 		if (ret != EOK) {
@@ -130,11 +130,11 @@
  * @return Error code.
  */
-int audio_mixer_get_item_info(async_exch_t *exch, unsigned item,
-    const char **name, unsigned *levels)
+errno_t audio_mixer_get_item_info(async_exch_t *exch, unsigned item,
+    char **name, unsigned *levels)
 {
 	if (!exch)
 		return EINVAL;
 	sysarg_t name_size, lvls;
-	const int ret = async_req_2_2(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
+	const errno_t ret = async_req_2_2(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
 	    IPC_M_AUDIO_MIXER_GET_ITEM_INFO, item, &name_size, &lvls);
 	if (ret == EOK && name) {
@@ -146,5 +146,5 @@
 			return ENOMEM;
 		}
-		const int ret =
+		const errno_t ret =
 		    async_data_read_start(exch, name_place, name_size);
 		if (ret != EOK) {
@@ -166,5 +166,5 @@
  * @return Error code.
  */
-int audio_mixer_set_item_level(async_exch_t *exch, unsigned item,
+errno_t audio_mixer_set_item_level(async_exch_t *exch, unsigned item,
     unsigned level)
 {
@@ -183,5 +183,5 @@
  * @return Error code.
  */
-int audio_mixer_get_item_level(async_exch_t *exch, unsigned item,
+errno_t audio_mixer_get_item_level(async_exch_t *exch, unsigned item,
     unsigned *level)
 {
@@ -189,5 +189,5 @@
 		return EINVAL;
 	sysarg_t current;
-	const int ret = async_req_2_1(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
+	const errno_t ret = async_req_2_1(exch, DEV_IFACE_ID(AUDIO_MIXER_IFACE),
 	    IPC_M_AUDIO_MIXER_GET_ITEM_LEVEL, item, &current);
 	if (ret == EOK && level)
@@ -229,5 +229,5 @@
 	const char *name = NULL;
 	unsigned items = 0;
-	const int ret = mixer_iface->get_info(fun, &name, &items);
+	const errno_t ret = mixer_iface->get_info(fun, &name, &items);
 	const size_t name_size = name ? str_size(name) + 1 : 0;
 	async_answer_2(callid, ret, name_size, items);
@@ -261,5 +261,5 @@
 	const char *name = NULL;
 	unsigned values = 0;
-	const int ret = mixer_iface->get_item_info(fun, item, &name, &values);
+	const errno_t ret = mixer_iface->get_item_info(fun, item, &name, &values);
 	const size_t name_size = name ? str_size(name) + 1 : 0;
 	async_answer_2(callid, ret, name_size, values);
@@ -291,5 +291,5 @@
 	const unsigned item = DEV_IPC_GET_ARG1(*call);
 	const unsigned value = DEV_IPC_GET_ARG2(*call);
-	const int ret = mixer_iface->set_item_level(fun, item, value);
+	const errno_t ret = mixer_iface->set_item_level(fun, item, value);
 	async_answer_0(callid, ret);
 }
@@ -306,5 +306,5 @@
 	const unsigned item = DEV_IPC_GET_ARG1(*call);
 	unsigned current = 0;
-	const int ret =
+	const errno_t ret =
 	    mixer_iface->get_item_level(fun, item, &current);
 	async_answer_1(callid, ret, current);
Index: uspace/lib/drv/generic/remote_audio_pcm.c
===================================================================
--- uspace/lib/drv/generic/remote_audio_pcm.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_audio_pcm.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -114,5 +114,5 @@
 	static category_id_t pcm_id = 0;
 	if (!resolved) {
-		const int ret = loc_category_get_id("audio-pcm", &pcm_id,
+		const errno_t ret = loc_category_get_id("audio-pcm", &pcm_id,
 		    IPC_FLAG_BLOCKING);
 		if (ret != EOK)
@@ -123,5 +123,5 @@
 	service_id_t *svcs = NULL;
 	size_t count = 0;
-	const int ret = loc_category_get_svcs(pcm_id, &svcs, &count);
+	const errno_t ret = loc_category_get_svcs(pcm_id, &svcs, &count);
 	if (ret != EOK)
 		return NULL;
@@ -143,5 +143,5 @@
 {
 	devman_handle_t device_handle = 0;
-	const int ret = devman_fun_get_handle(name, &device_handle, 0);
+	const errno_t ret = devman_fun_get_handle(name, &device_handle, 0);
 	if (ret != EOK)
 		return NULL;
@@ -184,5 +184,5 @@
  * @note Caller is responsible for freeing newly allocated memory.
  */
-int audio_pcm_get_info_str(audio_pcm_sess_t *sess, const char **name)
+errno_t audio_pcm_get_info_str(audio_pcm_sess_t *sess, char **name)
 {
 	if (!name)
@@ -190,5 +190,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 	sysarg_t name_size;
-	const int ret = async_req_1_1(exch,
+	const errno_t ret = async_req_1_1(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_GET_INFO_STR, &name_size);
@@ -202,5 +202,5 @@
 			return ENOMEM;
 		}
-		const int ret =
+		const errno_t ret =
 		    async_data_read_start(exch, name_place, name_size);
 		if (ret != EOK) {
@@ -221,18 +221,15 @@
  * @param sess Audio device session.
  * @param cap  Audio device capability.
- * @param val  Place to store queried value.
- *
- * @return Error code.
- */
-int audio_pcm_query_cap(audio_pcm_sess_t *sess, audio_cap_t cap)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	sysarg_t value = 0;
-	const int ret = async_req_2_1(exch,
+ * @param[out] val  Place to store queried value.
+ *
+ * @return Error code.
+ */
+errno_t audio_pcm_query_cap(audio_pcm_sess_t *sess, audio_cap_t cap, sysarg_t *value)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_1(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_QUERY_CAPS,
-	    cap, &value);
-	async_exchange_end(exch);
-	if (ret == EOK)
-		return value;
+	    cap, value);
+	async_exchange_end(exch);
 	return ret;
 }
@@ -248,5 +245,5 @@
  * Works for both playback and capture.
  */
-int audio_pcm_get_buffer_pos(audio_pcm_sess_t *sess, size_t *pos)
+errno_t audio_pcm_get_buffer_pos(audio_pcm_sess_t *sess, size_t *pos)
 {
 	if (!pos)
@@ -254,5 +251,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 	sysarg_t value = 0;
-	const int ret = async_req_1_1(exch,
+	const errno_t ret = async_req_1_1(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_GET_BUFFER_POS, &value);
@@ -276,5 +273,5 @@
  * parameters to the nearest values supported by the device.
  */
-int audio_pcm_test_format(audio_pcm_sess_t *sess, unsigned *channels,
+errno_t audio_pcm_test_format(audio_pcm_sess_t *sess, unsigned *channels,
     unsigned *rate, pcm_sample_format_t *format)
 {
@@ -283,5 +280,5 @@
 	sysarg_t rate_arg = rate ? *rate : 0;
 	sysarg_t format_arg = format ? *format : 0;
-	const int ret = async_req_4_3(exch,
+	const errno_t ret = async_req_4_3(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_TEST_FORMAT, channels_arg, rate_arg, format_arg,
@@ -314,5 +311,5 @@
  * @return Error code.
  */
-int audio_pcm_register_event_callback(audio_pcm_sess_t *sess,
+errno_t audio_pcm_register_event_callback(audio_pcm_sess_t *sess,
     async_port_handler_t event_callback, void *arg)
 {
@@ -322,5 +319,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 	
-	int ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
+	errno_t ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_REGISTER_EVENTS);
 	if (ret == EOK) {
@@ -341,8 +338,8 @@
  * @return Error code.
  */
-int audio_pcm_unregister_event_callback(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_1_0(exch,
+errno_t audio_pcm_unregister_event_callback(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_1_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_UNREGISTER_EVENTS);
@@ -360,5 +357,5 @@
  * @return Error code.
  */
-int audio_pcm_get_buffer(audio_pcm_sess_t *sess, void **buffer, size_t *size)
+errno_t audio_pcm_get_buffer(audio_pcm_sess_t *sess, void **buffer, size_t *size)
 {
 	if (!buffer || !size)
@@ -368,5 +365,5 @@
 
 	sysarg_t buffer_size = *size;
-	int ret = async_req_2_1(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
+	errno_t ret = async_req_2_1(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_GET_BUFFER, (sysarg_t)buffer_size, &buffer_size);
 	if (ret == EOK) {
@@ -391,8 +388,8 @@
  * @return Error code.
  */
-int audio_pcm_release_buffer(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_1_0(exch,
+errno_t audio_pcm_release_buffer(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_1_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_RELEASE_BUFFER);
@@ -415,5 +412,5 @@
  * 0 to turn off event generation.
  */
-int audio_pcm_start_playback_fragment(audio_pcm_sess_t *sess, unsigned frames,
+errno_t audio_pcm_start_playback_fragment(audio_pcm_sess_t *sess, unsigned frames,
     unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
 {
@@ -423,5 +420,5 @@
 	const sysarg_t packed = (channels << 16) | (format & UINT16_MAX);
 	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_4_0(exch,
+	const errno_t ret = async_req_4_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_START_PLAYBACK,
@@ -437,8 +434,8 @@
  * @return Error code.
  */
-int audio_pcm_last_playback_fragment(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_last_playback_fragment(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_PLAYBACK, false);
@@ -457,5 +454,5 @@
  * @return Error code.
  */
-int audio_pcm_start_playback(audio_pcm_sess_t *sess,
+errno_t audio_pcm_start_playback(audio_pcm_sess_t *sess,
     unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
 {
@@ -471,8 +468,8 @@
  * @return Error code.
  */
-int audio_pcm_stop_playback_immediate(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_stop_playback_immediate(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_PLAYBACK, true);
@@ -488,8 +485,8 @@
  * @return Error code.
  */
-int audio_pcm_stop_playback(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_stop_playback(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_PLAYBACK, false);
@@ -512,5 +509,5 @@
  * 0 to turn off event generation.
  */
-int audio_pcm_start_capture_fragment(audio_pcm_sess_t *sess, unsigned frames,
+errno_t audio_pcm_start_capture_fragment(audio_pcm_sess_t *sess, unsigned frames,
     unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
 {
@@ -520,5 +517,5 @@
 	const sysarg_t packed = (channels << 16) | (format & UINT16_MAX);
 	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_4_0(exch,
+	const errno_t ret = async_req_4_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_START_CAPTURE,
 	    frames, sample_rate, packed);
@@ -537,5 +534,5 @@
  * @return Error code.
  */
-int audio_pcm_start_capture(audio_pcm_sess_t *sess,
+errno_t audio_pcm_start_capture(audio_pcm_sess_t *sess,
     unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
 {
@@ -552,8 +549,8 @@
  * @return Error code.
  */
-int audio_pcm_last_capture_fragment(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_last_capture_fragment(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_CAPTURE, false);
@@ -569,8 +566,8 @@
  * @return Error code.
  */
-int audio_pcm_stop_capture_immediate(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_stop_capture_immediate(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_CAPTURE, true);
@@ -586,8 +583,8 @@
  * @return Error code.
  */
-int audio_pcm_stop_capture(audio_pcm_sess_t *sess)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	const int ret = async_req_2_0(exch,
+errno_t audio_pcm_stop_capture(audio_pcm_sess_t *sess)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	const errno_t ret = async_req_2_0(exch,
 	    DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
 	    IPC_M_AUDIO_PCM_STOP_CAPTURE, false);
@@ -644,5 +641,5 @@
 	}
 	const char *name = NULL;
-	const int ret = pcm_iface->get_info_str(fun, &name);
+	const errno_t ret = pcm_iface->get_info_str(fun, &name);
 	const size_t name_size = name ? str_size(name) + 1 : 0;
 	async_answer_1(callid, ret, name_size);
@@ -695,5 +692,5 @@
 		return;
 	}
-	const int ret = pcm_iface->set_event_session(fun, sess);
+	const errno_t ret = pcm_iface->set_event_session(fun, sess);
 	if (ret != EOK) {
 		ddf_msg(LVL_DEBUG, "Failed to set event callback.");
@@ -725,5 +722,5 @@
 	const audio_pcm_iface_t *pcm_iface = iface;
 	size_t pos = 0;
-	const int ret = pcm_iface->get_buffer_pos ?
+	const errno_t ret = pcm_iface->get_buffer_pos ?
 	    pcm_iface->get_buffer_pos(fun, &pos) : ENOTSUP;
 	async_answer_1(callid, ret, pos);
@@ -736,5 +733,5 @@
 	unsigned rate = DEV_IPC_GET_ARG2(*call);
 	pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call);
-	const int ret = pcm_iface->test_format ?
+	const errno_t ret = pcm_iface->test_format ?
 	    pcm_iface->test_format(fun, &channels, &rate, &format) : ENOTSUP;
 	async_answer_3(callid, ret, channels, rate, format);
@@ -753,5 +750,5 @@
 	void *buffer = NULL;
 	size_t size = DEV_IPC_GET_ARG1(*call);
-	int ret = pcm_iface->get_buffer(fun, &buffer, &size);
+	errno_t ret = pcm_iface->get_buffer(fun, &buffer, &size);
 	async_answer_1(callid, ret, size);
 	if (ret != EOK || size == 0)
@@ -795,5 +792,5 @@
 	const audio_pcm_iface_t *pcm_iface = iface;
 
-	const int ret = pcm_iface->release_buffer ?
+	const errno_t ret = pcm_iface->release_buffer ?
 	    pcm_iface->release_buffer(fun) : ENOTSUP;
 	async_answer_0(callid, ret);
@@ -810,5 +807,5 @@
 	const pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call) & UINT16_MAX;
 
-	const int ret = pcm_iface->start_playback
+	const errno_t ret = pcm_iface->start_playback
 	    ? pcm_iface->start_playback(fun, frames, channels, rate, format)
 	    : ENOTSUP;
@@ -822,5 +819,5 @@
 	const bool immediate = DEV_IPC_GET_ARG1(*call);
 
-	const int ret = pcm_iface->stop_playback ?
+	const errno_t ret = pcm_iface->stop_playback ?
 	    pcm_iface->stop_playback(fun, immediate) : ENOTSUP;
 	async_answer_0(callid, ret);
@@ -837,5 +834,5 @@
 	const pcm_sample_format_t format = DEV_IPC_GET_ARG3(*call) & UINT16_MAX;
 
-	const int ret = pcm_iface->start_capture
+	const errno_t ret = pcm_iface->start_capture
 	    ? pcm_iface->start_capture(fun, frames, channels, rate, format)
 	    : ENOTSUP;
@@ -849,5 +846,5 @@
 	const bool immediate = DEV_IPC_GET_ARG1(*call);
 
-	const int ret = pcm_iface->stop_capture ?
+	const errno_t ret = pcm_iface->stop_capture ?
 	    pcm_iface->stop_capture(fun, immediate) : ENOTSUP;
 	async_answer_0(callid, ret);
Index: uspace/lib/drv/generic/remote_battery_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_battery_dev.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_battery_dev.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -45,7 +45,7 @@
  * @param status   Current status of the battery
  *
- * @return         EOK on success or a negative error code
+ * @return         EOK on success or an error code
  */
-int
+errno_t
 battery_status_get(async_sess_t *sess, battery_status_t *batt_status)
 {
@@ -54,5 +54,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 
-	int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
+	errno_t const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
 	    BATTERY_STATUS_GET, &status);
 
@@ -70,7 +70,7 @@
  * @param level    Battery charge level (0 - 100)
  *
- * @return         EOK on success or a negative error code
+ * @return         EOK on success or an error code
  */
-int
+errno_t
 battery_charge_level_get(async_sess_t *sess, int *level)
 {
@@ -79,5 +79,5 @@
 	async_exch_t *exch = async_exchange_begin(sess);
 
-	int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
+	errno_t const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
 	    BATTERY_CHARGE_LEVEL_GET, &charge_level);
 
@@ -129,5 +129,5 @@
 
 	battery_status_t batt_status;
-	const int rc = bops->battery_status_get(fun, &batt_status);
+	const errno_t rc = bops->battery_status_get(fun, &batt_status);
 
 	if (rc != EOK)
@@ -155,5 +155,5 @@
 
 	int battery_level;
-	const int rc = bops->battery_charge_level_get(fun, &battery_level);
+	const errno_t rc = bops->battery_charge_level_get(fun, &battery_level);
 
 	if (rc != EOK)
Index: uspace/lib/drv/generic/remote_char_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_char_dev.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ 	(revision )
@@ -1,246 +1,0 @@
-/*
- * Copyright (c) 2010 Lenka Trochtova
- * 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 libdrv
- * @{
- */
-/** @file
- */
-
-#include <async.h>
-#include <errno.h>
-#include <macros.h>
-
-#include "ops/char_dev.h"
-#include "char_dev_iface.h"
-#include "ddf/driver.h"
-
-#define MAX_CHAR_RW_COUNT 256
-
-/** Read to or write from device.
- *
- * Helper function to read to or write from a device
- * using its character interface.
- *
- * @param sess Session to the device.
- * @param buf  Buffer for the data read from or written to the device.
- * @param size Maximum size of data (in bytes) to be read or written.
- * @param read Read from the device if true, write to it otherwise.
- *
- * @return Non-negative number of bytes actually read from or
- *         written to the device on success, negative error number
- *         otherwise.
- *
- */
-static ssize_t char_dev_rw(async_sess_t *sess, void *buf, size_t size, bool read)
-{
-	ipc_call_t answer;
-	aid_t req;
-	int ret;
-	
-	async_exch_t *exch = async_exchange_begin(sess);
-	
-	if (read) {
-		req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE),
-		    CHAR_DEV_READ, &answer);
-		ret = async_data_read_start(exch, buf, size);
-	} else {
-		req = async_send_1(exch, DEV_IFACE_ID(CHAR_DEV_IFACE),
-		    CHAR_DEV_WRITE, &answer);
-		ret = async_data_write_start(exch, buf, size);
-	}
-	
-	async_exchange_end(exch);
-	
-	sysarg_t rc;
-	if (ret != EOK) {
-		async_wait_for(req, &rc);
-		if (rc == EOK)
-			return (ssize_t) ret;
-		
-		return (ssize_t) rc;
-	}
-	
-	async_wait_for(req, &rc);
-	
-	ret = (int) rc;
-	if (ret != EOK)
-		return (ssize_t) ret;
-	
-	return (ssize_t) IPC_GET_ARG1(answer);
-}
-
-/** Read from character device.
- *
- * @param sess Session to the device.
- * @param buf  Output buffer for the data read from the device.
- * @param size Maximum size (in bytes) of the data to be read.
- *
- * @return Non-negative number of bytes actually read from the
- *         device on success, negative error number otherwise.
- *
- */
-ssize_t char_dev_read(async_sess_t *sess, void *buf, size_t size)
-{
-	return char_dev_rw(sess, buf, size, true);
-}
-
-/** Write to character device.
- *
- * @param sess Session to the device.
- * @param buf  Input buffer containg the data to be written to the
- *             device.
- * @param size Maximum size (in bytes) of the data to be written.
- *
- * @return Non-negative number of bytes actually written to the
- *         device on success, negative error number otherwise.
- *
- */
-ssize_t char_dev_write(async_sess_t *sess, void *buf, size_t size)
-{
-	return char_dev_rw(sess, buf, size, false);
-}
-
-static void remote_char_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_char_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
-
-/** Remote character interface operations. */
-static const remote_iface_func_ptr_t remote_char_dev_iface_ops[] = {
-	[CHAR_DEV_READ] = remote_char_read,
-	[CHAR_DEV_WRITE] = remote_char_write
-};
-
-/** Remote character interface structure.
- *
- * Interface for processing request from remote clients addressed to the
- * character interface.
- */
-const remote_iface_t remote_char_dev_iface = {
-	.method_count = ARRAY_SIZE(remote_char_dev_iface_ops),
-	.methods = remote_char_dev_iface_ops
-};
-
-/** Process the read request from the remote client.
- *
- * Receive the read request's parameters from the remote client and pass them
- * to the local interface. Return the result of the operation processed by the
- * local interface to the remote client.
- *
- * @param fun		The function from which the data are read.
- * @param ops		The local ops structure.
- */
-static void
-remote_char_read(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
-    ipc_call_t *call)
-{
-	char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
-	ipc_callid_t cid;
-	
-	size_t len;
-	if (!async_data_read_receive(&cid, &len)) {
-		/* TODO handle protocol error. */
-		async_answer_0(callid, EINVAL);
-		return;
-	}
-	
-	if (!char_dev_ops->read) {
-		async_data_read_finalize(cid, NULL, 0);
-		async_answer_0(callid, ENOTSUP);
-		return;
-	}
-	
-	if (len > MAX_CHAR_RW_COUNT)
-		len = MAX_CHAR_RW_COUNT;
-	
-	char buf[MAX_CHAR_RW_COUNT];
-	int ret = (*char_dev_ops->read)(fun, buf, len);
-	
-	if (ret < 0) {
-		/* Some error occured. */
-		async_data_read_finalize(cid, buf, 0);
-		async_answer_0(callid, ret);
-		return;
-	}
-	
-	/* The operation was successful, return the number of data read. */
-	async_data_read_finalize(cid, buf, ret);
-	async_answer_1(callid, EOK, ret);
-}
-
-/** Process the write request from the remote client.
- *
- * Receive the write request's parameters from the remote client and pass them
- * to the local interface. Return the result of the operation processed by the
- * local interface to the remote client.
- *
- * @param fun		The function to which the data are written.
- * @param ops		The local ops structure.
- */
-static void
-remote_char_write(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
-    ipc_call_t *call)
-{
-	char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
-	ipc_callid_t cid;
-	size_t len;
-	
-	if (!async_data_write_receive(&cid, &len)) {
-		/* TODO handle protocol error. */
-		async_answer_0(callid, EINVAL);
-		return;
-	}
-	
-	if (!char_dev_ops->write) {
-		async_data_write_finalize(cid, NULL, 0);
-		async_answer_0(callid, ENOTSUP);
-		return;
-	}
-	
-	if (len > MAX_CHAR_RW_COUNT)
-		len = MAX_CHAR_RW_COUNT;
-	
-	char buf[MAX_CHAR_RW_COUNT];
-	
-	async_data_write_finalize(cid, buf, len);
-	
-	int ret = (*char_dev_ops->write)(fun, buf, len);
-	if (ret < 0) {
-		/* Some error occured. */
-		async_answer_0(callid, ret);
-	} else {
-		/*
-		 * The operation was successful, return the number of data
-		 * written.
-		 */
-		async_answer_1(callid, EOK, ret);
-	}
-}
-
-/**
- * @}
- */
Index: uspace/lib/drv/generic/remote_clock_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_clock_dev.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_clock_dev.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -75,5 +75,5 @@
 	ipc_callid_t cid;
 	struct tm t;
-	int rc;
+	errno_t rc;
 	size_t len;
 
@@ -114,5 +114,5 @@
 {
 	clock_dev_ops_t *clock_dev_ops = (clock_dev_ops_t *) ops;
-	int          rc;
+	errno_t      rc;
 	struct tm    t;
 	ipc_callid_t cid;
Index: uspace/lib/drv/generic/remote_hw_res.c
===================================================================
--- uspace/lib/drv/generic/remote_hw_res.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_hw_res.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -79,5 +79,5 @@
 	
 	const int irq = DEV_IPC_GET_ARG1(*call);
-	const int ret = hw_res_ops->enable_interrupt(fun, irq);
+	const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
 	async_answer_0(callid, ret);
 }
@@ -94,5 +94,5 @@
 	
 	const int irq = DEV_IPC_GET_ARG1(*call);
-	const int ret = hw_res_ops->disable_interrupt(fun, irq);
+	const errno_t ret = hw_res_ops->disable_interrupt(fun, irq);
 	async_answer_0(callid, ret);
 }
@@ -109,5 +109,5 @@
 	
 	const int irq = DEV_IPC_GET_ARG1(*call);
-	const int ret = hw_res_ops->enable_interrupt(fun, irq);
+	const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
 	async_answer_0(callid, ret);
 }
@@ -153,5 +153,5 @@
 	const uint32_t size = DEV_IPC_GET_ARG3(*call);
 
-	const int ret = hw_res_ops->dma_channel_setup(
+	const errno_t ret = hw_res_ops->dma_channel_setup(
 	    fun, channel, address, size, mode);
 	async_answer_0(callid, ret);
@@ -169,5 +169,5 @@
 	const unsigned channel = DEV_IPC_GET_ARG1(*call);
 	size_t remain = 0;
-	const int ret = hw_res_ops->dma_channel_remain(fun, channel, &remain);
+	const errno_t ret = hw_res_ops->dma_channel_remain(fun, channel, &remain);
 	async_answer_1(callid, ret, remain);
 }
Index: uspace/lib/drv/generic/remote_ieee80211.c
===================================================================
--- uspace/lib/drv/generic/remote_ieee80211.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_ieee80211.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -59,8 +59,8 @@
  *
  * @return EOK If the operation was successfully completed,
- *         negative error code otherwise.
- *
- */
-int ieee80211_get_scan_results(async_sess_t *dev_sess,
+ *         error code otherwise.
+ *
+ */
+errno_t ieee80211_get_scan_results(async_sess_t *dev_sess,
     ieee80211_scan_results_t *results, bool now)
 {
@@ -71,13 +71,13 @@
 	aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
 	    IEEE80211_GET_SCAN_RESULTS, now, NULL);
-	int rc = async_data_read_start(exch, results,
+	errno_t rc = async_data_read_start(exch, results,
 	    sizeof(ieee80211_scan_results_t));
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(aid, &res);
 	
 	if(res != EOK)
-		return (int) res;
+		return (errno_t) res;
 	
 	return rc;
@@ -100,5 +100,5 @@
 	size_t count;
 	
-	int rc = inetcfg_get_link_list(&link_list, &count);
+	errno_t rc = inetcfg_get_link_list(&link_list, &count);
 	if (rc != EOK)
 		return -1;
@@ -123,12 +123,12 @@
  *
  * @return EOK If the operation was successfully completed,
- *         negative error code otherwise.
- *
- */
-int ieee80211_connect(async_sess_t *dev_sess, char *ssid_start, char *password)
+ *         error code otherwise.
+ *
+ */
+errno_t ieee80211_connect(async_sess_t *dev_sess, char *ssid_start, char *password)
 {
 	assert(ssid_start);
 	
-	sysarg_t rc_orig;
+	errno_t rc_orig;
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
@@ -137,5 +137,5 @@
 	    IEEE80211_CONNECT, NULL);
 	
-	sysarg_t rc = async_data_write_start(exch, ssid_start,
+	errno_t rc = async_data_write_start(exch, ssid_start,
 	    str_size(ssid_start) + 1);
 	if (rc != EOK) {
@@ -144,7 +144,7 @@
 		
 		if (rc_orig == EOK)
-			return (int) rc;
-		
-		return (int) rc_orig;
+			return (errno_t) rc;
+		
+		return (errno_t) rc_orig;
 	}
 	
@@ -159,7 +159,7 @@
 		
 		if (rc_orig == EOK)
-			return (int) rc;
-		
-		return (int) rc_orig;
+			return (errno_t) rc;
+		
+		return (errno_t) rc_orig;
 	}
 	
@@ -182,5 +182,5 @@
 	rc = dhcp_discover(link_id);
 	
-	return (int) rc;
+	return (errno_t) rc;
 }
 
@@ -190,11 +190,11 @@
  *
  * @return EOK If the operation was successfully completed,
- *         negative error code otherwise.
- *
- */
-int ieee80211_disconnect(async_sess_t *dev_sess)
+ *         error code otherwise.
+ *
+ */
+errno_t ieee80211_disconnect(async_sess_t *dev_sess)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
 	    IEEE80211_DISCONNECT);
 	async_exchange_end(exch);
@@ -278,5 +278,5 @@
 	bool now = IPC_GET_ARG2(*call);
 	
-	int rc = ieee80211_iface->get_scan_results(fun, &scan_results, now);
+	errno_t rc = ieee80211_iface->get_scan_results(fun, &scan_results, now);
 	if (rc == EOK) {
 		ipc_callid_t data_callid;
@@ -324,5 +324,5 @@
 	}
 	
-	int rc = async_data_write_finalize(data_callid, ssid_start, len);
+	errno_t rc = async_data_write_finalize(data_callid, ssid_start, len);
 	if (rc != EOK) {
 		async_answer_0(data_callid, EINVAL);
@@ -360,5 +360,5 @@
 	ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface;
 	assert(ieee80211_iface->disconnect);
-	int rc = ieee80211_iface->disconnect(fun);
+	errno_t rc = ieee80211_iface->disconnect(fun);
 	async_answer_0(callid, rc);
 }
Index: uspace/lib/drv/generic/remote_led_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_led_dev.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_led_dev.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -77,5 +77,5 @@
 	}
 	
-	int rc = (*led_dev_ops->color_set)(fun, color);
+	errno_t rc = (*led_dev_ops->color_set)(fun, color);
 	async_answer_0(callid, rc);
 }
Index: uspace/lib/drv/generic/remote_nic.c
===================================================================
--- uspace/lib/drv/generic/remote_nic.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_nic.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -98,5 +98,5 @@
  *
  */
-int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size)
+errno_t nic_send_frame(async_sess_t *dev_sess, void *data, size_t size)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
@@ -105,5 +105,5 @@
 	aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_SEND_MESSAGE, &answer);
-	sysarg_t retval = async_data_write_start(exch, data, size);
+	errno_t retval = async_data_write_start(exch, data, size);
 	
 	async_exchange_end(exch);
@@ -126,10 +126,10 @@
  *
  */
-int nic_callback_create(async_sess_t *dev_sess, async_port_handler_t cfun,
+errno_t nic_callback_create(async_sess_t *dev_sess, async_port_handler_t cfun,
     void *carg)
 {
 	ipc_call_t answer;
-	int rc;
-	sysarg_t retval;
+	errno_t rc;
+	errno_t retval;
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
@@ -147,5 +147,5 @@
 	
 	async_wait_for(req, &retval);
-	return (int) retval;
+	return retval;
 }
 
@@ -158,5 +158,5 @@
  *
  */
-int nic_get_state(async_sess_t *dev_sess, nic_device_state_t *state)
+errno_t nic_get_state(async_sess_t *dev_sess, nic_device_state_t *state)
 {
 	assert(state);
@@ -165,5 +165,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_STATE, &_state);
 	async_exchange_end(exch);
@@ -182,8 +182,8 @@
  *
  */
-int nic_set_state(async_sess_t *dev_sess, nic_device_state_t state)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_set_state(async_sess_t *dev_sess, nic_device_state_t state)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_SET_STATE, state);
 	async_exchange_end(exch);
@@ -200,5 +200,5 @@
  *
  */
-int nic_get_address(async_sess_t *dev_sess, nic_address_t *address)
+errno_t nic_get_address(async_sess_t *dev_sess, nic_address_t *address)
 {
 	assert(address);
@@ -207,8 +207,8 @@
 	aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_ADDRESS, NULL);
-	int rc = async_data_read_start(exch, address, sizeof(nic_address_t));
-	async_exchange_end(exch);
-	
-	sysarg_t res;
+	errno_t rc = async_data_read_start(exch, address, sizeof(nic_address_t));
+	async_exchange_end(exch);
+	
+	errno_t res;
 	async_wait_for(aid, &res);
 	
@@ -216,5 +216,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -227,5 +227,5 @@
  *
  */
-int nic_set_address(async_sess_t *dev_sess, const nic_address_t *address)
+errno_t nic_set_address(async_sess_t *dev_sess, const nic_address_t *address)
 {
 	assert(address);
@@ -234,8 +234,8 @@
 	aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_SET_ADDRESS, NULL);
-	int rc = async_data_write_start(exch, address, sizeof(nic_address_t));
-	async_exchange_end(exch);
-	
-	sysarg_t res;
+	errno_t rc = async_data_write_start(exch, address, sizeof(nic_address_t));
+	async_exchange_end(exch);
+	
+	errno_t res;
 	async_wait_for(aid, &res);
 	
@@ -243,5 +243,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -254,5 +254,5 @@
  *
  */
-int nic_get_stats(async_sess_t *dev_sess, nic_device_stats_t *stats)
+errno_t nic_get_stats(async_sess_t *dev_sess, nic_device_stats_t *stats)
 {
 	assert(stats);
@@ -260,5 +260,5 @@
 	async_exch_t *exch = async_exchange_begin(dev_sess);
 	
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_STATS);
 	if (rc != EOK) {
@@ -284,5 +284,5 @@
  *
  */
-int nic_get_device_info(async_sess_t *dev_sess, nic_device_info_t *device_info)
+errno_t nic_get_device_info(async_sess_t *dev_sess, nic_device_info_t *device_info)
 {
 	assert(device_info);
@@ -292,8 +292,8 @@
 	aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_DEVICE_INFO, NULL);
-	int rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
-	async_exchange_end(exch);
-
-	sysarg_t res;
+	errno_t rc = async_data_read_start(exch, device_info, sizeof(nic_device_info_t));
+	async_exchange_end(exch);
+
+	errno_t res;
 	async_wait_for(aid, &res);
 	
@@ -301,5 +301,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -312,5 +312,5 @@
  *
  */
-int nic_get_cable_state(async_sess_t *dev_sess, nic_cable_state_t *cable_state)
+errno_t nic_get_cable_state(async_sess_t *dev_sess, nic_cable_state_t *cable_state)
 {
 	assert(cable_state);
@@ -319,5 +319,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_CABLE_STATE, &_cable_state);
 	async_exchange_end(exch);
@@ -338,5 +338,5 @@
  *
  */
-int nic_get_operation_mode(async_sess_t *dev_sess, int *speed,
+errno_t nic_get_operation_mode(async_sess_t *dev_sess, int *speed,
    nic_channel_mode_t *duplex, nic_role_t *role)
 {
@@ -346,5 +346,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_OPERATION_MODE, &_speed, &_duplex, &_role);
 	async_exchange_end(exch);
@@ -375,9 +375,9 @@
  *
  */
-int nic_set_operation_mode(async_sess_t *dev_sess, int speed,
+errno_t nic_set_operation_mode(async_sess_t *dev_sess, int speed,
     nic_channel_mode_t duplex, nic_role_t role)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_SET_OPERATION_MODE, (sysarg_t) speed, (sysarg_t) duplex,
 	    (sysarg_t) role);
@@ -400,8 +400,8 @@
  *
  */
-int nic_autoneg_enable(async_sess_t *dev_sess, uint32_t advertisement)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_autoneg_enable(async_sess_t *dev_sess, uint32_t advertisement)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_AUTONEG_ENABLE, (sysarg_t) advertisement);
 	async_exchange_end(exch);
@@ -417,8 +417,8 @@
  *
  */
-int nic_autoneg_disable(async_sess_t *dev_sess)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_autoneg_disable(async_sess_t *dev_sess)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_AUTONEG_DISABLE);
 	async_exchange_end(exch);
@@ -444,5 +444,5 @@
  *
  */
-int nic_autoneg_probe(async_sess_t *dev_sess, uint32_t *our_advertisement,
+errno_t nic_autoneg_probe(async_sess_t *dev_sess, uint32_t *our_advertisement,
     uint32_t *their_advertisement, nic_result_t *result,
     nic_result_t *their_result)
@@ -454,5 +454,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_4(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_4(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_AUTONEG_PROBE, &_our_advertisement, &_their_advertisement,
 	    &_result, &_their_result);
@@ -481,8 +481,8 @@
  *
  */
-int nic_autoneg_restart(async_sess_t *dev_sess)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_autoneg_restart(async_sess_t *dev_sess)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_AUTONEG_RESTART);
 	async_exchange_end(exch);
@@ -501,5 +501,5 @@
  *
  */
-int nic_get_pause(async_sess_t *dev_sess, nic_result_t *we_send,
+errno_t nic_get_pause(async_sess_t *dev_sess, nic_result_t *we_send,
     nic_result_t *we_receive, uint16_t *pause)
 {
@@ -509,5 +509,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_GET_PAUSE, &_we_send, &_we_receive, &_pause);
 	async_exchange_end(exch);
@@ -539,9 +539,9 @@
  *
  */
-int nic_set_pause(async_sess_t *dev_sess, int allow_send, int allow_receive,
+errno_t nic_set_pause(async_sess_t *dev_sess, int allow_send, int allow_receive,
     uint16_t pause)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_SET_PAUSE, allow_send, allow_receive, pause);
 	async_exchange_end(exch);
@@ -566,5 +566,5 @@
  *
  */
-int nic_unicast_get_mode(async_sess_t *dev_sess, nic_unicast_mode_t *mode,
+errno_t nic_unicast_get_mode(async_sess_t *dev_sess, nic_unicast_mode_t *mode,
     size_t max_count, nic_address_t *address_list, size_t *address_count)
 {
@@ -579,5 +579,5 @@
 	async_exch_t *exch = async_exchange_begin(dev_sess);
 	
-	int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_UNICAST_GET_MODE, max_count, &_mode, &_address_count);
 	if (rc != EOK) {
@@ -609,5 +609,5 @@
  *
  */
-int nic_unicast_set_mode(async_sess_t *dev_sess, nic_unicast_mode_t mode,
+errno_t nic_unicast_set_mode(async_sess_t *dev_sess, nic_unicast_mode_t mode,
     const nic_address_t *address_list, size_t address_count)
 {
@@ -620,5 +620,5 @@
 	    NIC_UNICAST_SET_MODE, (sysarg_t) mode, address_count, NULL);
 	
-	int rc;
+	errno_t rc;
 	if (address_count)
 		rc = async_data_write_start(exch, address_list,
@@ -629,5 +629,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(message_id, &res);
 	
@@ -635,5 +635,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -655,5 +655,5 @@
  *
  */
-int nic_multicast_get_mode(async_sess_t *dev_sess, nic_multicast_mode_t *mode,
+errno_t nic_multicast_get_mode(async_sess_t *dev_sess, nic_multicast_mode_t *mode,
     size_t max_count, nic_address_t *address_list, size_t *address_count)
 {
@@ -668,5 +668,5 @@
 	
 	sysarg_t ac;
-	int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_MULTICAST_GET_MODE, max_count, &_mode, &ac);
 	if (rc != EOK) {
@@ -697,5 +697,5 @@
  *
  */
-int nic_multicast_set_mode(async_sess_t *dev_sess, nic_multicast_mode_t mode,
+errno_t nic_multicast_set_mode(async_sess_t *dev_sess, nic_multicast_mode_t mode,
     const nic_address_t *address_list, size_t address_count)
 {
@@ -708,5 +708,5 @@
 	    NIC_MULTICAST_SET_MODE, (sysarg_t) mode, address_count, NULL);
 	
-	int rc;
+	errno_t rc;
 	if (address_count)
 		rc = async_data_write_start(exch, address_list,
@@ -717,5 +717,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(message_id, &res);
 	
@@ -723,5 +723,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -734,5 +734,5 @@
  *
  */
-int nic_broadcast_get_mode(async_sess_t *dev_sess, nic_broadcast_mode_t *mode)
+errno_t nic_broadcast_get_mode(async_sess_t *dev_sess, nic_broadcast_mode_t *mode)
 {
 	assert(mode);
@@ -741,5 +741,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_BROADCAST_GET_MODE, &_mode);
 	async_exchange_end(exch);
@@ -758,8 +758,8 @@
  *
  */
-int nic_broadcast_set_mode(async_sess_t *dev_sess, nic_broadcast_mode_t mode)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_broadcast_set_mode(async_sess_t *dev_sess, nic_broadcast_mode_t mode)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_BROADCAST_SET_MODE, mode);
 	async_exchange_end(exch);
@@ -776,5 +776,5 @@
  *
  */
-int nic_defective_get_mode(async_sess_t *dev_sess, uint32_t *mode)
+errno_t nic_defective_get_mode(async_sess_t *dev_sess, uint32_t *mode)
 {
 	assert(mode);
@@ -783,5 +783,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_DEFECTIVE_GET_MODE, &_mode);
 	async_exchange_end(exch);
@@ -800,8 +800,8 @@
  *
  */
-int nic_defective_set_mode(async_sess_t *dev_sess, uint32_t mode)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_defective_set_mode(async_sess_t *dev_sess, uint32_t mode)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_DEFECTIVE_SET_MODE, mode);
 	async_exchange_end(exch);
@@ -822,5 +822,5 @@
  *
  */
-int nic_blocked_sources_get(async_sess_t *dev_sess, size_t max_count,
+errno_t nic_blocked_sources_get(async_sess_t *dev_sess, size_t max_count,
     nic_address_t *address_list, size_t *address_count)
 {
@@ -831,5 +831,5 @@
 	
 	sysarg_t ac;
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_BLOCKED_SOURCES_GET, max_count, &ac);
 	if (rc != EOK) {
@@ -858,5 +858,5 @@
  *
  */
-int nic_blocked_sources_set(async_sess_t *dev_sess,
+errno_t nic_blocked_sources_set(async_sess_t *dev_sess,
     const nic_address_t *address_list, size_t address_count)
 {
@@ -869,5 +869,5 @@
 	    NIC_BLOCKED_SOURCES_SET, address_count, NULL);
 	
-	int rc;
+	errno_t rc;
 	if (address_count)
 		rc = async_data_write_start(exch, address_list,
@@ -878,5 +878,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(message_id, &res);
 	
@@ -884,5 +884,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -895,10 +895,10 @@
  *
  */
-int nic_vlan_get_mask(async_sess_t *dev_sess, nic_vlan_mask_t *mask)
+errno_t nic_vlan_get_mask(async_sess_t *dev_sess, nic_vlan_mask_t *mask)
 {
 	assert(mask);
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_VLAN_GET_MASK);
 	if (rc != EOK) {
@@ -923,5 +923,5 @@
  *
  */
-int nic_vlan_set_mask(async_sess_t *dev_sess, const nic_vlan_mask_t *mask)
+errno_t nic_vlan_set_mask(async_sess_t *dev_sess, const nic_vlan_mask_t *mask)
 {
 	async_exch_t *exch = async_exchange_begin(dev_sess);
@@ -930,5 +930,5 @@
 	    NIC_VLAN_SET_MASK, mask != NULL, NULL);
 	
-	int rc;
+	errno_t rc;
 	if (mask != NULL)
 		rc = async_data_write_start(exch, mask, sizeof(nic_vlan_mask_t));
@@ -938,5 +938,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(message_id, &res);
 	
@@ -944,5 +944,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -963,8 +963,8 @@
  *
  */
-int nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, bool add, bool strip)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_vlan_set_tag(async_sess_t *dev_sess, uint16_t tag, bool add, bool strip)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_4_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_VLAN_SET_TAG, (sysarg_t) tag, (sysarg_t) add, (sysarg_t) strip);
 	async_exchange_end(exch);
@@ -985,5 +985,5 @@
  *
  */
-int nic_wol_virtue_add(async_sess_t *dev_sess, nic_wv_type_t type,
+errno_t nic_wol_virtue_add(async_sess_t *dev_sess, nic_wv_type_t type,
     const void *data, size_t length, nic_wv_id_t *id)
 {
@@ -997,7 +997,7 @@
 	    NIC_WOL_VIRTUE_ADD, (sysarg_t) type, send_data, &result);
 	
-	sysarg_t res;
+	errno_t res;
 	if (send_data) {
-		int rc = async_data_write_start(exch, data, length);
+		errno_t rc = async_data_write_start(exch, data, length);
 		if (rc != EOK) {
 			async_exchange_end(exch);
@@ -1011,5 +1011,5 @@
 	
 	*id = IPC_GET_ARG1(result);
-	return (int) res;
+	return res;
 }
 
@@ -1022,8 +1022,8 @@
  *
  */
-int nic_wol_virtue_remove(async_sess_t *dev_sess, nic_wv_id_t id)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_wol_virtue_remove(async_sess_t *dev_sess, nic_wv_id_t id)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_WOL_VIRTUE_REMOVE, (sysarg_t) id);
 	async_exchange_end(exch);
@@ -1045,5 +1045,5 @@
  *
  */
-int nic_wol_virtue_probe(async_sess_t *dev_sess, nic_wv_id_t id,
+errno_t nic_wol_virtue_probe(async_sess_t *dev_sess, nic_wv_id_t id,
     nic_wv_type_t *type, size_t max_length, void *data, size_t *length)
 {
@@ -1056,5 +1056,5 @@
 	async_exch_t *exch = async_exchange_begin(dev_sess);
 	
-	int rc = async_req_3_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_3_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_WOL_VIRTUE_PROBE, (sysarg_t) id, max_length,
 	    &_type, &_length);
@@ -1095,5 +1095,5 @@
  *
  */
-int nic_wol_virtue_list(async_sess_t *dev_sess, nic_wv_type_t type,
+errno_t nic_wol_virtue_list(async_sess_t *dev_sess, nic_wv_type_t type,
     size_t max_count, nic_wv_id_t *id_list, size_t *id_count)
 {
@@ -1104,5 +1104,5 @@
 	
 	sysarg_t count;
-	int rc = async_req_3_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_3_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_WOL_VIRTUE_LIST, (sysarg_t) type, max_count, &count);
 	
@@ -1135,5 +1135,5 @@
  *
  */
-int nic_wol_virtue_get_caps(async_sess_t *dev_sess, nic_wv_type_t type,
+errno_t nic_wol_virtue_get_caps(async_sess_t *dev_sess, nic_wv_type_t type,
     int *count)
 {
@@ -1143,5 +1143,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_WOL_VIRTUE_GET_CAPS, (sysarg_t) type, &_count);
 	async_exchange_end(exch);
@@ -1173,5 +1173,5 @@
  *
  */
-int nic_wol_load_info(async_sess_t *dev_sess, nic_wv_type_t *matched_type,
+errno_t nic_wol_load_info(async_sess_t *dev_sess, nic_wv_type_t *matched_type,
     size_t max_length, uint8_t *frame, size_t *frame_length)
 {
@@ -1186,5 +1186,5 @@
 	async_exch_t *exch = async_exchange_begin(dev_sess);
 	
-	int rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_WOL_LOAD_INFO, max_length, &_matched_type, &_frame_length);
 	if (rc != EOK) {
@@ -1213,5 +1213,5 @@
  *
  */
-int nic_offload_probe(async_sess_t *dev_sess, uint32_t *supported,
+errno_t nic_offload_probe(async_sess_t *dev_sess, uint32_t *supported,
     uint32_t *active)
 {
@@ -1223,5 +1223,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_OFFLOAD_PROBE, &_supported, &_active);
 	async_exchange_end(exch);
@@ -1241,8 +1241,8 @@
  *
  */
-int nic_offload_set(async_sess_t *dev_sess, uint32_t mask, uint32_t active)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_3_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+errno_t nic_offload_set(async_sess_t *dev_sess, uint32_t mask, uint32_t active)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_3_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_AUTONEG_RESTART, (sysarg_t) mask, (sysarg_t) active);
 	async_exchange_end(exch);
@@ -1261,5 +1261,5 @@
  *
  */
-int nic_poll_get_mode(async_sess_t *dev_sess, nic_poll_mode_t *mode,
+errno_t nic_poll_get_mode(async_sess_t *dev_sess, nic_poll_mode_t *mode,
     struct timeval *period)
 {
@@ -1270,5 +1270,5 @@
 	async_exch_t *exch = async_exchange_begin(dev_sess);
 	
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
 	    NIC_POLL_GET_MODE, period != NULL, &_mode);
 	if (rc != EOK) {
@@ -1295,5 +1295,5 @@
  *
  */
-int nic_poll_set_mode(async_sess_t *dev_sess, nic_poll_mode_t mode,
+errno_t nic_poll_set_mode(async_sess_t *dev_sess, nic_poll_mode_t mode,
     const struct timeval *period)
 {
@@ -1303,5 +1303,5 @@
 	    NIC_POLL_SET_MODE, (sysarg_t) mode, period != NULL, NULL);
 	
-	int rc;
+	errno_t rc;
 	if (period)
 		rc = async_data_write_start(exch, period, sizeof(struct timeval));
@@ -1311,5 +1311,5 @@
 	async_exchange_end(exch);
 	
-	sysarg_t res;
+	errno_t res;
 	async_wait_for(message_id, &res);
 	
@@ -1317,5 +1317,5 @@
 		return rc;
 	
-	return (int) res;
+	return res;
 }
 
@@ -1327,8 +1327,8 @@
  *
  */
-int nic_poll_now(async_sess_t *dev_sess)
-{
-	async_exch_t *exch = async_exchange_begin(dev_sess);
-	int rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_POLL_NOW);
+errno_t nic_poll_now(async_sess_t *dev_sess)
+{
+	async_exch_t *exch = async_exchange_begin(dev_sess);
+	errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_POLL_NOW);
 	async_exchange_end(exch);
 	
@@ -1344,5 +1344,5 @@
 	void *data;
 	size_t size;
-	int rc;
+	errno_t rc;
 	
 	rc = async_data_write_accept(&data, false, 0, 0, 0, &size);
@@ -1363,5 +1363,5 @@
 	assert(nic_iface->callback_create);
 	
-	int rc = nic_iface->callback_create(dev);
+	errno_t rc = nic_iface->callback_create(dev);
 	async_answer_0(callid, rc);
 }
@@ -1375,5 +1375,5 @@
 	nic_device_state_t state = NIC_STATE_MAX;
 	
-	int rc = nic_iface->get_state(dev, &state);
+	errno_t rc = nic_iface->get_state(dev, &state);
 	async_answer_1(callid, rc, state);
 }
@@ -1387,5 +1387,5 @@
 	nic_device_state_t state = (nic_device_state_t) IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->set_state(dev, state);
+	errno_t rc = nic_iface->set_state(dev, state);
 	async_answer_0(callid, rc);
 }
@@ -1400,5 +1400,5 @@
 	memset(&address, 0, sizeof(nic_address_t));
 	
-	int rc = nic_iface->get_address(dev, &address);
+	errno_t rc = nic_iface->get_address(dev, &address);
 	if (rc == EOK) {
 		size_t max_len;
@@ -1451,5 +1451,5 @@
 	
 	if (nic_iface->set_address != NULL) {
-		int rc = nic_iface->set_address(dev, &address);
+		errno_t rc = nic_iface->set_address(dev, &address);
 		async_answer_0(callid, rc);
 	} else
@@ -1469,5 +1469,5 @@
 	memset(&stats, 0, sizeof(nic_device_stats_t));
 	
-	int rc = nic_iface->get_stats(dev, &stats);
+	errno_t rc = nic_iface->get_stats(dev, &stats);
 	if (rc == EOK) {
 		ipc_callid_t data_callid;
@@ -1504,5 +1504,5 @@
 	memset(&info, 0, sizeof(nic_device_info_t));
 	
-	int rc = nic_iface->get_device_info(dev, &info);
+	errno_t rc = nic_iface->get_device_info(dev, &info);
 	if (rc == EOK) {
 		ipc_callid_t data_callid;
@@ -1538,5 +1538,5 @@
 	nic_cable_state_t cs = NIC_CS_UNKNOWN;
 	
-	int rc = nic_iface->get_cable_state(dev, &cs);
+	errno_t rc = nic_iface->get_cable_state(dev, &cs);
 	async_answer_1(callid, rc, (sysarg_t) cs);
 }
@@ -1555,5 +1555,5 @@
 	nic_role_t role = NIC_ROLE_UNKNOWN;
 	
-	int rc = nic_iface->get_operation_mode(dev, &speed, &duplex, &role);
+	errno_t rc = nic_iface->get_operation_mode(dev, &speed, &duplex, &role);
 	async_answer_3(callid, rc, (sysarg_t) speed, (sysarg_t) duplex,
 	    (sysarg_t) role);
@@ -1573,5 +1573,5 @@
 	nic_role_t role = (nic_role_t) IPC_GET_ARG4(*call);
 	
-	int rc = nic_iface->set_operation_mode(dev, speed, duplex, role);
+	errno_t rc = nic_iface->set_operation_mode(dev, speed, duplex, role);
 	async_answer_0(callid, rc);
 }
@@ -1588,5 +1588,5 @@
 	uint32_t advertisement = (uint32_t) IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->autoneg_enable(dev, advertisement);
+	errno_t rc = nic_iface->autoneg_enable(dev, advertisement);
 	async_answer_0(callid, rc);
 }
@@ -1601,5 +1601,5 @@
 	}
 	
-	int rc = nic_iface->autoneg_disable(dev);
+	errno_t rc = nic_iface->autoneg_disable(dev);
 	async_answer_0(callid, rc);
 }
@@ -1619,5 +1619,5 @@
 	nic_result_t their_result = NIC_RESULT_NOT_AVAILABLE;
 	
-	int rc = nic_iface->autoneg_probe(dev, &our_adv, &their_adv, &result,
+	errno_t rc = nic_iface->autoneg_probe(dev, &our_adv, &their_adv, &result,
 	    &their_result);
 	async_answer_4(callid, rc, our_adv, their_adv, (sysarg_t) result,
@@ -1634,5 +1634,5 @@
 	}
 	
-	int rc = nic_iface->autoneg_restart(dev);
+	errno_t rc = nic_iface->autoneg_restart(dev);
 	async_answer_0(callid, rc);
 }
@@ -1651,5 +1651,5 @@
 	uint16_t pause;
 	
-	int rc = nic_iface->get_pause(dev, &we_send, &we_receive, &pause);
+	errno_t rc = nic_iface->get_pause(dev, &we_send, &we_receive, &pause);
 	async_answer_3(callid, rc, we_send, we_receive, pause);
 }
@@ -1668,5 +1668,5 @@
 	uint16_t pause = (uint16_t) IPC_GET_ARG4(*call);
 	
-	int rc = nic_iface->set_pause(dev, allow_send, allow_receive,
+	errno_t rc = nic_iface->set_pause(dev, allow_send, allow_receive,
 	    pause);
 	async_answer_0(callid, rc);
@@ -1697,5 +1697,5 @@
 	size_t address_count = 0;
 	
-	int rc = nic_iface->unicast_get_mode(dev, &mode, max_count, address_list,
+	errno_t rc = nic_iface->unicast_get_mode(dev, &mode, max_count, address_list,
 	    &address_count);
 	
@@ -1768,5 +1768,5 @@
 	
 	if (nic_iface->unicast_set_mode != NULL) {
-		int rc = nic_iface->unicast_set_mode(dev, mode, address_list,
+		errno_t rc = nic_iface->unicast_set_mode(dev, mode, address_list,
 		    address_count);
 		async_answer_0(callid, rc);
@@ -1801,5 +1801,5 @@
 	size_t address_count = 0;
 	
-	int rc = nic_iface->multicast_get_mode(dev, &mode, max_count, address_list,
+	errno_t rc = nic_iface->multicast_get_mode(dev, &mode, max_count, address_list,
 	    &address_count);
 	
@@ -1872,5 +1872,5 @@
 	
 	if (nic_iface->multicast_set_mode != NULL) {
-		int rc = nic_iface->multicast_set_mode(dev, mode, address_list,
+		errno_t rc = nic_iface->multicast_set_mode(dev, mode, address_list,
 		    address_count);
 		async_answer_0(callid, rc);
@@ -1892,5 +1892,5 @@
 	nic_broadcast_mode_t mode = NIC_BROADCAST_ACCEPTED;
 	
-	int rc = nic_iface->broadcast_get_mode(dev, &mode);
+	errno_t rc = nic_iface->broadcast_get_mode(dev, &mode);
 	async_answer_1(callid, rc, mode);
 }
@@ -1907,5 +1907,5 @@
 	nic_broadcast_mode_t mode = IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->broadcast_set_mode(dev, mode);
+	errno_t rc = nic_iface->broadcast_set_mode(dev, mode);
 	async_answer_0(callid, rc);
 }
@@ -1922,5 +1922,5 @@
 	uint32_t mode = 0;
 	
-	int rc = nic_iface->defective_get_mode(dev, &mode);
+	errno_t rc = nic_iface->defective_get_mode(dev, &mode);
 	async_answer_1(callid, rc, mode);
 }
@@ -1937,5 +1937,5 @@
 	uint32_t mode = IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->defective_set_mode(dev, mode);
+	errno_t rc = nic_iface->defective_set_mode(dev, mode);
 	async_answer_0(callid, rc);
 }
@@ -1964,5 +1964,5 @@
 	size_t address_count = 0;
 	
-	int rc = nic_iface->blocked_sources_get(dev, max_count, address_list,
+	errno_t rc = nic_iface->blocked_sources_get(dev, max_count, address_list,
 	    &address_count);
 	
@@ -2034,5 +2034,5 @@
 	
 	if (nic_iface->blocked_sources_set != NULL) {
-		int rc = nic_iface->blocked_sources_set(dev, address_list,
+		errno_t rc = nic_iface->blocked_sources_set(dev, address_list,
 		    address_count);
 		async_answer_0(callid, rc);
@@ -2055,5 +2055,5 @@
 	memset(&vlan_mask, 0, sizeof(nic_vlan_mask_t));
 	
-	int rc = nic_iface->vlan_get_mask(dev, &vlan_mask);
+	errno_t rc = nic_iface->vlan_get_mask(dev, &vlan_mask);
 	if (rc == EOK) {
 		ipc_callid_t data_callid;
@@ -2111,5 +2111,5 @@
 	
 	if (nic_iface->vlan_set_mask != NULL) {
-		int rc = nic_iface->vlan_set_mask(dev, vlan_mask_pointer);
+		errno_t rc = nic_iface->vlan_set_mask(dev, vlan_mask_pointer);
 		async_answer_0(callid, rc);
 	} else
@@ -2131,5 +2131,5 @@
 	bool strip = (int) IPC_GET_ARG4(*call);
 	
-	int rc = nic_iface->vlan_set_tag(dev, tag, add, strip);
+	errno_t rc = nic_iface->vlan_set_tag(dev, tag, add, strip);
 	async_answer_0(callid, rc);
 }
@@ -2180,5 +2180,5 @@
 	nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->wol_virtue_add(dev, type, data, length, &id);
+	errno_t rc = nic_iface->wol_virtue_add(dev, type, data, length, &id);
 	async_answer_1(callid, rc, (sysarg_t) id);
 	free(data);
@@ -2197,5 +2197,5 @@
 	nic_wv_id_t id = (nic_wv_id_t) IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->wol_virtue_remove(dev, id);
+	errno_t rc = nic_iface->wol_virtue_remove(dev, id);
 	async_answer_0(callid, rc);
 }
@@ -2228,5 +2228,5 @@
 	memset(data, 0, max_length);
 	
-	int rc = nic_iface->wol_virtue_probe(dev, id, &type, max_length,
+	errno_t rc = nic_iface->wol_virtue_probe(dev, id, &type, max_length,
 	    data, &length);
 	
@@ -2278,5 +2278,5 @@
 	memset(id_list, 0, max_count * sizeof (nic_wv_id_t));
 	
-	int rc = nic_iface->wol_virtue_list(dev, type, max_count, id_list,
+	errno_t rc = nic_iface->wol_virtue_list(dev, type, max_count, id_list,
 	    &count);
 	
@@ -2315,5 +2315,5 @@
 	nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call);
 	
-	int rc = nic_iface->wol_virtue_get_caps(dev, type, &count);
+	errno_t rc = nic_iface->wol_virtue_get_caps(dev, type, &count);
 	async_answer_1(callid, rc, (sysarg_t) count);
 }
@@ -2343,5 +2343,5 @@
 	memset(data, 0, max_length);
 	
-	int rc = nic_iface->wol_load_info(dev, &type, max_length, data,
+	errno_t rc = nic_iface->wol_load_info(dev, &type, max_length, data,
 	    &frame_length);
 	if (rc == EOK) {
@@ -2376,5 +2376,5 @@
 	uint32_t active = 0;
 	
-	int rc = nic_iface->offload_probe(dev, &supported, &active);
+	errno_t rc = nic_iface->offload_probe(dev, &supported, &active);
 	async_answer_2(callid, rc, supported, active);
 }
@@ -2392,5 +2392,5 @@
 	uint32_t active = (uint32_t) IPC_GET_ARG3(*call);
 	
-	int rc = nic_iface->offload_set(dev, mask, active);
+	errno_t rc = nic_iface->offload_set(dev, mask, active);
 	async_answer_0(callid, rc);
 }
@@ -2412,5 +2412,5 @@
 	};
 	
-	int rc = nic_iface->poll_get_mode(dev, &mode, &period);
+	errno_t rc = nic_iface->poll_get_mode(dev, &mode, &period);
 	if ((rc == EOK) && (request_data)) {
 		size_t max_len;
@@ -2470,5 +2470,5 @@
 	
 	if (nic_iface->poll_set_mode != NULL) {
-		int rc = nic_iface->poll_set_mode(dev, mode, period);
+		errno_t rc = nic_iface->poll_set_mode(dev, mode, period);
 		async_answer_0(callid, rc);
 	} else
@@ -2485,5 +2485,5 @@
 	}
 	
-	int rc = nic_iface->poll_now(dev);
+	errno_t rc = nic_iface->poll_now(dev);
 	async_answer_0(callid, rc);
 }
Index: uspace/lib/drv/generic/remote_pci.c
===================================================================
--- uspace/lib/drv/generic/remote_pci.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_pci.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -51,10 +51,10 @@
 } pci_dev_iface_funcs_t;
 
-int pci_config_space_read_8(async_sess_t *sess, uint32_t address, uint8_t *val)
+errno_t pci_config_space_read_8(async_sess_t *sess, uint32_t address, uint8_t *val)
 {
 	sysarg_t res = 0;
 	
 	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_READ_8, address, &res);
 	async_exchange_end(exch);
@@ -64,5 +64,5 @@
 }
 
-int pci_config_space_read_16(async_sess_t *sess, uint32_t address,
+errno_t pci_config_space_read_16(async_sess_t *sess, uint32_t address,
     uint16_t *val)
 {
@@ -70,5 +70,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_READ_16, address, &res);
 	async_exchange_end(exch);
@@ -78,5 +78,5 @@
 }
 
-int pci_config_space_read_32(async_sess_t *sess, uint32_t address,
+errno_t pci_config_space_read_32(async_sess_t *sess, uint32_t address,
     uint32_t *val)
 {
@@ -84,5 +84,5 @@
 	
 	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+	errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_READ_32, address, &res);
 	async_exchange_end(exch);
@@ -92,8 +92,8 @@
 }
 
-int pci_config_space_write_8(async_sess_t *sess, uint32_t address, uint8_t val)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+errno_t pci_config_space_write_8(async_sess_t *sess, uint32_t address, uint8_t val)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	errno_t rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_WRITE_8, address, val);
 	async_exchange_end(exch);
@@ -102,9 +102,9 @@
 }
 
-int pci_config_space_write_16(async_sess_t *sess, uint32_t address,
+errno_t pci_config_space_write_16(async_sess_t *sess, uint32_t address,
     uint16_t val)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+	errno_t rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_WRITE_16, address, val);
 	async_exchange_end(exch);
@@ -113,9 +113,9 @@
 }
 
-int pci_config_space_write_32(async_sess_t *sess, uint32_t address,
+errno_t pci_config_space_write_32(async_sess_t *sess, uint32_t address,
     uint32_t val)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
-	int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
+	errno_t rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
 	    IPC_M_CONFIG_SPACE_WRITE_32, address, val);
 	async_exchange_end(exch);
@@ -160,5 +160,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint8_t value;
-	int ret = pci_iface->config_space_read_8(fun, address, &value);
+	errno_t ret = pci_iface->config_space_read_8(fun, address, &value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
@@ -178,5 +178,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint16_t value;
-	int ret = pci_iface->config_space_read_16(fun, address, &value);
+	errno_t ret = pci_iface->config_space_read_16(fun, address, &value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
@@ -195,5 +195,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint32_t value;
-	int ret = pci_iface->config_space_read_32(fun, address, &value);
+	errno_t ret = pci_iface->config_space_read_32(fun, address, &value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
@@ -213,5 +213,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint8_t value = DEV_IPC_GET_ARG2(*call);
-	int ret = pci_iface->config_space_write_8(fun, address, value);
+	errno_t ret = pci_iface->config_space_write_8(fun, address, value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
@@ -231,5 +231,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint16_t value = DEV_IPC_GET_ARG2(*call);
-	int ret = pci_iface->config_space_write_16(fun, address, value);
+	errno_t ret = pci_iface->config_space_write_16(fun, address, value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
@@ -249,5 +249,5 @@
 	uint32_t address = DEV_IPC_GET_ARG1(*call);
 	uint32_t value = DEV_IPC_GET_ARG2(*call);
-	int ret = pci_iface->config_space_write_32(fun, address, value);
+	errno_t ret = pci_iface->config_space_write_32(fun, address, value);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
Index: uspace/lib/drv/generic/remote_usb.c
===================================================================
--- uspace/lib/drv/generic/remote_usb.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_usb.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -70,5 +70,5 @@
  * @return Error code.
  */
-int usb_get_my_description(async_exch_t *exch, usb_device_desc_t *desc)
+errno_t usb_get_my_description(async_exch_t *exch, usb_device_desc_t *desc)
 {
 	if (!exch)
@@ -77,5 +77,5 @@
 	usb_device_desc_t tmp_desc;
 
-	const int ret = async_req_1_5(exch, DEV_IFACE_ID(USB_DEV_IFACE),
+	const errno_t ret = async_req_1_5(exch, DEV_IFACE_ID(USB_DEV_IFACE),
 	    IPC_M_USB_GET_MY_DESCRIPTION,
 	    (sysarg_t *) &tmp_desc.address,
@@ -114,5 +114,5 @@
 
 	usb_device_desc_t desc;
-	const int ret = usb_iface->get_my_description(fun, &desc);
+	const errno_t ret = usb_iface->get_my_description(fun, &desc);
 	if (ret != EOK) {
 		async_answer_0(callid, ret);
Index: uspace/lib/drv/generic/remote_usbdiag.c
===================================================================
--- uspace/lib/drv/generic/remote_usbdiag.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_usbdiag.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -82,5 +82,5 @@
 	async_exchange_end(exch);
 
-	sysarg_t retval;
+	errno_t retval;
 	async_wait_for(req, &retval);
 
@@ -112,5 +112,5 @@
 	async_exchange_end(exch);
 
-	sysarg_t retval;
+	errno_t retval;
 	async_wait_for(req, &retval);
 
Index: uspace/lib/drv/generic/remote_usbhc.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhc.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_usbhc.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -39,4 +39,5 @@
 #include <errno.h>
 #include <devman.h>
+#include <as.h>
 
 #include "usbhc_iface.h"
@@ -104,5 +105,5 @@
  *
  */
-int usbhc_device_remove(async_exch_t *exch, unsigned port)
+errno_t usbhc_device_remove(async_exch_t *exch, unsigned port)
 {
 	if (!exch)
@@ -112,5 +113,5 @@
 }
 
-int usbhc_register_endpoint(async_exch_t *exch, usb_pipe_desc_t *pipe_desc,
+errno_t usbhc_register_endpoint(async_exch_t *exch, usb_pipe_desc_t *pipe_desc,
     const usb_endpoint_descriptors_t *desc)
 {
@@ -135,5 +136,5 @@
 
 	/* Wait for the answer. */
-	sysarg_t opening_request_rc;
+	int opening_request_rc;
 	async_wait_for(opening_request, &opening_request_rc);
 
@@ -153,5 +154,5 @@
 }
 
-int usbhc_unregister_endpoint(async_exch_t *exch, const usb_pipe_desc_t *pipe_desc)
+errno_t usbhc_unregister_endpoint(async_exch_t *exch, const usb_pipe_desc_t *pipe_desc)
 {
 	if (!exch)
@@ -172,5 +173,5 @@
 
 	/* Wait for the answer. */
-	sysarg_t opening_request_rc;
+	int opening_request_rc;
 	async_wait_for(opening_request, &opening_request_rc);
 
@@ -178,7 +179,15 @@
 }
 
-int usbhc_read(async_exch_t *exch, usb_endpoint_t endpoint, uint64_t setup,
-    void *data, size_t size, size_t *rec_size)
-{
+/**
+ * Issue a USB transfer with a data contained in memory area. That area is
+ * temporarily shared with the HC.
+ */
+errno_t usbhc_transfer(async_exch_t *exch, usb_endpoint_t endpoint,
+    usb_direction_t dir, uint64_t setup, void *area, size_t size,
+    size_t *transferred)
+{
+	if (transferred)
+		*transferred = 0;
+
 	if (!exch)
 		return EBADMEM;
@@ -187,66 +196,22 @@
 		return EOK;
 
-	/* Make call identifying target USB device and type of transfer. */
-	aid_t opening_request = async_send_4(exch,
-	    DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_READ, endpoint,
-	    (setup & UINT32_MAX), (setup >> 32), NULL);
-
-	if (opening_request == 0) {
+	sysarg_t method = (dir == USB_DIRECTION_IN)
+		? IPC_M_USB_READ : IPC_M_USB_WRITE;
+
+	ipc_call_t call;
+
+
+	aid_t opening_request = async_send_5(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
+	    method, endpoint, size, (setup & UINT32_MAX), (setup >> 32), &call);
+
+	if (opening_request == 0)
 		return ENOMEM;
-	}
-
-	/* Retrieve the data. */
-	ipc_call_t data_request_call;
-	aid_t data_request =
-	    async_data_read(exch, data, size, &data_request_call);
-
-	if (data_request == 0) {
-		// FIXME: How to let the other side know that we want to abort?
-		async_forget(opening_request);
-		return ENOMEM;
-	}
-
-	/* Wait for the answer. */
-	sysarg_t data_request_rc;
-	sysarg_t opening_request_rc;
-	async_wait_for(data_request, &data_request_rc);
-	async_wait_for(opening_request, &opening_request_rc);
-
-	if (data_request_rc != EOK) {
-		/* Prefer the return code of the opening request. */
-		if (opening_request_rc != EOK) {
-			return (int) opening_request_rc;
-		} else {
-			return (int) data_request_rc;
-		}
-	}
-	if (opening_request_rc != EOK) {
-		return (int) opening_request_rc;
-	}
-
-	*rec_size = IPC_GET_ARG2(data_request_call);
-	return EOK;
-}
-
-int usbhc_write(async_exch_t *exch, usb_endpoint_t endpoint, uint64_t setup,
-    const void *data, size_t size)
-{
-	if (!exch)
-		return EBADMEM;
-
-	if (size == 0 && setup == 0)
-		return EOK;
-
-	aid_t opening_request = async_send_5(exch,
-	    DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_WRITE, endpoint, size,
-	    (setup & UINT32_MAX), (setup >> 32), NULL);
-
-	if (opening_request == 0) {
-		return ENOMEM;
-	}
 
 	/* Send the data if any. */
 	if (size > 0) {
-		const int ret = async_data_write_start(exch, data, size);
+		unsigned flags = (dir == USB_DIRECTION_IN)
+			? AS_AREA_WRITE : AS_AREA_READ;
+
+		const errno_t ret = async_share_out_start(exch, area, flags);
 		if (ret != EOK) {
 			async_forget(opening_request);
@@ -256,8 +221,53 @@
 
 	/* Wait for the answer. */
-	sysarg_t opening_request_rc;
+	errno_t opening_request_rc;
 	async_wait_for(opening_request, &opening_request_rc);
 
-	return (int) opening_request_rc;
+	if (transferred)
+		*transferred = IPC_GET_ARG1(call);
+
+	return (errno_t) opening_request_rc;
+}
+
+errno_t usbhc_read(async_exch_t *exch, usb_endpoint_t endpoint, uint64_t setup,
+    void *data, size_t size, size_t *rec_size)
+{
+	if (size == 0)
+		return usbhc_transfer(exch, endpoint, USB_DIRECTION_IN,
+		    setup, NULL, 0, NULL);
+
+	/* Prepare an area to read */
+	void *area = as_area_create(AS_AREA_ANY, size,
+	    AS_AREA_READ | AS_AREA_WRITE, AS_AREA_UNPAGED);
+	if (!area)
+		return ENOMEM;
+
+	const errno_t err = usbhc_transfer(exch, endpoint, USB_DIRECTION_IN,
+	    setup, area, size, rec_size);
+	if (err == EOK)
+		memcpy(data, area, *rec_size);
+
+	as_area_destroy(area);
+	return err;
+}
+
+errno_t usbhc_write(async_exch_t *exch, usb_endpoint_t endpoint, uint64_t setup,
+    const void *data, size_t size)
+{
+	if (size == 0)
+		return usbhc_transfer(exch, endpoint, USB_DIRECTION_OUT,
+		    setup, NULL, 0, NULL);
+
+	/* Prepare an area to read */
+	void *area = as_area_create(AS_AREA_ANY, size,
+	    AS_AREA_READ | AS_AREA_WRITE, AS_AREA_UNPAGED);
+	if (!area)
+		return ENOMEM;
+
+	memcpy(area, data, size);
+	const errno_t err = usbhc_transfer(exch, endpoint, USB_DIRECTION_OUT,
+	    setup, area, size, NULL);
+	as_area_destroy(area);
+	return err;
 }
 
@@ -267,6 +277,5 @@
 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_read(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call);
-static void remote_usbhc_write(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call);
+static void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call);
 
 /** Remote USB interface operations. */
@@ -277,6 +286,6 @@
 	[IPC_M_USB_REGISTER_ENDPOINT] = remote_usbhc_register_endpoint,
 	[IPC_M_USB_UNREGISTER_ENDPOINT] = remote_usbhc_unregister_endpoint,
-	[IPC_M_USB_READ] = remote_usbhc_read,
-	[IPC_M_USB_WRITE] = remote_usbhc_write,
+	[IPC_M_USB_READ] = remote_usbhc_transfer,
+	[IPC_M_USB_WRITE] = remote_usbhc_transfer,
 };
 
@@ -290,5 +299,4 @@
 typedef struct {
 	ipc_callid_t caller;
-	ipc_callid_t data_caller;
 	void *buffer;
 } async_transaction_t;
@@ -413,5 +421,5 @@
 	}
 	if (trans->buffer != NULL) {
-		free(trans->buffer);
+		as_area_destroy(trans->buffer);
 	}
 
@@ -427,5 +435,4 @@
 
 	trans->caller = caller;
-	trans->data_caller = 0;
 	trans->buffer = NULL;
 
@@ -433,35 +440,38 @@
 }
 
-static int callback_out(void *arg, int error, size_t transferred_size)
+static errno_t transfer_finished(void *arg, int error, size_t transferred_size)
 {
 	async_transaction_t *trans = arg;
-
-	const int err = async_answer_0(trans->caller, error);
-
-	async_transaction_destroy(trans);
-
-	return err;
-}
-
-static int callback_in(void *arg, int error, size_t transferred_size)
-{
-	async_transaction_t *trans = arg;
-
-	if (trans->data_caller) {
-		if (error == EOK) {
-			error = async_data_read_finalize(trans->data_caller,
-			    trans->buffer, transferred_size);
-		} else {
-			async_answer_0(trans->data_caller, EINTR);
-		}
-	}
-
-	const int err = async_answer_0(trans->caller, error);
+	const errno_t err = async_answer_1(trans->caller, error, transferred_size);
 	async_transaction_destroy(trans);
 	return err;
 }
 
-void remote_usbhc_read(
-    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
+static errno_t receive_memory_buffer(async_transaction_t *trans,
+	size_t required_size, unsigned required_flags)
+{
+	assert(trans);
+	assert(required_size > 0);
+
+	errno_t err;
+	ipc_callid_t data_callid;
+	size_t size;
+	unsigned flags;
+
+	if (!async_share_out_receive(&data_callid, &size, &flags))
+		return EPARTY;
+
+	if (size < required_size || (flags & required_flags) != required_flags) {
+		async_answer_0(data_callid, EINVAL);
+		return EINVAL;
+	}
+
+	if ((err = async_share_out_finalize(data_callid, &trans->buffer)))
+		return err;
+
+	return EOK;
+}
+
+void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
 {
 	assert(fun);
@@ -471,13 +481,17 @@
 	const usbhc_iface_t *usbhc_iface = iface;
 
-	if (!usbhc_iface->read) {
+	if (!usbhc_iface->transfer) {
 		async_answer_0(callid, ENOTSUP);
 		return;
 	}
 
-	const usb_endpoint_t ep = DEV_IPC_GET_ARG1(*call);
-	const uint64_t setup =
-	    ((uint64_t)DEV_IPC_GET_ARG2(*call)) |
-	    (((uint64_t)DEV_IPC_GET_ARG3(*call)) << 32);
+	const sysarg_t method = IPC_GET_ARG1(*call);
+	const usb_direction_t dir =
+		method == IPC_M_USB_READ ? USB_DIRECTION_IN : USB_DIRECTION_OUT;
+
+	const usb_endpoint_t ep = IPC_GET_ARG2(*call);
+	const size_t size = IPC_GET_ARG3(*call);
+	const uint64_t setup = ((uint64_t)IPC_GET_ARG4(*call)) |
+	    (((uint64_t)IPC_GET_ARG5(*call)) << 32);
 
 	async_transaction_t *trans = async_transaction_create(callid);
@@ -487,68 +501,12 @@
 	}
 
-	size_t size = 0;
-	if (!async_data_read_receive(&trans->data_caller, &size)) {
-		async_answer_0(callid, EPARTY);
-		async_transaction_destroy(trans);
-		return;
-	}
-
-	trans->buffer = malloc(size);
-	if (trans->buffer == NULL) {
-		async_answer_0(trans->data_caller, ENOMEM);
-		async_answer_0(callid, ENOMEM);
-		async_transaction_destroy(trans);
-		return;
-	}
-
-	const usb_target_t target = {{
-		/* .address is initialized by read itself */
-		.endpoint = ep,
-	}};
-
-	const int rc = usbhc_iface->read(
-	    fun, target, setup, trans->buffer, size, callback_in, trans);
-
-	if (rc != EOK) {
-		async_answer_0(trans->data_caller, rc);
-		async_answer_0(callid, rc);
-		async_transaction_destroy(trans);
-	}
-}
-
-void remote_usbhc_write(
-    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
-{
-	assert(fun);
-	assert(iface);
-	assert(call);
-
-	const usbhc_iface_t *usbhc_iface = iface;
-
-	if (!usbhc_iface->write) {
-		async_answer_0(callid, ENOTSUP);
-		return;
-	}
-
-	const usb_endpoint_t ep = DEV_IPC_GET_ARG1(*call);
-	const size_t data_buffer_len = DEV_IPC_GET_ARG2(*call);
-	const uint64_t setup =
-	    ((uint64_t)DEV_IPC_GET_ARG3(*call)) |
-	    (((uint64_t)DEV_IPC_GET_ARG4(*call)) << 32);
-
-	async_transaction_t *trans = async_transaction_create(callid);
-	if (trans == NULL) {
-		async_answer_0(callid, ENOMEM);
-		return;
-	}
-
-	size_t size = 0;
-	if (data_buffer_len > 0) {
-		const int rc = async_data_write_accept(&trans->buffer, false,
-		    1, data_buffer_len, 0, &size);
-
+	if (size > 0) {
+		const unsigned required_flags = (dir == USB_DIRECTION_IN)
+			? AS_AREA_WRITE : AS_AREA_READ;
+
+		const errno_t rc = receive_memory_buffer(trans, size, required_flags);
 		if (rc != EOK) {
+			async_transaction_destroy(trans);
 			async_answer_0(callid, rc);
-			async_transaction_destroy(trans);
 			return;
 		}
@@ -562,6 +520,6 @@
 	}};
 
-	const int rc = usbhc_iface->write(
-	    fun, target, setup, trans->buffer, size, callback_out, trans);
+	const errno_t rc = usbhc_iface->transfer(fun, target, dir, setup,
+	    trans->buffer, size, &transfer_finished, trans);
 
 	if (rc != EOK) {
@@ -570,4 +528,5 @@
 	}
 }
+
 /**
  * @}
Index: uspace/lib/drv/generic/remote_usbhid.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhid.c	(revision 8393c73b627efedd36e9f17f530125baff7a47c6)
+++ uspace/lib/drv/generic/remote_usbhid.c	(revision 961a5ee6a39f4b63d8092b4429f5cd10fd784e2a)
@@ -94,8 +94,8 @@
  * @param dev_sess Session to DDF device providing USB HID interface.
  *
- * @return Number of usages returned or negative error code.
- *
- */
-int usbhid_dev_get_event_length(async_sess_t *dev_sess, size_t *size)
+ * @return Number of usages returned or an error code.
+ *
+ */
+errno_t usbhid_dev_get_event_length(async_sess_t *dev_sess, size_t *size)
 {
 	if (!dev_sess)
@@ -105,5 +105,5 @@
 	
 	sysarg_t len;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
 	    IPC_M_USBHID_GET_EVENT_LENGTH, &len);
 	
@@ -132,5 +132,5 @@
  *
  */
-int usbhid_dev_get_event(async_sess_t *dev_sess, uint8_t *buf,
+errno_t usbhid_dev_get_event(async_sess_t *dev_sess, uint8_t *buf,
     size_t size, size_t *actual_size, int *event_nr, unsigned int flags)
 {
@@ -174,6 +174,6 @@
 	}
 	
-	sysarg_t data_request_rc;
-	sysarg_t opening_request_rc;
+	errno_t data_request_rc;
+	errno_t opening_request_rc;
 	async_wait_for(data_request, &data_request_rc);
 	async_wait_for(opening_request, &opening_request_rc);
@@ -182,11 +182,11 @@
 		/* Prefer return code of the opening request. */
 		if (opening_request_rc != EOK)
-			return (int) opening_request_rc;
+			return (errno_t) opening_request_rc;
 		else
-			return (int) data_request_rc;
+			return (errno_t) data_request_rc;
 	}
 	
 	if (opening_request_rc != EOK)
-		return (int) opening_request_rc;
+		return (errno_t) opening_request_rc;
 	
 	size_t act_size = IPC_GET_ARG2(data_request_call);
@@ -204,5 +204,5 @@
 }
 
-int usbhid_dev_get_report_descriptor_length(async_sess_t *dev_sess,
+errno_t usbhid_dev_get_report_descriptor_length(async_sess_t *dev_sess,
     size_t *size)
 {
@@ -213,5 +213,5 @@
 	
 	sysarg_t arg_size;
-	int rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
+	errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
 	    IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size);
 	
@@ -226,5 +226,5 @@
 }
 
-int usbhid_dev_get_report_descriptor(async_sess_t *dev_sess, uint8_t *buf,
+errno_t usbhid_dev_get_report_descriptor(async_sess_t *dev_sess, uint8_t *buf,
     size_t size, size_t *actual_size)
 {
@@ -259,6 +259,6 @@
 	}
 	
-	sysarg_t data_request_rc;
-	sysarg_t opening_request_rc;
+	errno_t data_request_rc;
+	errno_t opening_request_rc;
 	async_wait_for(data_request, &data_request_rc);
 	async_wait_for(opening_request, &opening_request_rc);
@@ -267,11 +267,11 @@
 		/* Prefer return code of the opening request. */
 		if (opening_request_rc != EOK)
-			return (int) opening_request_rc;
+			return (errno_t) opening_request_rc;
 		else
-			return (int) data_request_rc;
+			return (errno_t) data_request_rc;
 	}
 	
 	if (opening_request_rc != EOK)
-		return (int) opening_request_rc;
+		return (errno_t) opening_request_rc;
 	
 	size_t act_size = IPC_GET_ARG2(data_request_call);
@@ -362,5 +362,5 @@
 	}
 
-	int rc;
+	errno_t rc;
 
 	uint8_t *data = malloc(len);
@@ -438,5 +438,5 @@
 
 	size_t act_len = 0;
-	int rc = hid_iface->get_report_descriptor(fun, descriptor, len,
+	errno_t rc = hid_iface->get_report_descriptor(fun, descriptor, len,
 	    &act_len);
 	if (act_len > len) {
