Index: uspace/drv/bus/pci/pciintel/pci.c
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.c	(revision 88dfee72b892efbc89d6fc68db4a2e3de85ea013)
+++ uspace/drv/bus/pci/pciintel/pci.c	(revision 2df6f6fe4f21b8f1ebefce19a6d94cd3137976f0)
@@ -92,5 +92,5 @@
 static bool pciintel_enable_interrupt(ddf_fun_t *fnode)
 {
-	/* This is an old ugly way, copied from ne2000 driver */
+	/* This is an old ugly way */
 	assert(fnode);
 	pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data;
Index: uspace/drv/char/i8042/buffer.h
===================================================================
--- uspace/drv/char/i8042/buffer.h	(revision 88dfee72b892efbc89d6fc68db4a2e3de85ea013)
+++ uspace/drv/char/i8042/buffer.h	(revision 2df6f6fe4f21b8f1ebefce19a6d94cd3137976f0)
@@ -26,8 +26,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /**
  * @addtogroup kbd
  * @{
  */
+
 /** @file
  * @brief Cyclic buffer structure.
@@ -46,22 +48,26 @@
  * Attempt to insert byte into the full buffer will block until it can succeed.
  * Attempt to read from empty buffer will block until it can succeed.
+ *
  */
 typedef struct {
-	uint8_t *buffer;         /**< Storage space. */
-	uint8_t *buffer_end;     /**< End of storage place. */
-	fibril_mutex_t guard;    /**< Protects buffer structures. */
-	fibril_condvar_t change; /**< Indicates change (empty/full). */
-	uint8_t *read_head;      /**< Place of the next readable element. */
-	uint8_t *write_head;     /**< Pointer to the next writable place. */
+	uint8_t *buffer;          /**< Storage space. */
+	uint8_t *buffer_end;      /**< End of storage place. */
+	fibril_mutex_t guard;     /**< Protects buffer structures. */
+	fibril_condvar_t change;  /**< Indicates change (empty/full). */
+	uint8_t *read_head;       /**< Place of the next readable element. */
+	uint8_t *write_head;      /**< Pointer to the next writable place. */
 } buffer_t;
 
 /** Initialize cyclic buffer using provided memory space.
+ *
  * @param buffer Cyclic buffer structure to initialize.
- * @param data Memory space to use.
- * @param size Size of the memory place.
+ * @param data   Memory space to use.
+ * @param size   Size of the memory place.
+ *
  */
 static inline void buffer_init(buffer_t *buffer, uint8_t *data, size_t size)
 {
 	assert(buffer);
+	
 	fibril_mutex_initialize(&buffer->guard);
 	fibril_condvar_initialize(&buffer->change);
@@ -74,27 +80,29 @@
 
 /** Write byte to cyclic buffer.
+ *
  * @param buffer Cyclic buffer to write to.
- * @param data Data to write.
+ * @param data   Data to write.
+ *
  */
 static inline void buffer_write(buffer_t *buffer, uint8_t data)
 {
 	fibril_mutex_lock(&buffer->guard);
-
+	
 	/* Next position. */
 	uint8_t *new_head = buffer->write_head + 1;
 	if (new_head == buffer->buffer_end)
 		new_head = buffer->buffer;
-
+	
 	/* Buffer full. */
 	while (new_head == buffer->read_head)
 		fibril_condvar_wait(&buffer->change, &buffer->guard);
-
+	
 	/* Write data. */
 	*buffer->write_head = data;
-
+	
 	/* Buffer was empty. */
 	if (buffer->write_head == buffer->read_head)
 		fibril_condvar_broadcast(&buffer->change);
-
+	
 	/* Move head */
 	buffer->write_head = new_head;
@@ -103,22 +111,26 @@
 
 /** Read byte from cyclic buffer.
+ *
  * @param buffer Cyclic buffer to read from.
+ *
  * @return Byte read.
+ *
  */
 static inline uint8_t buffer_read(buffer_t *buffer)
 {
 	fibril_mutex_lock(&buffer->guard);
+	
 	/* Buffer is empty. */
 	while (buffer->write_head == buffer->read_head)
 		fibril_condvar_wait(&buffer->change, &buffer->guard);
-
+	
 	/* Next position. */
 	uint8_t *new_head = buffer->read_head + 1;
 	if (new_head == buffer->buffer_end)
 		new_head = buffer->buffer;
-
+	
 	/* Read data. */
 	const uint8_t data = *buffer->read_head;
-
+	
 	/* Buffer was full. */
 	uint8_t *new_write_head = buffer->write_head + 1;
@@ -127,12 +139,14 @@
 	if (new_write_head == buffer->read_head)
 		fibril_condvar_broadcast(&buffer->change);
-
+	
 	/* Move head */
 	buffer->read_head = new_head;
-
+	
 	fibril_mutex_unlock(&buffer->guard);
 	return data;
 }
+
 #endif
+
 /**
  * @}
Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision 88dfee72b892efbc89d6fc68db4a2e3de85ea013)
+++ uspace/drv/char/i8042/i8042.c	(revision 2df6f6fe4f21b8f1ebefce19a6d94cd3137976f0)
@@ -29,8 +29,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /** @addtogroup kbd_port
  * @ingroup kbd
  * @{
  */
+
 /** @file
  * @brief i8042 PS/2 port driver.
@@ -44,11 +46,55 @@
 #include <str_error.h>
 #include <inttypes.h>
-
 #include <ddf/log.h>
 #include <ddf/interrupt.h>
-
 #include "i8042.h"
 
-#define NAME       "i8042"
+/* Interesting bits for status register */
+#define i8042_OUTPUT_FULL  0x01
+#define i8042_INPUT_FULL   0x02
+#define i8042_AUX_DATA     0x20
+
+/* Command constants */
+#define i8042_CMD_WRITE_CMDB  0x60  /**< Write command byte */
+#define i8042_CMD_WRITE_AUX   0xd4  /**< Write aux device */
+
+/* Command byte fields */
+#define i8042_KBD_IE         0x01
+#define i8042_AUX_IE         0x02
+#define i8042_KBD_DISABLE    0x10
+#define i8042_AUX_DISABLE    0x20
+#define i8042_KBD_TRANSLATE  0x40  /* Use this to switch to XT scancodes */
+
+#define CHECK_RET_DESTROY(ret, msg...) \
+	do { \
+		if (ret != EOK) { \
+			ddf_msg(LVL_ERROR, msg); \
+			if (dev->kbd_fun) { \
+				dev->kbd_fun->driver_data = NULL; \
+				ddf_fun_destroy(dev->kbd_fun); \
+			} \
+			if (dev->aux_fun) { \
+				dev->aux_fun->driver_data = NULL; \
+				ddf_fun_destroy(dev->aux_fun); \
+			} \
+		} \
+	} while (0)
+
+#define CHECK_RET_UNBIND_DESTROY(ret, msg...) \
+	do { \
+		if (ret != EOK) { \
+			ddf_msg(LVL_ERROR, msg); \
+			if (dev->kbd_fun) { \
+				ddf_fun_unbind(dev->kbd_fun); \
+				dev->kbd_fun->driver_data = NULL; \
+				ddf_fun_destroy(dev->kbd_fun); \
+			} \
+			if (dev->aux_fun) { \
+				ddf_fun_unbind(dev->aux_fun); \
+				dev->aux_fun->driver_data = NULL; \
+				ddf_fun_destroy(dev->aux_fun); \
+			} \
+		} \
+	} while (0)
 
 void default_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
@@ -59,25 +105,9 @@
 };
 
-/* Interesting bits for status register */
-#define i8042_OUTPUT_FULL	0x01
-#define i8042_INPUT_FULL	0x02
-#define i8042_AUX_DATA		0x20
-
-/* Command constants */
-#define i8042_CMD_WRITE_CMDB	0x60	/**< write command byte */
-#define i8042_CMD_WRITE_AUX	0xd4	/**< write aux device */
-
-/* Command byte fields */
-#define i8042_KBD_IE		0x01
-#define i8042_AUX_IE		0x02
-#define i8042_KBD_DISABLE	0x10
-#define i8042_AUX_DISABLE	0x20
-#define i8042_KBD_TRANSLATE	0x40 /* Use this to switch to XT scancodes */
-
 /** i8042 Interrupt pseudo-code. */
 static const irq_cmd_t i8042_cmds[] = {
 	{
 		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,	/* will be patched in run-time */
+		.addr = NULL,  /* will be patched in run-time */
 		.dstarg = 1
 	},
@@ -95,5 +125,5 @@
 	{
 		.cmd = CMD_PIO_READ_8,
-		.addr = NULL,	/* will be patched in run-time */
+		.addr = NULL,  /* will be patched in run-time */
 		.dstarg = 2
 	},
@@ -111,31 +141,40 @@
 
 /** Interrupt handler routine.
- * Writes new data to the corresponding buffer.
- * @param dev Device that caued the interrupt.
- * @param iid Call id.
+ *
+ * Write new data to the corresponding buffer.
+ *
+ * @param dev  Device that caued the interrupt.
+ * @param iid  Call id.
  * @param call pointerr to call data.
- */
-static void i8042_irq_handler(
-    ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
-{
-	if (!dev || !dev->driver_data)
+ *
+ */
+static void i8042_irq_handler(ddf_dev_t *dev, ipc_callid_t iid,
+    ipc_call_t *call)
+{
+	if ((!dev) || (!dev->driver_data))
 		return;
+	
 	i8042_t *controller = dev->driver_data;
-
+	
 	const uint8_t status = IPC_GET_ARG1(*call);
 	const uint8_t data = IPC_GET_ARG2(*call);
+	
 	buffer_t *buffer = (status & i8042_AUX_DATA) ?
 	    &controller->aux_buffer : &controller->kbd_buffer;
+	
 	buffer_write(buffer, data);
 }
 
 /** Initialize i8042 driver structure.
- * @param dev Driver structure to initialize.
- * @param regs I/O address of registers.
- * @param reg_size size of the reserved I/O address space.
- * @param irq_kbd IRQ for primary port.
+ *
+ * @param dev       Driver structure to initialize.
+ * @param regs      I/O address of registers.
+ * @param reg_size  size of the reserved I/O address space.
+ * @param irq_kbd   IRQ for primary port.
  * @param irq_mouse IRQ for aux port.
- * @param ddf_dev DDF device structure of the device.
+ * @param ddf_dev   DDF device structure of the device.
+ *
  * @return Error code.
+ *
  */
 int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd,
@@ -144,14 +183,15 @@
 	assert(ddf_dev);
 	assert(dev);
-
+	
 	if (reg_size < sizeof(i8042_regs_t))
 		return EINVAL;
-
-	if (pio_enable(regs, sizeof(i8042_regs_t), (void**)&dev->regs) != 0)
+	
+	if (pio_enable(regs, sizeof(i8042_regs_t), (void **) &dev->regs) != 0)
 		return -1;
-
+	
 	dev->kbd_fun = ddf_fun_create(ddf_dev, fun_inner, "ps2a");
 	if (!dev->kbd_fun)
 		return ENOMEM;
+	
 	int ret = ddf_fun_add_match_id(dev->kbd_fun, "char/xtkbd", 90);
 	if (ret != EOK) {
@@ -159,5 +199,5 @@
 		return ret;
 	}
-
+	
 	dev->aux_fun = ddf_fun_create(ddf_dev, fun_inner, "ps2b");
 	if (!dev->aux_fun) {
@@ -165,5 +205,5 @@
 		return ENOMEM;
 	}
-
+	
 	ret = ddf_fun_add_match_id(dev->aux_fun, "char/ps2mouse", 90);
 	if (ret != EOK) {
@@ -172,35 +212,22 @@
 		return ret;
 	}
-
+	
 	dev->kbd_fun->ops = &ops;
 	dev->aux_fun->ops = &ops;
 	dev->kbd_fun->driver_data = dev;
 	dev->aux_fun->driver_data = dev;
-
+	
 	buffer_init(&dev->kbd_buffer, dev->kbd_data, BUFFER_SIZE);
 	buffer_init(&dev->aux_buffer, dev->aux_data, BUFFER_SIZE);
 	fibril_mutex_initialize(&dev->write_guard);
-
-#define CHECK_RET_DESTROY(ret, msg...) \
-if  (ret != EOK) { \
-	ddf_msg(LVL_ERROR, msg); \
-	if (dev->kbd_fun) { \
-		dev->kbd_fun->driver_data = NULL; \
-		ddf_fun_destroy(dev->kbd_fun); \
-	} \
-	if (dev->aux_fun) { \
-		dev->aux_fun->driver_data = NULL; \
-		ddf_fun_destroy(dev->aux_fun); \
-	} \
-} else (void)0
-
+	
 	ret = ddf_fun_bind(dev->kbd_fun);
-	CHECK_RET_DESTROY(ret,
-	    "Failed to bind keyboard function: %s.", str_error(ret));
-
+	CHECK_RET_DESTROY(ret, "Failed to bind keyboard function: %s.",
+	    str_error(ret));
+	
 	ret = ddf_fun_bind(dev->aux_fun);
-	CHECK_RET_DESTROY(ret,
-	    "Failed to bind mouse function: %s.", str_error(ret));
-
+	CHECK_RET_DESTROY(ret, "Failed to bind mouse function: %s.",
+	    str_error(ret));
+	
 	/* Disable kbd and aux */
 	wait_ready(dev);
@@ -208,24 +235,9 @@
 	wait_ready(dev);
 	pio_write_8(&dev->regs->data, i8042_KBD_DISABLE | i8042_AUX_DISABLE);
-
+	
 	/* Flush all current IO */
 	while (pio_read_8(&dev->regs->status) & i8042_OUTPUT_FULL)
 		(void) pio_read_8(&dev->regs->data);
-
-#define CHECK_RET_UNBIND_DESTROY(ret, msg...) \
-if  (ret != EOK) { \
-	ddf_msg(LVL_ERROR, msg); \
-	if (dev->kbd_fun) { \
-		ddf_fun_unbind(dev->kbd_fun); \
-		dev->kbd_fun->driver_data = NULL; \
-		ddf_fun_destroy(dev->kbd_fun); \
-	} \
-	if (dev->aux_fun) { \
-		ddf_fun_unbind(dev->aux_fun); \
-		dev->aux_fun->driver_data = NULL; \
-		ddf_fun_destroy(dev->aux_fun); \
-	} \
-} else (void)0
-
+	
 	const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t);
 	irq_cmd_t cmds[cmd_count];
@@ -233,16 +245,20 @@
 	cmds[0].addr = (void *) &dev->regs->status;
 	cmds[3].addr = (void *) &dev->regs->data;
-
-	irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = cmds };
+	
+	irq_code_t irq_code = {
+		.cmdcount = cmd_count,
+		.cmds = cmds
+	};
+	
 	ret = register_interrupt_handler(ddf_dev, irq_kbd, i8042_irq_handler,
 	    &irq_code);
-	CHECK_RET_UNBIND_DESTROY(ret,
-	    "Failed set handler for kbd: %s.", str_error(ret));
-
+	CHECK_RET_UNBIND_DESTROY(ret, "Failed set handler for kbd: %s.",
+	    str_error(ret));
+	
 	ret = register_interrupt_handler(ddf_dev, irq_mouse, i8042_irq_handler,
 	    &irq_code);
-	CHECK_RET_UNBIND_DESTROY(ret,
-	    "Failed set handler for mouse: %s.", str_error(ret));
-
+	CHECK_RET_UNBIND_DESTROY(ret, "Failed set handler for mouse: %s.",
+	    str_error(ret));
+	
 	/* Enable interrupts */
 	async_sess_t *parent_sess =
@@ -251,10 +267,10 @@
 	ret = parent_sess ? EOK : ENOMEM;
 	CHECK_RET_UNBIND_DESTROY(ret, "Failed to create parent connection.");
-
+	
 	const bool enabled = hw_res_enable_interrupt(parent_sess);
 	async_hangup(parent_sess);
 	ret = enabled ? EOK : EIO;
 	CHECK_RET_UNBIND_DESTROY(ret, "Failed to enable interrupts: %s.");
-
+	
 	/* Enable port interrupts. */
 	wait_ready(dev);
@@ -263,9 +279,9 @@
 	pio_write_8(&dev->regs->data, i8042_KBD_IE | i8042_KBD_TRANSLATE |
 	    i8042_AUX_IE);
-
+	
 	return EOK;
 }
 
-// TODO use shared instead this
+// FIXME TODO use shared instead this
 enum {
 	IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
@@ -274,8 +290,11 @@
 
 /** Write data to i8042 port.
- * @param fun DDF function.
+ *
+ * @param fun    DDF function.
  * @param buffer Data source.
- * @param size Data size.
+ * @param size   Data size.
+ *
  * @return Bytes written.
+ *
  */
 static int i8042_write(ddf_fun_t *fun, char *buffer, size_t size)
@@ -283,13 +302,18 @@
 	assert(fun);
 	assert(fun->driver_data);
+	
 	i8042_t *controller = fun->driver_data;
 	fibril_mutex_lock(&controller->write_guard);
+	
 	for (size_t i = 0; i < size; ++i) {
 		wait_ready(controller);
+		
 		if (controller->aux_fun == fun)
-			pio_write_8(
-			    &controller->regs->status, i8042_CMD_WRITE_AUX);
+			pio_write_8(&controller->regs->status,
+			    i8042_CMD_WRITE_AUX);
+		
 		pio_write_8(&controller->regs->data, buffer[i]);
 	}
+	
 	fibril_mutex_unlock(&controller->write_guard);
 	return size;
@@ -297,8 +321,11 @@
 
 /** Read data from i8042 port.
- * @param fun DDF function.
+ *
+ * @param fun    DDF function.
  * @param buffer Data place.
- * @param size Data place size.
+ * @param size   Data place size.
+ *
  * @return Bytes read.
+ *
  */
 static int i8042_read(ddf_fun_t *fun, char *data, size_t size)
@@ -306,18 +333,21 @@
 	assert(fun);
 	assert(fun->driver_data);
-
+	
 	i8042_t *controller = fun->driver_data;
 	buffer_t *buffer = (fun == controller->aux_fun) ?
 	    &controller->aux_buffer : &controller->kbd_buffer;
-	for (size_t i = 0; i < size; ++i) {
+	
+	for (size_t i = 0; i < size; ++i)
 		*data++ = buffer_read(buffer);
-	}
+	
 	return size;
 }
 
 /** Handle data requests.
- * @param fun ddf_fun_t function.
- * @param id callid
+ *
+ * @param fun  ddf_fun_t function.
+ * @param id   callid
  * @param call IPC request.
+ *
  */
 void default_handler(ddf_fun_t *fun, ipc_callid_t id, ipc_call_t *call)
@@ -325,31 +355,35 @@
 	const sysarg_t method = IPC_GET_IMETHOD(*call);
 	const size_t size = IPC_GET_ARG1(*call);
+	
 	switch (method) {
 	case IPC_CHAR_READ:
 		if (size <= 4 * sizeof(sysarg_t)) {
 			sysarg_t message[4] = {};
-			i8042_read(fun, (char*)message, size);
+			
+			i8042_read(fun, (char *) message, size);
 			async_answer_4(id, size, message[0], message[1],
 			    message[2], message[3]);
-		} else {
+		} else
 			async_answer_0(id, ELIMIT);
-		}
 		break;
-
+	
 	case IPC_CHAR_WRITE:
 		if (size <= 3 * sizeof(sysarg_t)) {
 			const sysarg_t message[3] = {
-				IPC_GET_ARG2(*call), IPC_GET_ARG3(*call),
-				IPC_GET_ARG4(*call) };
-			i8042_write(fun, (char*)message, size);
+				IPC_GET_ARG2(*call),
+				IPC_GET_ARG3(*call),
+				IPC_GET_ARG4(*call)
+			};
+			
+			i8042_write(fun, (char *) message, size);
 			async_answer_0(id, size);
-		} else {
+		} else
 			async_answer_0(id, ELIMIT);
-		}
-
+	
 	default:
 		async_answer_0(id, EINVAL);
 	}
 }
