Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 79d2987615b780d65a2ce85f69be6227caa7ecb1)
+++ uspace/lib/usb/src/recognise.c	(revision 4e8e1f51aca228845c8d503a3f52fbf34a47bb20)
@@ -36,7 +36,13 @@
 #include <usb_iface.h>
 #include <usb/usbdrv.h>
+#include <usb/pipes.h>
+#include <usb/recognise.h>
+#include <usb/request.h>
 #include <usb/classes/classes.h>
 #include <stdio.h>
 #include <errno.h>
+
+static size_t device_name_index = 0;
+static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
 
 /** Callback for getting host controller handle.
@@ -241,13 +247,11 @@
 /** Add match ids based on configuration descriptor.
  *
- * @param hc Open phone to host controller.
+ * @param pipe Control pipe to the device.
  * @param matches Match ids list to add matches to.
- * @param address USB address of the attached device.
  * @param config_count Number of configurations the device has.
  * @return Error code.
  */
-static int usb_add_config_descriptor_match_ids(int hc,
-    match_id_list_t *matches, usb_address_t address,
-    int config_count)
+static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe,
+    match_id_list_t *matches, int config_count)
 {
 	int final_rc = EOK;
@@ -257,6 +261,6 @@
 		int rc;
 		usb_standard_configuration_descriptor_t config_descriptor;
-		rc = usb_drv_req_get_bare_configuration_descriptor(hc,
-		    address,  config_index, &config_descriptor);
+		rc = usb_request_get_bare_configuration_descriptor(pipe,
+		    config_index, &config_descriptor);
 		if (rc != EOK) {
 			final_rc = rc;
@@ -267,6 +271,6 @@
 		void *full_config_descriptor
 		    = malloc(config_descriptor.total_length);
-		rc = usb_drv_req_get_full_configuration_descriptor(hc,
-		    address, config_index,
+		rc = usb_request_get_full_configuration_descriptor(pipe,
+		    config_index,
 		    full_config_descriptor, config_descriptor.total_length,
 		    &full_config_descriptor_size);
@@ -299,14 +303,13 @@
  * function exits with error.
  *
- * @param hc Open phone to host controller.
+ * @param ctrl_pipe Control pipe to given device (session must be already
+ *	started).
  * @param matches Initialized list of match ids.
- * @param address USB address of the attached device.
- * @return Error code.
- */
-int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches,
-    usb_address_t address)
+ * @return Error code.
+ */
+int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe,
+    match_id_list_t *matches)
 {
 	int rc;
-	
 	/*
 	 * Retrieve device descriptor and add matches from it.
@@ -314,10 +317,9 @@
 	usb_standard_device_descriptor_t device_descriptor;
 
-	rc = usb_drv_req_get_device_descriptor(hc, address,
-	    &device_descriptor);
+	rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor);
 	if (rc != EOK) {
 		return rc;
 	}
-	
+
 	rc = usb_drv_create_match_ids_from_device_descriptor(matches,
 	    &device_descriptor);
@@ -325,11 +327,11 @@
 		return rc;
 	}
-	
+
 	/*
 	 * Go through all configurations and add matches
 	 * based on interface class.
 	 */
-	rc = usb_add_config_descriptor_match_ids(hc, matches,
-	    address, device_descriptor.configuration_count);
+	rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches,
+	    device_descriptor.configuration_count);
 	if (rc != EOK) {
 		return rc;
@@ -347,19 +349,16 @@
 }
 
-
 /** Probe for device kind and register it in devman.
  *
- * @param[in] hc Open phone to the host controller.
+ * @param[in] address Address of the (unknown) attached device.
+ * @param[in] hc_handle Handle of the host controller.
  * @param[in] parent Parent device.
- * @param[in] address Address of the (unknown) attached device.
  * @param[out] child_handle Handle of the child device.
  * @return Error code.
  */
-int usb_drv_register_child_in_devman(int hc, device_t *parent,
-    usb_address_t address, devman_handle_t *child_handle)
-{
-	static size_t device_name_index = 0;
-	static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
-
+int usb_device_register_child_in_devman(usb_address_t address,
+    devman_handle_t hc_handle,
+    device_t *parent, devman_handle_t *child_handle)
+{
 	size_t this_device_name_index;
 
@@ -369,8 +368,20 @@
 	fibril_mutex_unlock(&device_name_index_mutex);
 
-
 	device_t *child = NULL;
 	char *child_name = NULL;
 	int rc;
+	usb_device_connection_t dev_connection;
+	usb_endpoint_pipe_t ctrl_pipe;
+
+	rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
+	    &dev_connection);
+	if (rc != EOK) {
+		goto failure;
+	}
 
 	child = create_device();
@@ -391,6 +402,16 @@
 	child->name = child_name;
 	child->ops = &child_ops;
-	
-	rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
+
+	rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_endpoint_pipe_end_session(&ctrl_pipe);
 	if (rc != EOK) {
 		goto failure;
@@ -405,5 +426,5 @@
 		*child_handle = child->handle;
 	}
-	
+
 	return EOK;
 
@@ -419,5 +440,4 @@
 
 	return rc;
-
 }
 
