Index: uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -35,5 +35,5 @@
 #define DRV_UHCI_HW_STRUCT_LINK_POINTER_H
 
-/* UHCI link pointer, used by many data structures */
+/** UHCI link pointer, used by many data structures */
 typedef uint32_t link_pointer_t;
 
Index: uspace/drv/bus/usb/uhci/hw_struct/queue_head.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/queue_head.h	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/hw_struct/queue_head.h	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -58,6 +58,6 @@
 	assert(instance);
 
-	instance->element = 0 | LINK_POINTER_TERMINATE_FLAG;
-	instance->next = 0 | LINK_POINTER_TERMINATE_FLAG;
+	instance->element = LINK_POINTER_TERM;
+	instance->next = LINK_POINTER_TERM;
 }
 /*----------------------------------------------------------------------------*/
@@ -71,5 +71,8 @@
 static inline void qh_set_next_qh(qh_t *instance, qh_t *next)
 {
-	uint32_t pa = addr_to_phys(next);
+	/* Physical address has to be below 4GB,
+	 * it is an UHCI limitation and malloc32
+	 * should guarantee this */
+	const uint32_t pa = addr_to_phys(next);
 	if (pa) {
 		instance->next = LINK_POINTER_QH(pa);
@@ -88,5 +91,8 @@
 static inline void qh_set_element_td(qh_t *instance, td_t *td)
 {
-	uint32_t pa = addr_to_phys(td);
+	/* Physical address has to be below 4GB,
+	 * it is an UHCI limitation and malloc32
+	 * should guarantee this */
+	const uint32_t pa = addr_to_phys(td);
 	if (pa) {
 		instance->element = LINK_POINTER_TD(pa);
Index: uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -113,5 +113,5 @@
  * @return Error code.
  */
-int td_status(td_t *instance)
+int td_status(const td_t *instance)
 {
 	assert(instance);
@@ -119,5 +119,5 @@
 	/* This is hc internal error it should never be reported. */
 	if ((instance->status & TD_STATUS_ERROR_BIT_STUFF) != 0)
-		return EAGAIN;
+		return EIO;
 
 	/* CRC or timeout error, like device not present or bad data,
@@ -150,5 +150,5 @@
  * @param[in] instance TD structure to use.
  */
-void td_print_status(td_t *instance)
+void td_print_status(const td_t *instance)
 {
 	assert(instance);
Index: uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -69,5 +69,5 @@
 #define TD_STATUS_ACTLEN_MASK 0x7ff
 
-	/* double word with USB device specific info */
+	/** Double word with USB device specific info */
 	volatile uint32_t device;
 #define TD_DEVICE_MAXLEN_POS 21
@@ -87,6 +87,6 @@
 	/* According to UHCI design guide, there is 16 bytes of
 	 * data available here.
-	 * According to linux kernel the hardware does not care,
-	 * it just needs to be aligned. We don't use it anyway.
+	 * According to Linux kernel the hardware does not care,
+	 * memory just needs to be aligned. We don't use it anyway.
 	 */
 } __attribute__((packed)) td_t;
@@ -97,7 +97,7 @@
     const void *buffer, const td_t *next);
 
-int td_status(td_t *instance);
+int td_status(const td_t *instance);
 
-void td_print_status(td_t *instance);
+void td_print_status(const td_t *instance);
 /*----------------------------------------------------------------------------*/
 /** Helper function for parsing actual size out of TD.
@@ -106,8 +106,9 @@
  * @return Parsed actual size.
  */
-static inline size_t td_act_size(td_t *instance)
+static inline size_t td_act_size(const td_t *instance)
 {
 	assert(instance);
 	const uint32_t s = instance->status;
+	/* Actual size is encoded as n-1 (UHCI design guide p. 23) */
 	return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
 }
@@ -119,5 +120,5 @@
  * false otherwise.
  */
-static inline bool td_is_short(td_t *instance)
+static inline bool td_is_short(const td_t *instance)
 {
 	const size_t act_size = td_act_size(instance);
@@ -134,5 +135,5 @@
  * @return Toggle bit value.
  */
-static inline int td_toggle(td_t *instance)
+static inline int td_toggle(const td_t *instance)
 {
 	assert(instance);
@@ -145,5 +146,5 @@
  * @return Active bit value.
  */
-static inline bool td_is_active(td_t *instance)
+static inline bool td_is_active(const td_t *instance)
 {
 	assert(instance);
Index: uspace/drv/bus/usb/uhci/main.c
===================================================================
--- uspace/drv/bus/usb/uhci/main.c	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/main.c	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -64,13 +64,14 @@
 	assert(device);
 
-	int ret = device_setup_uhci(device);
+	const int ret = device_setup_uhci(device);
 	if (ret != EOK) {
 		usb_log_error("Failed to initialize UHCI driver: %s.\n",
 		    str_error(ret));
-		return ret;
+	} else {
+		usb_log_info("Controlling new UHCI device '%s'.\n",
+		    device->name);
 	}
-	usb_log_info("Controlling new UHCI device '%s'.\n", device->name);
 
-	return EOK;
+	return ret;
 }
 /*----------------------------------------------------------------------------*/
Index: uspace/drv/bus/usb/uhci/pci.c
===================================================================
--- uspace/drv/bus/usb/uhci/pci.c	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/pci.c	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -61,5 +61,5 @@
 	assert(io_reg_size);
 	assert(irq_no);
-	
+
 	async_sess_t *parent_sess =
 	    devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
@@ -67,5 +67,5 @@
 	if (!parent_sess)
 		return ENOMEM;
-	
+
 	hw_resource_list_t hw_resources;
 	int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
@@ -74,5 +74,5 @@
 		return rc;
 	}
-	
+
 	uintptr_t io_address = 0;
 	size_t io_size = 0;
@@ -102,17 +102,17 @@
 		}
 	}
-	
+
 	async_hangup(parent_sess);
-	
+
 	if (!io_found || !irq_found)
 		return ENOENT;
-	
+
 	*io_reg_address = io_address;
 	*io_reg_size = io_size;
 	*irq_no = irq;
-	
+
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Call the PCI driver with a request to enable interrupts
  *
@@ -127,11 +127,11 @@
 	if (!parent_sess)
 		return ENOMEM;
-	
+
 	const bool enabled = hw_res_enable_interrupt(parent_sess);
 	async_hangup(parent_sess);
-	
+
 	return enabled ? EOK : EIO;
 }
-
+/*----------------------------------------------------------------------------*/
 /** Call the PCI driver with a request to clear legacy support register
  *
Index: uspace/drv/bus/usb/uhci/root_hub.c
===================================================================
--- uspace/drv/bus/usb/uhci/root_hub.c	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/root_hub.c	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -50,14 +50,6 @@
 int rh_init(rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size)
 {
-	int ret;
-
+	assert(instance);
 	assert(fun);
-
-	ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
-	if (ret != EOK) {
-		usb_log_error("Failed to add root hub match id: %s\n",
-		    str_error(ret));
-		return ret;
-	}
 
 	/* Initialize resource structure */
@@ -70,5 +62,10 @@
 	instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN;
 
-	return EOK;
+	const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
+	if (ret != EOK) {
+		usb_log_error("Failed to add root hub match id: %s\n",
+		    str_error(ret));
+	}
+	return ret;
 }
 /**
Index: uspace/drv/bus/usb/uhci/uhci_batch.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_batch.c	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/uhci_batch.c	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -134,5 +134,5 @@
 	memcpy(dest, usb_batch->setup_buffer, usb_batch->setup_size);
 	dest += usb_batch->setup_size;
-	/* Copy generic data if unless they are provided by the device */
+	/* Copy generic data unless they are provided by the device */
 	if (usb_batch->ep->direction != USB_DIRECTION_IN) {
 		memcpy(dest, usb_batch->buffer, usb_batch->buffer_size);
@@ -142,4 +142,5 @@
 	    " memory structures ready.\n", usb_batch,
 	    USB_TRANSFER_BATCH_ARGS(*usb_batch));
+
 	assert(
 	    batch_setup[usb_batch->ep->transfer_type][usb_batch->ep->direction]);
@@ -215,10 +216,12 @@
 	assert(uhci_batch);
 	assert(uhci_batch->usb_batch);
+	assert(uhci_batch->usb_batch->ep);
+	assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT ||
+	    uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN);
+
 	static const usb_packet_id pids[] = {
 		[USB_DIRECTION_IN] = USB_PID_IN,
 		[USB_DIRECTION_OUT] = USB_PID_OUT,
 	};
