Index: uspace/drv/uhci-hcd/Makefile
===================================================================
--- uspace/drv/uhci-hcd/Makefile	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/Makefile	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -40,5 +40,5 @@
 	uhci_struct/transfer_descriptor.c \
 	pci.c \
-	tracker.c
+	batch.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/uhci-hcd/batch.c
===================================================================
--- uspace/drv/uhci-hcd/batch.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
+++ uspace/drv/uhci-hcd/batch.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#include <errno.h>
+
+#include <usb/debug.h>
+
+#include "batch.h"
+#include "transfer_list.h"
+#include "uhci.h"
+#include "utils/malloc32.h"
+
+#define DEFAULT_ERROR_COUNT 3
+
+static int batch_schedule(batch_t *instance);
+
+static void batch_call_in(batch_t *instance);
+static void batch_call_out(batch_t *instance);
+static void batch_call_in_and_dispose(batch_t *instance);
+static void batch_call_out_and_dispose(batch_t *instance);
+
+
+batch_t * batch_get(device_t *dev, usb_target_t target,
+    usb_transfer_type_t transfer_type, size_t max_packet_size,
+    dev_speed_t speed, char *buffer, size_t size,
+    char* setup_buffer, size_t setup_size,
+    usbhc_iface_transfer_in_callback_t func_in,
+    usbhc_iface_transfer_out_callback_t func_out, void *arg)
+{
+	assert(func_in == NULL || func_out == NULL);
+	assert(func_in != NULL || func_out != NULL);
+
+	batch_t *instance = malloc(sizeof(batch_t));
+	if (instance == NULL) {
+		usb_log_error("Failed to allocate batch instance.\n");
+		return NULL;
+	}
+
+	instance->qh = queue_head_get();
+	if (instance->qh == NULL) {
+		usb_log_error("Failed to allocate queue head.\n");
+		free(instance);
+		return NULL;
+	}
+
+	instance->packets = (size + max_packet_size - 1) / max_packet_size;
+	if (transfer_type == USB_TRANSFER_CONTROL) {
+		instance->packets += 2;
+	}
+
+	instance->tds = malloc32(sizeof(transfer_descriptor_t) * instance->packets);
+	if (instance->tds == NULL) {
+		usb_log_error("Failed to allocate transfer descriptors.\n");
+		queue_head_dispose(instance->qh);
+		free(instance);
+		return NULL;
+	}
+	bzero(instance->tds, sizeof(transfer_descriptor_t) * instance->packets);
+
+	const size_t transport_size = max_packet_size * instance->packets;
+
+	instance->transport_buffer =
+	   (size > 0) ? malloc32(transport_size) : NULL;
+	if ((size > 0) && (instance->transport_buffer == NULL)) {
+		usb_log_error("Failed to allocate device accessible buffer.\n");
+		queue_head_dispose(instance->qh);
+		free32(instance->tds);
+		free(instance);
+		return NULL;
+	}
+
+	instance->setup_buffer = setup_buffer ? malloc32(setup_size) : NULL;
+	if ((setup_size > 0) && (instance->setup_buffer == NULL)) {
+		usb_log_error("Failed to allocate device accessible setup buffer.\n");
+		queue_head_dispose(instance->qh);
+		free32(instance->tds);
+		free32(instance->transport_buffer);
+		free(instance);
+		return NULL;
+	}
+	if (instance->setup_buffer) {
+		memcpy(instance->setup_buffer, setup_buffer, setup_size);
+	}
+
+	instance->max_packet_size = max_packet_size;
+
+	link_initialize(&instance->link);
+
+	instance->target = target;
+	instance->transfer_type = transfer_type;
+
+	if (func_out)
+		instance->callback_out = func_out;
+	if (func_in)
+		instance->callback_in = func_in;
+
+	instance->buffer = buffer;
+	instance->buffer_size = size;
+	instance->setup_size = setup_size;
+	instance->dev = dev;
+	instance->arg = arg;
+	instance->speed = speed;
+
+	queue_head_element_td(instance->qh, addr_to_phys(instance->tds));
+	return instance;
+}
+/*----------------------------------------------------------------------------*/
+bool batch_is_complete(batch_t *instance)
+{
+	assert(instance);
+	usb_log_debug("Checking(%p) %d packet for completion.\n",
+	    instance, instance->packets);
+	/* This is just an ugly trick to support the old API */
+	instance->transfered_size = 0;
+	size_t i = 0;
+	for (;i < instance->packets; ++i) {
+		if (transfer_descriptor_is_active(&instance->tds[i])) {
+			return false;
+		}
+		instance->error = transfer_descriptor_status(&instance->tds[i]);
+		if (instance->error != EOK) {
+			if (i > 0)
+				instance->transfered_size -= instance->setup_size;
+			return true;
+		}
+		instance->transfered_size +=
+		    transfer_descriptor_actual_size(&instance->tds[i]);
+	}
+	instance->transfered_size -= instance->setup_size;
+	return true;
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_write(batch_t *instance)
+{
+	assert(instance);
+
+	/* we are data out, we are supposed to provide data */
+	memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
+
+	int toggle = 0;
+	/* setup stage */
+	transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
+	    instance->setup_size, toggle, false, instance->target,
+	    USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
+
+	/* data stage */
+	size_t i = 1;
+	for (;i < instance->packets - 1; ++i) {
+		char *data =
+		    instance->transport_buffer + ((i - 1) * instance->max_packet_size);
+		toggle = 1 - toggle;
+
+		transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+		    instance->max_packet_size, toggle++, false, instance->target,
+		    USB_PID_OUT, data, &instance->tds[i + 1]);
+	}
+
+	/* status stage */
+	i = instance->packets - 1;
+	transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+	    0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
+
+	instance->next_step = batch_call_out_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_read(batch_t *instance)
+{
+	assert(instance);
+
+	int toggle = 0;
+	/* setup stage */
+	transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
+	    instance->setup_size, toggle, false, instance->target,
+	    USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
+
+	/* data stage */
+	size_t i = 1;
+	for (;i < instance->packets - 1; ++i) {
+		char *data =
+		    instance->transport_buffer + ((i - 1) * instance->max_packet_size);
+		toggle = 1 - toggle;
+
+		transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+		    instance->max_packet_size, toggle, false, instance->target,
+		    USB_PID_IN, data, &instance->tds[i + 1]);
+	}
+
+	/* status stage */
+	i = instance->packets - 1;
+	transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+	    0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
+
+	instance->next_step = batch_call_in_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_interrupt_in(batch_t *instance)
+{
+	assert(instance);
+
+	int toggle = 1;
+	size_t i = 0;
+	for (;i < instance->packets; ++i) {
+		char *data =
+		    instance->transport_buffer + (i  * instance->max_packet_size);
+		transfer_descriptor_t *next = (i + 1) < instance->packets ?
+		    &instance->tds[i + 1] : NULL;
+		toggle = 1 - toggle;
+
+		transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+		    instance->max_packet_size, toggle, false, instance->target,
+		    USB_PID_IN, data, next);
+	}
+
+	instance->next_step = batch_call_in_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_interrupt_out(batch_t *instance)
+{
+	assert(instance);
+
+	memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
+
+	int toggle = 1;
+	size_t i = 0;
+	for (;i < instance->packets; ++i) {
+		char *data =
+		    instance->transport_buffer + (i  * instance->max_packet_size);
+		transfer_descriptor_t *next = (i + 1) < instance->packets ?
+		    &instance->tds[i + 1] : NULL;
+		toggle = 1 - toggle;
+
+		transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
+		    instance->max_packet_size, toggle++, false, instance->target,
+		    USB_PID_OUT, data, next);
+	}
+
+	instance->next_step = batch_call_out_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_call_in(batch_t *instance)
+{
+	assert(instance);
+	assert(instance->callback_in);
+
+	memcpy(instance->buffer, instance->transport_buffer, instance->buffer_size);
+
+	int err = instance->error;
+	usb_log_info("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
+	    err, instance->transfered_size);
+
+	instance->callback_in(instance->dev,
+	    err, instance->transfered_size,
+	    instance->arg);
+}
+/*----------------------------------------------------------------------------*/
+void batch_call_out(batch_t *instance)
+{
+	assert(instance);
+	assert(instance->callback_out);
+
+	int err = instance->error;
+	usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
+	instance->callback_out(instance->dev,
+	    err, instance->arg);
+}
+/*----------------------------------------------------------------------------*/
+void batch_call_in_and_dispose(batch_t *instance)
+{
+	assert(instance);
+	batch_call_in(instance);
+	usb_log_debug("Disposing batch: %p.\n", instance);
+	free32(instance->tds);
+	free32(instance->qh);
+	free32(instance->setup_buffer);
+	free32(instance->transport_buffer);
+	free(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_call_out_and_dispose(batch_t *instance)
+{
+	assert(instance);
+	batch_call_out(instance);
+	usb_log_debug("Disposing batch: %p.\n", instance);
+	free32(instance->tds);
+	free32(instance->qh);
+	free32(instance->setup_buffer);
+	free32(instance->transport_buffer);
+	free(instance);
+}
+/*----------------------------------------------------------------------------*/
+int batch_schedule(batch_t *instance)
+{
+	assert(instance);
+	uhci_t *hc = dev_to_uhci(instance->dev);
+	assert(hc);
+	return uhci_schedule(hc, instance);
+}
+/*----------------------------------------------------------------------------*/
+/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
+void batch_control_setup_old(batch_t *instance)
+{
+	assert(instance);
+	instance->packets = 1;
+
+	/* setup stage */
+	transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
+	    instance->setup_size, 0, false, instance->target,
+	    USB_PID_SETUP, instance->setup_buffer, NULL);
+
+	instance->next_step = batch_call_out_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_write_data_old(batch_t *instance)
+{
+	assert(instance);
+	instance->packets -= 2;
+	batch_interrupt_out(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_read_data_old(batch_t *instance)
+{
+	assert(instance);
+	instance->packets -= 2;
+	batch_interrupt_in(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_write_status_old(batch_t *instance)
+{
+	assert(instance);
+	instance->packets = 1;
+	transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
+	    0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
+	instance->next_step = batch_call_in_and_dispose;
+	batch_schedule(instance);
+}
+/*----------------------------------------------------------------------------*/
+void batch_control_read_status_old(batch_t *instance)
+{
+	assert(instance);
+	instance->packets = 1;
+	transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
+	    0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
+	instance->next_step = batch_call_out_and_dispose;
+	batch_schedule(instance);
+}
+/**
+ * @}
+ */
Index: uspace/drv/uhci-hcd/batch.h
===================================================================
--- uspace/drv/uhci-hcd/batch.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
+++ uspace/drv/uhci-hcd/batch.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_BATCH_H
+#define DRV_UHCI_BATCH_H
+
+#include <adt/list.h>
+
+#include <usbhc_iface.h>
+#include <usb/usb.h>
+
+#include "uhci_struct/transfer_descriptor.h"
+#include "uhci_struct/queue_head.h"
+
+typedef enum {
+	LOW_SPEED,
+	FULL_SPEED,
+} dev_speed_t;
+
+typedef struct batch
+{
+	link_t link;
+	dev_speed_t speed;
+	usb_target_t target;
+	usb_transfer_type_t transfer_type;
+	union {
+		usbhc_iface_transfer_in_callback_t callback_in;
+		usbhc_iface_transfer_out_callback_t callback_out;
+	};
+	void *arg;
+	char *transport_buffer;
+	char *setup_buffer;
+	size_t setup_size;
+	char *buffer;
+	size_t buffer_size;
+	size_t max_packet_size;
+	size_t packets;
+	size_t transfered_size;
+	int error;
+	device_t *dev;
+	queue_head_t *qh;
+	transfer_descriptor_t *tds;
+	void (*next_step)(struct batch*);
+} batch_t;
+
+batch_t * batch_get(device_t *dev, usb_target_t target,
+    usb_transfer_type_t transfer_type, size_t max_packet_size,
+    dev_speed_t speed, char *buffer, size_t size,
+		char *setup_buffer, size_t setup_size,
+    usbhc_iface_transfer_in_callback_t func_in,
+    usbhc_iface_transfer_out_callback_t func_out, void *arg);
+
+bool batch_is_complete(batch_t *instance);
+
+void batch_control_write(batch_t *instance);
+
+void batch_control_read(batch_t *instance);
+
+void batch_interrupt_in(batch_t *instance);
+
+void batch_interrupt_out(batch_t *instance);
+
+/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
+void batch_control_setup_old(batch_t *instance);
+
+void batch_control_write_data_old(batch_t *instance);
+
+void batch_control_read_data_old(batch_t *instance);
+
+void batch_control_write_status_old(batch_t *instance);
+
+void batch_control_read_status_old(batch_t *instance);
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci-hcd/iface.c
===================================================================
--- uspace/drv/uhci-hcd/iface.c	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/iface.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -109,9 +109,9 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_INTERRUPT,
-	    max_packet_size, speed, data, size, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_interrupt_out(tracker);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
+	    max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_interrupt_out(batch);
 	return EOK;
 }
@@ -124,9 +124,9 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_INTERRUPT,
-	    max_packet_size, speed, data, size, callback, NULL, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_interrupt_in(tracker);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
+	    max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_interrupt_in(batch);
 	return EOK;
 }
@@ -139,9 +139,10 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    max_packet_size, speed, data, size, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_write(tracker, setup_data, setup_size);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, data, size, setup_data, setup_size,
+	    NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_write(batch);
 	return EOK;
 }
@@ -154,9 +155,10 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    max_packet_size, speed, data, size, callback, NULL, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_read(tracker, setup_data, setup_size);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, data, size, setup_data, setup_size, callback,
+	    NULL, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_read(batch);
 	return EOK;
 }
@@ -166,10 +168,13 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    8, FULL_SPEED, data, size, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_setup_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_setup_old(batch);
 	return EOK;
 }
@@ -179,10 +184,13 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    size, FULL_SPEED, data, size, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_write_data_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_write_data_old(batch);
 	return EOK;
 }
@@ -191,10 +199,13 @@
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    0, FULL_SPEED, NULL, 0, callback, NULL, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_write_status_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, NULL, 0, NULL, 0, callback, NULL, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_write_status_old(batch);
 	return EOK;
 }
