Index: uspace/lib/usbdev/src/devpoll.c
===================================================================
--- uspace/lib/usbdev/src/devpoll.c	(revision 24893533ca9ec3767255a61462aa42d05039d4ea)
+++ uspace/lib/usbdev/src/devpoll.c	(revision 7dddd7b475f6a4be64132bca0625d4514f8c8872)
@@ -203,18 +203,16 @@
  * @param epm Endpoint mapping to use.
  * @param polling Polling settings.
- * @param request_size How many bytes to ask for in each request.
- * @param arg Custom argument (passed as is to the callbacks).
+ * @param req_size How many bytes to ask for in each request.
  * @return Error code.
  * @retval EOK New fibril polling the device was already started.
  */
-static int usb_device_auto_polling_internal(usb_device_t *dev,
-    usb_endpoint_mapping_t *epm, const usb_device_auto_polling_t *polling,
-    size_t request_size)
+int usb_device_auto_polling(usb_device_t *dev, usb_endpoint_mapping_t *epm,
+    const usb_device_auto_polling_t *polling, size_t req_size)
 {
-	if ((dev == NULL) || (polling == NULL) || (polling->on_data == NULL)) {
+	int rc;
+	if (!dev || !polling || !polling->on_data)
 		return EBADMEM;
-	}
-
-	if (request_size == 0)
+
+	if (!req_size)
 		return EINVAL;
 
@@ -223,17 +221,15 @@
 		return EINVAL;
 
-
 	polling_data_t *polling_data = malloc(sizeof(polling_data_t));
-	if (polling_data == NULL) {
+	if (!polling_data)
 		return ENOMEM;
-	}
 
 	/* Fill-in the data. */
-	polling_data->buffer = malloc(request_size);
+	polling_data->buffer = malloc(req_size);
 	if (polling_data->buffer == NULL) {
-		free(polling_data);
-		return ENOMEM;
-	}
-	polling_data->request_size = request_size;
+		rc = ENOMEM;
+		goto err_polling_data;
+	}
+	polling_data->request_size = req_size;
 	polling_data->dev = dev;
 	polling_data->polling_mapping = epm;
@@ -249,107 +245,18 @@
 
 	fid_t fibril = fibril_create(polling_fibril, polling_data);
-	if (fibril == 0) {
-		free(polling_data->buffer);
-		free(polling_data);
-		return ENOMEM;
+	if (!fibril) {
+		rc = ENOMEM;
+		goto err_buffer;
 	}
 	fibril_add_ready(fibril);
 
 	/* Fibril launched. That fibril will free the allocated data. */
-
 	return EOK;
-}
-/** Start automatic device polling over interrupt in pipe.
- *
- * The polling settings is copied thus it is okay to destroy the structure
- * after this function returns.
- *
- * @warning There is no guarantee when the request to the device
- * will be sent for the first time (it is possible that this
- * first request would be executed prior to return from this function).
- *
- * @param dev Device to be periodically polled.
- * @param pipe_index Index of the endpoint pipe used for polling.
- * @param polling Polling settings.
- * @param req_size How many bytes to ask for in each request.
- * @param arg Custom argument (passed as is to the callbacks).
- * @return Error code.
- * @retval EOK New fibril polling the device was already started.
- */
-int usb_device_auto_polling(usb_device_t *usb_dev, usb_endpoint_t ep,
-    const usb_device_auto_polling_t *polling, size_t req_size)
-{
-	usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(usb_dev, ep);
-	return usb_device_auto_polling_internal(usb_dev, epm, polling, req_size);
-}
-
-/** Start automatic device polling over interrupt in pipe.
- *
- * @warning It is up to the callback to produce delays between individual
- * requests.
- *
- * @warning There is no guarantee when the request to the device
- * will be sent for the first time (it is possible that this
- * first request would be executed prior to return from this function).
- *
- * @param dev Device to be periodically polled.
- * @param ep Endpoint  used for polling.
- * @param callback Callback when data are available.
- * @param request_size How many bytes to ask for in each request.
- * @param delay NUmber of ms to wait between queries, -1 to use descriptor val.
- * @param terminated_callback Callback when polling is terminated.
- * @param arg Custom argument (passed as is to the callbacks).
- * @return Error code.
- * @retval EOK New fibril polling the device was already started.
- */
-int usb_device_auto_poll(usb_device_t *dev, usb_endpoint_t ep,
-    usb_polling_callback_t callback, size_t request_size, int delay,
-    usb_polling_terminted_callback_t terminated_callback, void *arg)
-{
-	const usb_device_auto_polling_t auto_polling = {
-		.debug = 1,
-		.auto_clear_halt = true,
-		.delay = delay,
-		.max_failures = MAX_FAILED_ATTEMPTS,
-		.on_data = callback,
-		.on_polling_end = terminated_callback,
-		.on_error = NULL,
-		.arg = arg,
-	};
-
-	usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(dev, ep);
-	return usb_device_auto_polling_internal(
-	    dev, epm, &auto_polling, request_size);
-}
-
-int usb_device_auto_polling_desc(usb_device_t *usb_dev,
-    const usb_endpoint_description_t *desc,
-    const usb_device_auto_polling_t *polling, size_t req_size)
-{
-	usb_endpoint_mapping_t *epm =
-	    usb_device_get_mapped_ep_desc(usb_dev, desc);
-	return usb_device_auto_polling_internal(usb_dev, epm, polling, req_size);
-}
-
-int usb_device_auto_poll_desc(usb_device_t * usb_dev,
-    const usb_endpoint_description_t *desc, usb_polling_callback_t callback,
-    size_t req_size, int delay, usb_polling_error_callback_t error_callback,
-    usb_polling_terminted_callback_t terminated_callback, void *arg)
-{
-	const usb_device_auto_polling_t auto_polling = {
-		.debug = 1,
-		.auto_clear_halt = true,
-		.delay = delay,
-		.max_failures = MAX_FAILED_ATTEMPTS,
-		.on_data = callback,
-		.on_polling_end = terminated_callback,
-		.on_error = error_callback,
-		.arg = arg,
-	};
-
-	usb_endpoint_mapping_t *epm =
-	    usb_device_get_mapped_ep_desc(usb_dev, desc);
-	return usb_device_auto_polling_internal(
-	    usb_dev, epm, &auto_polling, req_size);
+
+err_buffer:
+	free(polling_data->buffer);
+err_polling_data:
+	free(polling_data);
+	return rc;
 }
 