-	assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT ||
-	    uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN);
 
 	const usb_packet_id pid = pids[uhci_batch->usb_batch->ep->direction];
Index: uspace/drv/bus/usb/uhci/uhci_batch.h
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_batch.h	(revision 1e647c7d81a68e2c939af34197e0de24a4c7014b)
+++ uspace/drv/bus/usb/uhci/uhci_batch.h	(revision 5d915b7301d1f95d873429460a51a3d45051c061)
@@ -64,23 +64,20 @@
 bool uhci_transfer_batch_is_complete(uhci_transfer_batch_t *uhci_batch);
 
+static inline void * uhci_transfer_batch_setup_buffer(
+    const uhci_transfer_batch_t *uhci_batch)
+{
+	assert(uhci_batch);
+	assert(uhci_batch->device_buffer);
+	return uhci_batch->device_buffer + sizeof(qh_t) +
+	    uhci_batch->td_count * sizeof(td_t);
+}
+/*----------------------------------------------------------------------------*/
 static inline void * uhci_transfer_batch_data_buffer(
-    uhci_transfer_batch_t *uhci_batch)
+    const uhci_transfer_batch_t *uhci_batch)
 {
 	assert(uhci_batch);
 	assert(uhci_batch->usb_batch);
-	assert(uhci_batch->device_buffer);
-	return uhci_batch->device_buffer + sizeof(qh_t) +
-	    uhci_batch->td_count * sizeof(td_t) +
+	return uhci_transfer_batch_setup_buffer(uhci_batch) +
 	    uhci_batch->usb_batch->setup_size;
-}
-/*----------------------------------------------------------------------------*/
-static inline void * uhci_transfer_batch_setup_buffer(
-    uhci_transfer_batch_t *uhci_batch)
-{
-	assert(uhci_batch);
-	assert(uhci_batch->usb_batch);
-	assert(uhci_batch->device_buffer);
-	return uhci_batch->device_buffer + sizeof(qh_t) +
-	    uhci_batch->td_count * sizeof(td_t);
 }
 /*----------------------------------------------------------------------------*/