@@ -204,10 +215,13 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    8, FULL_SPEED, data, size, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_setup_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_setup_old(batch);
 	return EOK;
 }
@@ -217,10 +231,13 @@
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    size, FULL_SPEED, data, size, callback, NULL, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_read_data_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_read_data_old(batch);
 	return EOK;
 }
@@ -229,10 +246,13 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
-	tracker_t *tracker = tracker_get(dev, target, USB_TRANSFER_CONTROL,
-	    0, FULL_SPEED, NULL, 0, NULL, callback, arg);
-	if (!tracker)
-		return ENOMEM;
-	tracker_control_read_status_old(tracker);
+	size_t max_packet_size = 8;
+	dev_speed_t speed = FULL_SPEED;
+
+	usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
+	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	    max_packet_size, speed, NULL, 0, NULL, 0, NULL, callback, arg);
+	if (!batch)
+		return ENOMEM;
+	batch_control_read_status_old(batch);
 	return EOK;
 }
Index: pace/drv/uhci-hcd/tracker.c
===================================================================
--- uspace/drv/uhci-hcd/tracker.c	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ 	(revision )
@@ -1,501 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 usb
- * @{
- */
-/** @file
- * @brief UHCI driver
- */
-#include <errno.h>
-
-#include <usb/debug.h>
-
-#include "tracker.h"
-#include "transfer_list.h"
-#include "uhci.h"
-#include "utils/malloc32.h"
-
-#define SETUP_PACKET_DATA_SIZE 8
-#define DEFAULT_ERROR_COUNT 3
-#define MAX(a,b) ((a > b) ? a : b)
-#define MIN(a,b) ((a < b) ? a : b)
-
-static int tracker_schedule(tracker_t *instance);
-
-static void tracker_control_read_data(tracker_t *instance);
-static void tracker_control_write_data(tracker_t *instance);
-static void tracker_control_read_status(tracker_t *instance);
-static void tracker_control_write_status(tracker_t *instance);
-
-static void tracker_call_in(tracker_t *instance);
-static void tracker_call_out(tracker_t *instance);
-static void tracker_call_in_and_dispose(tracker_t *instance);
-static void tracker_call_out_and_dispose(tracker_t *instance);
-
-
-tracker_t * tracker_get(device_t *dev, usb_target_t target,
-    usb_transfer_type_t transfer_type, size_t max_packet_size,
-    dev_speed_t speed, char *buffer, size_t size,
-    usbhc_iface_transfer_in_callback_t func_in,
-    usbhc_iface_transfer_out_callback_t func_out, void *arg)
-{
-	assert(func_in == NULL || func_out == NULL);
-	assert(func_in != NULL || func_out != NULL);
-
-	tracker_t *instance = malloc(sizeof(tracker_t));
-	if (!instance) {
-		usb_log_error("Failed to allocate tracker isntance.\n");
-		return NULL;
-	}
-
-	instance->td = malloc32(sizeof(transfer_descriptor_t));
-	if (!instance->td) {
-		usb_log_error("Failed to allocate transfer descriptor.\n");
-		free(instance);
-		return NULL;
-	}
-	bzero(instance->td, sizeof(transfer_descriptor_t));
-
-	instance->packet = max_packet_size ? malloc32(max_packet_size) : NULL;
-	if (max_packet_size && !instance->packet) {
-		usb_log_error("Failed to allocate device acessible buffer.\n");
-		free32(instance->td);
-		free(instance);
-		return NULL;
-	}
-	instance->max_packet_size = max_packet_size;
-	instance->packet_size = 0;
-	instance->buffer_offset = 0;
-
-	link_initialize(&instance->link);
-	instance->target = target;
-	instance->transfer_type = transfer_type;
-
-	if (func_out)
-		instance->callback_out = func_out;
-	if (func_in)
-		instance->callback_in = func_in;
-	instance->buffer = buffer;
-	instance->buffer_size = size;
-	instance->dev = dev;
-	instance->arg = arg;
-	instance->toggle = 0;
-	instance->speed = speed;
-
-	return instance;
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_write(
-    tracker_t *instance, char* setup_buffer, size_t setup_size)
-{
-	assert(instance);
-	assert(instance->buffer_offset == 0);
-	assert(setup_size == 8);
-
-	instance->packet_size = 0;
-	memcpy(instance->packet, setup_buffer, setup_size);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    setup_size, instance->toggle++, false, instance->target,
-	    USB_PID_SETUP, instance->packet);
-
-	instance->next_step = tracker_control_write_data;
-
-	tracker_schedule(instance);
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_read(
-    tracker_t *instance, char* setup_buffer, size_t setup_size)
-{
-	assert(instance);
-	assert(instance->buffer_offset == 0);
-	assert(setup_size == 8);
-
-	memcpy(instance->packet, setup_buffer, setup_size);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    setup_size, instance->toggle++, false, instance->target,
-	    USB_PID_SETUP, instance->packet);
-
-	instance->next_step = tracker_control_read_data;
-
-	tracker_schedule(instance);
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_read_data(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_in_and_dispose(instance);
-		return;
-	}
-
-	/* we are data in, we want data from our device */
-	if (instance->packet_size) {
-		memcpy(instance->buffer + instance->buffer_offset, instance->packet,
-		    instance->packet_size);
-	}
-	instance->buffer_offset += instance->packet_size;
-
-	/* prepare next packet, no copy, we are receiving data */
-	instance->packet_size =	MIN(instance->max_packet_size,
-	    instance->buffer_size - instance->buffer_offset);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, instance->toggle++, false, instance->target,
-	    USB_PID_IN, instance->packet);
-
-	tracker_schedule(instance);
-
-	/* set next step */
-	if ((instance->buffer_offset + instance->packet_size)
-	    >= instance->buffer_size) {
-		/* that's all, end coomunication */
-		instance->next_step = tracker_control_read_status;
-	}
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_write_data(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_out_and_dispose(instance);
-		return;
-	}
-
-	/* we are data out, we don't want data from our device */
-	instance->buffer_offset += instance->packet_size;
-
-	/* prepare next packet, copy data to packet */
-	instance->packet_size =	MIN(instance->max_packet_size,
-	    instance->buffer_size - instance->buffer_offset);
-	memcpy(instance->packet, instance->buffer + instance->buffer_offset,
-	    instance->packet_size);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, instance->toggle++, false, instance->target,
-	    USB_PID_OUT, instance->packet);
-
-	tracker_schedule(instance);
-
-	/* set next step */
-	if ((instance->buffer_offset + instance->packet_size)
-	    >= instance->buffer_size) {
-		/* that's all, end coomunication */
-		instance->next_step = tracker_control_write_status;
-	}
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_read_status(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_in_and_dispose(instance);
-		return;
-	}
-
-	/* we are data in, we want data from our device */
-	memcpy(instance->buffer + instance->buffer_offset, instance->packet,
-	    instance->packet_size);
-	instance->buffer_offset += instance->packet_size;
-	assert(instance->buffer_offset = instance->buffer_size);
-
-	/* prepare next packet, no nothing, just an empty packet */
-	instance->packet_size =	0;
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_OUT, NULL);
-
-	tracker_schedule(instance);
-
-	/* set next step, callback and cleanup */
-	instance->next_step = tracker_call_in_and_dispose;
-}
-/*----------------------------------------------------------------------------*/
-void tracker_control_write_status(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_out_and_dispose(instance);
-		return;
-	}
-
-	/* we are data in, we want data from our device */
-	assert(
-	    instance->buffer_offset + instance->packet_size <= instance->buffer_size);
-	memcpy(instance->buffer + instance->buffer_offset, instance->packet,
-	    instance->packet_size);
-	instance->buffer_offset += instance->packet_size;
-	assert(instance->buffer_offset = instance->buffer_size);
-
-	/* prepare next packet, no nothing, just an empty packet */
-	instance->packet_size =	0;
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_IN, NULL);
-
-	tracker_schedule(instance);
-
-	/* set next step, callback and cleanup */
-	instance->next_step = tracker_call_out_and_dispose;
-}
-/*----------------------------------------------------------------------------*/
-void tracker_interrupt_in(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_in_and_dispose(instance);
-		return;
-	}
-
-	assert(instance->packet_size <= instance->max_packet_size);
-	if (instance->packet_size) {
-		/* we are data in, we want data from our device. if there is data */
-		memcpy(instance->buffer + instance->buffer_offset, instance->packet,
-				instance->packet_size);
-		instance->buffer_offset += instance->packet_size;
-	}
-
-	/* prepare next packet, no copy, we are receiving data */
-	instance->packet_size =	MIN(instance->max_packet_size,
-			instance->buffer_size - instance->buffer_offset);
-	assert(instance->packet_size <= instance->max_packet_size);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, instance->toggle++, false, instance->target,
-	    USB_PID_IN, instance->packet);
-
-	tracker_schedule(instance);
-
-	/* set next step */
-	if ((instance->buffer_offset + instance->packet_size)
-	    >= instance->buffer_size) {
-		/* that's all, end coomunication */
-		instance->next_step = tracker_call_in_and_dispose;
-	} else {
-		instance->next_step = tracker_interrupt_in;
-	}
-}
-/*----------------------------------------------------------------------------*/
-void tracker_interrupt_out(tracker_t *instance)
-{
-	assert(instance);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err != EOK) {
-		tracker_call_out_and_dispose(instance);
-		return;
-	}
-
-	/* we are data out, we don't want data from our device */
-	instance->buffer_offset += instance->packet_size;
-
-	/* prepare next packet, copy data to packet */
-	instance->packet_size =	MIN(instance->max_packet_size,
-	    instance->buffer_size - instance->buffer_offset);
-	memcpy(instance->packet, instance->buffer + instance->buffer_offset,
-	    instance->packet_size);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, instance->toggle++, false, instance->target,
-	    USB_PID_OUT, instance->packet);
-
-	tracker_schedule(instance);
-
-	/* set next step */
-	if ((instance->buffer_offset + instance->packet_size)
-	    >= instance->buffer_size) {
-		/* that's all, end coomunication */
-		instance->next_step = tracker_call_out_and_dispose;
-	} else {
-		instance->next_step = tracker_interrupt_out;
-	}
-}
-/*----------------------------------------------------------------------------*/
-void tracker_call_in(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->callback_in);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	if (err == EOK && instance->packet_size) {
-		memcpy(instance->buffer + instance->buffer_offset, instance->packet,
-		    instance->packet_size);
-		instance->buffer_offset += instance->packet_size;
-	}
-	usb_log_debug("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
-	    err, instance->buffer_offset);
-	instance->callback_in(instance->dev,
-	    err ? USB_OUTCOME_CRCERROR : USB_OUTCOME_OK, instance->buffer_offset,
-	    instance->arg);
-}
-/*----------------------------------------------------------------------------*/
-void tracker_call_out(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->callback_out);
-
-	/* check for errors */
-	int err = transfer_descriptor_status(instance->td);
-	usb_log_debug("Callback OUT(%d): %d, %zu.\n", instance->transfer_type,
-	    err, instance->buffer_offset);
-	instance->callback_out(instance->dev,
-	    err ? USB_OUTCOME_CRCERROR : USB_OUTCOME_OK, instance->arg);
-}
-/*----------------------------------------------------------------------------*/
-void tracker_call_in_and_dispose(tracker_t *instance)
-{
-	assert(instance);
-	tracker_call_in(instance);
-	transfer_list_remove_tracker(instance->scheduled_list, instance);
-	free32(instance->td);
-	free32(instance->packet);
-	free(instance);
-}
-/*----------------------------------------------------------------------------*/
-void tracker_call_out_and_dispose(tracker_t *instance)
-{
-	assert(instance);
-	tracker_call_out(instance);
-	assert(instance->scheduled_list);
-	transfer_list_remove_tracker(instance->scheduled_list, instance);
-	free32(instance->td);
-	free32(instance->packet);
-	free(instance);
-}
-/*----------------------------------------------------------------------------*/
-int tracker_schedule(tracker_t *instance)
-{
-	assert(instance);
-	uhci_t *hc = dev_to_uhci(instance->dev);
-	assert(hc);
-	return uhci_schedule(hc, instance);
-}
-/*----------------------------------------------------------------------------*/
-/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
-void tracker_control_setup_old(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->buffer_offset == 0);
-
-	instance->packet_size = SETUP_PACKET_DATA_SIZE;
-	memcpy(instance->packet, instance->buffer, SETUP_PACKET_DATA_SIZE);
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    SETUP_PACKET_DATA_SIZE, 0, false, instance->target, USB_PID_SETUP,
-	    instance->packet);
-
-	instance->buffer_offset += SETUP_PACKET_DATA_SIZE;
-	instance->next_step = tracker_call_out_and_dispose;
-
-	tracker_schedule(instance);
-}
-
-void tracker_control_write_data_old(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->max_packet_size == instance->buffer_size);
-
-	memcpy(instance->packet, instance->buffer, instance->max_packet_size);
-	instance->packet_size = instance->max_packet_size;
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_OUT,
-	    instance->packet);
-	instance->next_step = tracker_call_out_and_dispose;
-
-	tracker_schedule(instance);
-}
-
-void tracker_control_read_data_old(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->max_packet_size == instance->buffer_size);
-
-	instance->packet_size = instance->max_packet_size;
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_IN,
-	    instance->packet);
-
-	instance->next_step = tracker_call_in_and_dispose;
-
-	tracker_schedule(instance);
-}
-
-void tracker_control_write_status_old(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->max_packet_size == 0);
-	assert(instance->buffer_size == 0);
-	assert(instance->packet == NULL);
-
-	instance->packet_size = instance->max_packet_size;
-	instance->next_step = tracker_call_in_and_dispose;
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_IN,
-	    instance->packet);
-
-	tracker_schedule(instance);
-}
-
-void tracker_control_read_status_old(tracker_t *instance)
-{
-	assert(instance);
-	assert(instance->max_packet_size == 0);
-	assert(instance->buffer_size == 0);
-	assert(instance->packet == NULL);
-
-	instance->packet_size = instance->max_packet_size;
-	instance->next_step = tracker_call_out_and_dispose;
-
-	transfer_descriptor_init(instance->td, DEFAULT_ERROR_COUNT,
-	    instance->packet_size, 1, false, instance->target, USB_PID_OUT,
-	    instance->packet);
-
-	tracker_schedule(instance);
-}
-/**
- * @}
- */
Index: pace/drv/uhci-hcd/tracker.h
===================================================================
--- uspace/drv/uhci-hcd/tracker.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 usb
- * @{
- */
-/** @file
- * @brief UHCI driver
- */
-#ifndef DRV_UHCI_TRACKER_H
-#define DRV_UHCI_TRACKER_H
-
-#include <adt/list.h>
-
-#include <usbhc_iface.h>
-#include <usb/usb.h>
-
-#include "uhci_struct/transfer_descriptor.h"
-
-typedef enum {
-	LOW_SPEED,
-	FULL_SPEED,
-} dev_speed_t;
-
-struct transfer_list;
-
-typedef struct tracker
-{
-	link_t link;
-	usb_target_t target;
-	usb_transfer_type_t transfer_type;
-	union {
-		usbhc_iface_transfer_in_callback_t callback_in;
-		usbhc_iface_transfer_out_callback_t callback_out;
-	};
-	void *arg;
-	char *buffer;
-	char *packet;
-	size_t buffer_size;
-	size_t max_packet_size;
-	size_t packet_size;
-	size_t buffer_offset;
-	dev_speed_t speed;
-	device_t *dev;
-	transfer_descriptor_t *td;
-	void (*next_step)(struct tracker*);
-	unsigned toggle:1;
-
-	struct transfer_list *scheduled_list;
-} tracker_t;
-
-
-tracker_t * tracker_get(device_t *dev, usb_target_t target,
-    usb_transfer_type_t transfer_type, size_t max_packet_size,
-    dev_speed_t speed, char *buffer, size_t size,
-    usbhc_iface_transfer_in_callback_t func_in,
-    usbhc_iface_transfer_out_callback_t func_out, void *arg);
-
-void tracker_control_write(
-    tracker_t *instance, char* setup_buffer, size_t setup_size);
-
-void tracker_control_read(
-    tracker_t *instance, char* setup_buffer, size_t setup_size);
-
-void tracker_interrupt_in(tracker_t *instance);
-
-void tracker_interrupt_out(tracker_t *instance);
-
-/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
-void tracker_control_setup_old(tracker_t *instance);
-
-void tracker_control_write_data_old(tracker_t *instance);
-
-void tracker_control_read_data_old(tracker_t *instance);
-
-void tracker_control_write_status_old(tracker_t *instance);
-
-void tracker_control_read_status_old(tracker_t *instance);
-#endif
-/**
- * @}
- */
Index: uspace/drv/uhci-hcd/transfer_list.c
===================================================================
--- uspace/drv/uhci-hcd/transfer_list.c	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/transfer_list.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -51,4 +51,6 @@
 
 	queue_head_init(instance->queue_head);
+	list_initialize(&instance->batch_list);
+	fibril_mutex_initialize(&instance->guard);
 	return EOK;
 }