+
 /**
  * @}
Index: uspace/drv/char/i8042/i8042.h
===================================================================
--- uspace/drv/char/i8042/i8042.h	(revision 88dfee72b892efbc89d6fc68db4a2e3de85ea013)
+++ uspace/drv/char/i8042/i8042.h	(revision 2df6f6fe4f21b8f1ebefce19a6d94cd3137976f0)
@@ -27,8 +27,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /** @addtogroup kbd_port
  * @ingroup  kbd
  * @{
  */
+
 /** @file
  * @brief i8042 port driver.
@@ -41,8 +43,9 @@
 #include <fibril_synch.h>
 #include <ddf/driver.h>
-
 #include "buffer.h"
 
-#define BUFFER_SIZE 12
+#define NAME  "i8042"
+
+#define BUFFER_SIZE  12
 
 /** i8042 HW I/O interface */
@@ -55,9 +58,9 @@
 /** i8042 driver structure. */
 typedef struct i8042 {
-	i8042_regs_t *regs;    /**< I/O registers. */
-	ddf_fun_t *kbd_fun;    /**< Pirmary port device function. */
-	ddf_fun_t *aux_fun;  /**< Auxiliary port device function. */
-	buffer_t kbd_buffer;   /**< Primary port buffer. */
-	buffer_t aux_buffer;   /**< Aux. port buffer. */
+	i8042_regs_t *regs;             /**< I/O registers. */
+	ddf_fun_t *kbd_fun;             /**< Pirmary port device function. */
+	ddf_fun_t *aux_fun;             /**< Auxiliary port device function. */
+	buffer_t kbd_buffer;            /**< Primary port buffer. */
+	buffer_t aux_buffer;            /**< Aux. port buffer. */
 	uint8_t aux_data[BUFFER_SIZE];  /**< Primary port buffer space. */
 	uint8_t kbd_data[BUFFER_SIZE];  /**< Aux. port buffer space. */
@@ -66,5 +69,7 @@
 
 int i8042_init(i8042_t *, void *, size_t, int, int, ddf_dev_t *);
+
 #endif
+
 /**
  * @}
Index: uspace/drv/char/i8042/main.c
===================================================================
--- uspace/drv/char/i8042/main.c	(revision 88dfee72b892efbc89d6fc68db4a2e3de85ea013)
+++ uspace/drv/char/i8042/main.c	(revision 2df6f6fe4f21b8f1ebefce19a6d94cd3137976f0)
@@ -26,7 +26,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /** @addtogroup drvi8042
  * @{
  */
+
 /** @file
  * @brief i8042 driver DDF bits.
@@ -41,12 +43,100 @@
 #include <ddf/log.h>
 #include <stdio.h>
-
 #include "i8042.h"
 
-#define NAME "i8042"
+#define CHECK_RET_RETURN(ret, message...) \
+	do { \
+		if (ret != EOK) { \
+			ddf_msg(LVL_ERROR, message); \
+			return ret; \
+		} \
+	} while (0)
 
-static int get_my_registers(const ddf_dev_t *dev,
-    uintptr_t *io_reg_address, size_t *io_reg_size, int *kbd, int *mouse);
-static int i8042_dev_add(ddf_dev_t *device);
+/** Get address of I/O registers.
+ *
+ * @param[in]  dev            Device asking for the addresses.
+ * @param[out] io_reg_address Base address of the memory range.
+ * @param[out] io_reg_size    Size of the memory range.
+ * @param[out] kbd_irq        Primary port IRQ.
+ * @param[out] mouse_irq      Auxiliary port IRQ.
+ *
+ * @return Error code.
+ *
+ */
+static int get_my_registers(const ddf_dev_t *dev, uintptr_t *io_reg_address,
+    size_t *io_reg_size, int *kbd_irq, int *mouse_irq)
+{
+	assert(dev);
+	
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
+	    IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+	
+	hw_res_list_parsed_t hw_resources;
+	hw_res_list_parsed_init(&hw_resources);
+	const int ret = hw_res_get_list_parsed(parent_sess, &hw_resources, 0);
+	async_hangup(parent_sess);
+	if (ret != EOK)
+		return ret;
+	
+	if ((hw_resources.irqs.count != 2) ||
+	    (hw_resources.io_ranges.count != 1)) {
+		hw_res_list_parsed_clean(&hw_resources);
+		return EINVAL;
+	}
+	
+	if (io_reg_address)
+		*io_reg_address = hw_resources.io_ranges.ranges[0].address;
+	
+	if (io_reg_size)
+		*io_reg_size = hw_resources.io_ranges.ranges[0].size;
+	
+	if (kbd_irq)
+		*kbd_irq = hw_resources.irqs.irqs[0];
+	
+	if (mouse_irq)
+		*mouse_irq = hw_resources.irqs.irqs[1];
+	
+	hw_res_list_parsed_clean(&hw_resources);
+	return EOK;
+}
+
+/** Initialize a new ddf driver instance of i8042 driver
+ *
+ * @param[in] device DDF instance of the device to initialize.
+ *
+ * @return Error code.
+ *
+ */
+static int i8042_dev_add(ddf_dev_t *device)
+{
+	if (!device)
+		return EINVAL;
+	
+	uintptr_t io_regs = 0;
+	size_t io_size = 0;
+	int kbd = 0;
+	int mouse = 0;
+	
+	int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
+	CHECK_RET_RETURN(ret, "Failed to get registers: %s.",
+	    str_error(ret));
+	ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
+	    (void *) io_regs, io_size, kbd, mouse);
+	
+	i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t));
+	ret = (i8042 == NULL) ? ENOMEM : EOK;
+	CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance.");
+	
+	ret = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);
+	CHECK_RET_RETURN(ret, "Failed to initialize i8042 driver: %s.",
+	    str_error(ret));
+	
+	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
+	    device->name, device->handle);
+	return EOK;
+}
 
 /** DDF driver operations. */