@@ -58,58 +60,83 @@
 	assert(instance);
 	assert(next);
-	instance->next = next;
 	if (!instance->queue_head)
 		return;
-	queue_head_add_next(instance->queue_head, next->queue_head_pa);
+	queue_head_append_qh(instance->queue_head, next->queue_head_pa);
+	instance->queue_head->element = instance->queue_head->next_queue;
 }
 /*----------------------------------------------------------------------------*/
-void transfer_list_add_tracker(transfer_list_t *instance, tracker_t *tracker)
+void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch)
 {
 	assert(instance);
-	assert(tracker);
+	assert(batch);
 
-	uint32_t pa = (uintptr_t)addr_to_phys(tracker->td);
+	uint32_t pa = (uintptr_t)addr_to_phys(batch->qh);
 	assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
+	pa |= LINK_POINTER_QUEUE_HEAD_FLAG;
 
+	batch->qh->next_queue = instance->queue_head->next_queue;
 
-	if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
-		usb_log_debug2("Adding td(%X:%X) to queue %s first.\n",
-			tracker->td->status, tracker->td->device, instance->name);
+	fibril_mutex_lock(&instance->guard);
+
+	if (instance->queue_head->element == instance->queue_head->next_queue) {
 		/* there is nothing scheduled */
-		instance->last_tracker = tracker;
+		list_append(&batch->link, &instance->batch_list);
 		instance->queue_head->element = pa;
-		usb_log_debug2("Added td(%X:%X) to queue %s first.\n",
-			tracker->td->status, tracker->td->device, instance->name);
+		usb_log_debug2("Added batch(%p) to queue %s first.\n",
+			batch, instance->name);
+		fibril_mutex_unlock(&instance->guard);
 		return;
 	}
-	usb_log_debug2("Adding td(%X:%X) to queue %s last.%p\n",
-	    tracker->td->status, tracker->td->device, instance->name,
-	    instance->last_tracker);
-	/* now we can be sure that last_tracker is a valid pointer */
-	instance->last_tracker->td->next = pa;
-	instance->last_tracker = tracker;
-
-	usb_log_debug2("Added td(%X:%X) to queue %s last.\n",
-		tracker->td->status, tracker->td->device, instance->name);
-
-	/* check again, may be use atomic compare and swap */
-	if (instance->queue_head->element & LINK_POINTER_TERMINATE_FLAG) {
-		instance->queue_head->element = pa;
-		usb_log_debug2("Added td(%X:%X) to queue first2 %s.\n",
-			tracker->td->status, tracker->td->device, instance->name);
-	}
+	/* now we can be sure that there is someting scheduled */
+	assert(!list_empty(&instance->batch_list));
+	batch_t *first = list_get_instance(
+	          instance->batch_list.next, batch_t, link);
+	batch_t *last = list_get_instance(
+	    instance->batch_list.prev, batch_t, link);
+	queue_head_append_qh(last->qh, pa);
+	list_append(&batch->link, &instance->batch_list);
+	usb_log_debug2("Added batch(%p) to queue %s last, first is %p.\n",
+		batch, instance->name, first );
+	fibril_mutex_unlock(&instance->guard);
 }
 /*----------------------------------------------------------------------------*/
-void transfer_list_remove_tracker(transfer_list_t *instance, tracker_t *tracker)
+static void transfer_list_remove_batch(
+    transfer_list_t *instance, batch_t *batch)
 {
 	assert(instance);
-	assert(tracker);
+	assert(batch);
 	assert(instance->queue_head);
-	assert(tracker->td);
+	assert(batch->qh);
 
-	uint32_t pa = (uintptr_t)addr_to_phys(tracker->td);
-	if ((instance->queue_head->element & LINK_POINTER_ADDRESS_MASK) == pa) {
-		instance->queue_head->element = tracker->td->next;
+	/* I'm the first one here */
+	if (batch->link.prev == &instance->batch_list) {
+		usb_log_debug("Removing tracer %p was first, next element %x.\n",
+			batch, batch->qh->next_queue);
+		instance->queue_head->element = batch->qh->next_queue;
+	} else {
+		usb_log_debug("Removing tracer %p was NOT first, next element %x.\n",
+			batch, batch->qh->next_queue);
+		batch_t *prev = list_get_instance(batch->link.prev, batch_t, link);
+		prev->qh->next_queue = batch->qh->next_queue;
 	}
+	list_remove(&batch->link);
+}
+/*----------------------------------------------------------------------------*/
+void transfer_list_check(transfer_list_t *instance)
+{
+	assert(instance);
+	fibril_mutex_lock(&instance->guard);
+	link_t *current = instance->batch_list.next;
+	while (current != &instance->batch_list) {
+		link_t *next = current->next;
+		batch_t *batch = list_get_instance(current, batch_t, link);
+
+		if (batch_is_complete(batch)) {
+			transfer_list_remove_batch(instance, batch);
+			batch->next_step(batch);
+		}
+		current = next;
+	}
+	fibril_mutex_unlock(&instance->guard);
 }
 /**
Index: uspace/drv/uhci-hcd/transfer_list.h
===================================================================
--- uspace/drv/uhci-hcd/transfer_list.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/transfer_list.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -35,16 +35,18 @@
 #define DRV_UHCI_TRANSFER_LIST_H
 
+#include <fibril_synch.h>
+
 #include "uhci_struct/queue_head.h"
 
-#include "tracker.h"
+#include "batch.h"
 
 typedef struct transfer_list
 {
-	tracker_t *last_tracker;
-
+	fibril_mutex_t guard;
 	queue_head_t *queue_head;
 	uint32_t queue_head_pa;
 	struct transfer_list *next;
 	const char *name;
+	link_t batch_list;
 } transfer_list_t;
 
@@ -53,5 +55,4 @@
 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);
 
-
 static inline void transfer_list_fini(transfer_list_t *instance)
 {
@@ -59,9 +60,7 @@
 	queue_head_dispose(instance->queue_head);
 }
+void transfer_list_check(transfer_list_t *instance);
 
-void transfer_list_add_tracker(transfer_list_t *instance, tracker_t *tracker);
-
-void transfer_list_remove_tracker(transfer_list_t *instance, tracker_t *track);
-
+void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch);
 #endif
 /**
Index: uspace/drv/uhci-hcd/uhci.c
===================================================================
--- uspace/drv/uhci-hcd/uhci.c	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/uhci.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -89,6 +89,6 @@
 	pio_write_32(&instance->registers->flbaseadd, (uint32_t)pa);
 
-	list_initialize(&instance->tracker_list);
-	fibril_mutex_initialize(&instance->tracker_list_mutex);
+	list_initialize(&instance->batch_list);
+	fibril_mutex_initialize(&instance->batch_list_mutex);
 
 	instance->cleaner = fibril_create(uhci_clean_finished, instance);
@@ -152,37 +152,22 @@
 }
 /*----------------------------------------------------------------------------*/
-int uhci_schedule(uhci_t *instance, tracker_t *tracker)
-{
-	assert(instance);
-	assert(tracker);
-	const int low_speed = (tracker->speed == LOW_SPEED);
+int uhci_schedule(uhci_t *instance, batch_t *batch)
+{
+	assert(instance);
+	assert(batch);
+	const int low_speed = (batch->speed == LOW_SPEED);
 	if (!allowed_usb_packet(
-	    low_speed, tracker->transfer_type, tracker->packet_size)) {
+	    low_speed, batch->transfer_type, batch->max_packet_size)) {
 		usb_log_warning("Invalid USB packet specified %s SPEED %d %zu.\n",
-			  low_speed ? "LOW" : "FULL" , tracker->transfer_type,
-		    tracker->packet_size);
+			  low_speed ? "LOW" : "FULL" , batch->transfer_type,
+		    batch->max_packet_size);
 		return ENOTSUP;
 	}
 	/* TODO: check available bandwith here */
 
-	usb_log_debug2("Scheduler(%d) acquiring tracker list mutex.\n",
-	    fibril_get_id());
-	fibril_mutex_lock(&instance->tracker_list_mutex);
-	usb_log_debug2("Scheduler(%d) acquired tracker list mutex.\n",
-	    fibril_get_id());
-
 	transfer_list_t *list =
-	    instance->transfers[low_speed][tracker->transfer_type];
+	    instance->transfers[low_speed][batch->transfer_type];
 	assert(list);
-	transfer_list_add_tracker(list, tracker);
-	list_append(&tracker->link, &instance->tracker_list);
-
-	tracker->scheduled_list = list;
-
-	usb_log_debug2("Scheduler(%d) releasing tracker list mutex.\n",
-	    fibril_get_id());
-	fibril_mutex_unlock(&instance->tracker_list_mutex);
-	usb_log_debug2("Scheduler(%d) released tracker list mutex.\n",
-	    fibril_get_id());
+	transfer_list_add_batch(list, batch);
 
 	return EOK;
@@ -196,46 +181,8 @@
 
 	while(1) {
-		LIST_INITIALIZE(done_trackers);
-		/* tracker iteration */
-
-		usb_log_debug2("Cleaner(%d) acquiring tracker list mutex.\n",
-		    fibril_get_id());
-		fibril_mutex_lock(&instance->tracker_list_mutex);
-		usb_log_debug2("Cleaner(%d) acquired tracker list mutex.\n",
-		    fibril_get_id());
-
-		link_t *current = instance->tracker_list.next;
-		while (current != &instance->tracker_list)
-		{
-
-			link_t *next = current->next;
-			tracker_t *tracker = list_get_instance(current, tracker_t, link);
-
-			assert(current == &tracker->link);
-			assert(tracker);
-			assert(tracker->next_step);
-			assert(tracker->td);
-
-			if (!transfer_descriptor_is_active(tracker->td)) {
-				usb_log_info("Found inactive tracker with status: %x:%x.\n",
-				    tracker->td->status, tracker->td->device);
-				list_remove(current);
-				list_append(current, &done_trackers);
-			}
-			current = next;
-		}
-
-		usb_log_debug2("Cleaner(%d) releasing tracker list mutex.\n",
-		    fibril_get_id());
-		fibril_mutex_unlock(&instance->tracker_list_mutex);
-		usb_log_debug2("Cleaner(%d) released tracker list mutex.\n",
-		    fibril_get_id());
-
-		while (!list_empty(&done_trackers)) {
-			tracker_t *tracker = list_get_instance(
-			  done_trackers.next, tracker_t, link);
-			list_remove(&tracker->link);
-			tracker->next_step(tracker);
-		}
+		transfer_list_check(&instance->transfers_interrupt);
+		transfer_list_check(&instance->transfers_control_slow);
+		transfer_list_check(&instance->transfers_control_full);
+		transfer_list_check(&instance->transfers_bulk_full);
 		async_usleep(UHCI_CLEANER_TIMEOUT);
 	}
Index: uspace/drv/uhci-hcd/uhci.h
===================================================================
--- uspace/drv/uhci-hcd/uhci.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/uhci.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -44,5 +44,5 @@
 
 #include "transfer_list.h"
-#include "tracker.h"
+#include "batch.h"
 
 typedef struct uhci_regs {
@@ -72,5 +72,5 @@
 
 #define UHCI_FRAME_LIST_COUNT 1024
-#define UHCI_CLEANER_TIMEOUT 1000
+#define UHCI_CLEANER_TIMEOUT 10000
 #define UHCI_DEBUGER_TIMEOUT 5000000
 
@@ -81,6 +81,6 @@
 	link_pointer_t *frame_list;
 
-	link_t tracker_list;
-	fibril_mutex_t tracker_list_mutex;
+	link_t batch_list;
+	fibril_mutex_t batch_list_mutex;
 
 	transfer_list_t transfers_bulk_full;
@@ -113,5 +113,5 @@
   void *arg );
 
-int uhci_schedule(uhci_t *instance, tracker_t *tracker);
+int uhci_schedule(uhci_t *instance, batch_t *batch);
 
 static inline uhci_t * dev_to_uhci(device_t *dev)
Index: uspace/drv/uhci-hcd/uhci_struct/queue_head.h
===================================================================
--- uspace/drv/uhci-hcd/uhci_struct/queue_head.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/uhci_struct/queue_head.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -55,14 +55,33 @@
 }
 