@@ -61,107 +151,11 @@
 };
 
-/** Initialize global driver structures (NONE).
- *
- * @param[in] argc Nmber of arguments in argv vector (ignored).
- * @param[in] argv Cmdline argument vector (ignored).
- * @return Error code.
- *
- * Driver debug level is set here.
- */
 int main(int argc, char *argv[])
 {
-	printf(NAME ": HelenOS ps/2 driver.\n");
+	printf("%s: HelenOS PS/2 driver.\n", NAME);
 	ddf_log_init(NAME, LVL_NOTE);
 	return ddf_driver_main(&i8042_driver);
 }
 
-/** Initialize a new ddf driver instance of i8042 driver
- *
- * @param[in] device DDF instance of the device to initialize.
- * @return Error code.
- */
-static int i8042_dev_add(ddf_dev_t *device)
-{
-	if (!device)
-		return EINVAL;
-
-#define CHECK_RET_RETURN(ret, message...) \
-if (ret != EOK) { \
-	ddf_msg(LVL_ERROR, message); \
-	return ret; \
-} else (void)0
-
-	uintptr_t io_regs = 0;
-	size_t io_size = 0;
-	int kbd = 0, mouse = 0;
-
-	int ret = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
-	CHECK_RET_RETURN(ret,
-	    "Failed to get registers: %s.", str_error(ret));
-	ddf_msg(LVL_DEBUG,
-	    "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
-	    (void *) io_regs, io_size, kbd, mouse);
-
-	i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t));
-	ret = (i8042 == NULL) ? ENOMEM : EOK;
-	CHECK_RET_RETURN(ret, "Failed to allocate i8042 driver instance.");
-
-	ret = i8042_init(i8042, (void*)io_regs, io_size, kbd, mouse, device);
-	CHECK_RET_RETURN(ret,
-	    "Failed to initialize i8042 driver: %s.", str_error(ret));
-
-	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
-	    device->name, device->handle);
-	return EOK;
-}
-
-/** Get address of I/O registers.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] io_reg_address Base address of the memory range.
- * @param[out] io_reg_size Size of the memory range.
- * @param[out] kbd_irq Primary port IRQ.
- * @param[out] mouse_irq Auxiliary port IRQ.
- * @return Error code.
- */
-int get_my_registers(const ddf_dev_t *dev, uintptr_t *io_reg_address,
-    size_t *io_reg_size, int *kbd_irq, int *mouse_irq)
-{
-	assert(dev);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
-	    IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_resources;
-	hw_res_list_parsed_init(&hw_resources);
-	const int ret = hw_res_get_list_parsed(parent_sess, &hw_resources, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	if (hw_resources.irqs.count != 2 || hw_resources.io_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_resources);
-		return EINVAL;
-	}
-
-	if (io_reg_address)
-		*io_reg_address = hw_resources.io_ranges.ranges[0].address;
-
-	if (io_reg_size)
-		*io_reg_size = hw_resources.io_ranges.ranges[0].size;
-
-	if (kbd_irq)
-		*kbd_irq = hw_resources.irqs.irqs[0];
-
-	if (mouse_irq)
-		*mouse_irq = hw_resources.irqs.irqs[1];
-
-	hw_res_list_parsed_clean(&hw_resources);
-	return EOK;
-}
 /**
  * @}