-static inline void queue_head_add_next(queue_head_t *instance, uint32_t next_queue_pa)
+static inline void queue_head_append_qh(queue_head_t *instance, uint32_t pa)
 {
-	if (next_queue_pa) {
-		instance->next_queue = (next_queue_pa & LINK_POINTER_ADDRESS_MASK)
-		  | LINK_POINTER_QUEUE_HEAD_FLAG;
+	if (pa) {
+		instance->next_queue = (pa & LINK_POINTER_ADDRESS_MASK)
+		    | LINK_POINTER_QUEUE_HEAD_FLAG;
 	}
 }
 
-static inline queue_head_t * queue_head_get()
-	{ return malloc32(sizeof(queue_head_t)); }
+static inline void queue_head_element_qh(queue_head_t *instance, uint32_t pa)
+{
+	if (pa) {
+		instance->next_queue = (pa & LINK_POINTER_ADDRESS_MASK)
+		    | LINK_POINTER_QUEUE_HEAD_FLAG;
+	}
+}
+
+static inline void queue_head_element_td(queue_head_t *instance, uint32_t pa)
+{
+	if (pa) {
+		instance->element = (pa & LINK_POINTER_ADDRESS_MASK);
+	}
+}
+
+static inline queue_head_t * queue_head_get() {
+	queue_head_t *ret = malloc32(sizeof(queue_head_t));
+	if (ret)
+		queue_head_init(ret);
+	return ret;
+}
 
 static inline void queue_head_dispose(queue_head_t *head)
Index: uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -40,9 +40,11 @@
 void transfer_descriptor_init(transfer_descriptor_t *instance,
     int error_count, size_t size, bool toggle, bool isochronous,
-    usb_target_t target, int pid, void *buffer)
+    usb_target_t target, int pid, void *buffer, transfer_descriptor_t *next)
 {
 	assert(instance);
 
-	instance->next = 0 | LINK_POINTER_TERMINATE_FLAG;
+	instance->next = 0
+	    | LINK_POINTER_VERTICAL_FLAG
+	    | ((next != NULL) ? addr_to_phys(next) : LINK_POINTER_TERMINATE_FLAG);
 
 	instance->status = 0
Index: uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -93,7 +93,15 @@
 void transfer_descriptor_init(transfer_descriptor_t *instance,
     int error_count, size_t size, bool toggle, bool isochronous,
-    usb_target_t target, int pid, void *buffer);
+    usb_target_t target, int pid, void *buffer, transfer_descriptor_t * next);
 
 int transfer_descriptor_status(transfer_descriptor_t *instance);
+
+static inline size_t transfer_descriptor_actual_size(
+    transfer_descriptor_t *instance)
+{
+	assert(instance);
+	return
+	    ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
+}
 
 static inline bool transfer_descriptor_is_active(
Index: uspace/drv/uhci-hcd/utils/malloc32.h
===================================================================
--- uspace/drv/uhci-hcd/utils/malloc32.h	(revision dc04868bf6630e8b7f8647342a586893610cd743)
+++ uspace/drv/uhci-hcd/utils/malloc32.h	(revision 54d90588bbe1023ed8700646c7c2130ac22ac4ca)
@@ -45,5 +45,5 @@
 #define UHCI_REQUIRED_PAGE_SIZE 4096
 
-static inline void * addr_to_phys(void *addr)
+static inline uintptr_t addr_to_phys(void *addr)
 {
 	uintptr_t result;
@@ -51,5 +51,5 @@
 
 	assert(ret == 0);
-	return (void*)(result | ((uintptr_t)addr & 0xfff));
+	return (result | ((uintptr_t)addr & 0xfff));
 }
 
