Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 5097bed4d7ef551a2f0d80edcf1f4094c66dff04)
+++ uspace/drv/usbhub/usbhub.c	(revision 281ebae2047c36745538dd2881ad486e9daf26a2)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/** @addtogroup usb hub driver
+/** @addtogroup drvusbhub
  * @{
  */
@@ -46,4 +46,5 @@
 #include "usbhub_private.h"
 #include "port_status.h"
+#include "usb/usb.h"
 
 static usb_iface_t hub_usb_iface = {
@@ -75,5 +76,5 @@
 	//get some hub info
 	usb_address_t addr = usb_drv_get_my_address(hc, device);
-	dprintf(1,"[usb_hub] address of newly created hub = %d", addr);
+	dprintf(1, "address of newly created hub = %d", addr);
 	/*if(addr<0){
 		//return result;
@@ -85,10 +86,4 @@
 
 	// get hub descriptor
-	usb_target_t target;
-	target.address = addr;
-	target.endpoint = 0;
-	usb_device_request_setup_packet_t request;
-	//printf("[usb_hub] creating descriptor request\n");
-	usb_hub_set_descriptor_request(&request);
 
 	//printf("[usb_hub] creating serialized descriptor\n");
@@ -98,9 +93,12 @@
 	int opResult;
 	//printf("[usb_hub] starting control transaction\n");
-	opResult = usb_drv_sync_control_read(
-			hc, target, &request, serialized_descriptor,
+	
+	opResult = usb_drv_req_get_descriptor(hc, addr,
+			USB_REQUEST_TYPE_CLASS,
+			USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
 			USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
-	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult);
+
+	if (opResult != EOK) {
+		dprintf(1, "failed when receiving hub descriptor, badcode = %d",opResult);
 		free(serialized_descriptor);
 		return result;
@@ -109,5 +107,5 @@
 	descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
 	if(descriptor==NULL){
-		dprintf(1,"[usb_hub] could not deserialize descriptor ");
+		dprintf(1, "could not deserialize descriptor ");
 		result->port_count = 1;///\TODO this code is only for debug!!!
 		return result;
@@ -129,5 +127,5 @@
 	//finish
 
-	dprintf(1,"[usb_hub] hub info created");
+	dprintf(1, "hub info created");
 
 	return result;
@@ -136,5 +134,5 @@
 int usb_add_hub_device(device_t *dev) {
 	dprintf(1, "add_hub_device(handle=%d)", (int) dev->handle);
-	dprintf(1,"[usb_hub] hub device");
+	dprintf(1, "hub device");
 
 	/*
@@ -155,5 +153,4 @@
 	int port;
 	int opResult;
-	usb_device_request_setup_packet_t request;
 	usb_target_t target;
 	target.address = hub_info->usb_device->address;
@@ -165,12 +162,13 @@
 	usb_standard_device_descriptor_t std_descriptor;
 	opResult = usb_drv_req_get_device_descriptor(hc, target.address,
-    &std_descriptor);
+	    &std_descriptor);
 	if(opResult!=EOK){
-		dprintf(1,"[usb_hub] could not get device descriptor, %d",opResult);
+		dprintf(1, "could not get device descriptor, %d",opResult);
 		return opResult;
 	}
-	dprintf(1,"[usb_hub] hub has %d configurations",std_descriptor.configuration_count);
+	dprintf(1, "hub has %d configurations",std_descriptor.configuration_count);
 	if(std_descriptor.configuration_count<1){
-		dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
+		dprintf(1, "THERE ARE NO CONFIGURATIONS AVAILABLE");
+		//shouldn`t I return?
 	}
 	/// \TODO check other configurations
@@ -180,25 +178,22 @@
         &config_descriptor);
 	if(opResult!=EOK){
-		dprintf(1,"[usb_hub] could not get configuration descriptor, %d",opResult);
+		dprintf(1, "could not get configuration descriptor, %d",opResult);
 		return opResult;
 	}
 	//set configuration
-	request.request_type = 0;
-	request.request = USB_DEVREQ_SET_CONFIGURATION;
-	request.index=0;
-	request.length=0;
-	request.value_high=0;
-	request.value_low = config_descriptor.configuration_number;
-	opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
-	if (opResult != EOK) {
-		dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult);
-	}
-
+	opResult = usb_drv_req_set_configuration(hc, target.address,
+    config_descriptor.configuration_number);
+
+	if (opResult != EOK) {
+		dprintf(1, "something went wrong when setting hub`s configuration, %d", opResult);
+	}
+
+	usb_device_request_setup_packet_t request;
 	for (port = 1; port < hub_info->port_count+1; ++port) {
 		usb_hub_set_power_port_request(&request, port);
 		opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
-		dprintf(1,"[usb_hub] powering port %d",port);
+		dprintf(1, "powering port %d",port);
 		if (opResult != EOK) {
-			dprintf(1,"[usb_hub]something went wrong when setting hub`s %dth port", port);
+			dprintf(1, "something went wrong when setting hub`s %dth port", port);
 		}
 	}
@@ -212,5 +207,5 @@
 	futex_up(&usb_hub_list_lock);
 
-	dprintf(1,"[usb_hub] hub info added to list");
+	dprintf(1, "hub info added to list");
 	//(void)hub_info;
 	usb_hub_check_hub_changes();
@@ -218,14 +213,13 @@
 	
 
-	dprintf(1,"[usb_hub] hub dev added");
-	dprintf(1,"\taddress %d, has %d ports ",
+	dprintf(1, "hub dev added");
+	dprintf(1, "\taddress %d, has %d ports ",
 			hub_info->usb_device->address,
 			hub_info->port_count);
-	dprintf(1,"\tused configuration %d",config_descriptor.configuration_number);
+	dprintf(1, "\tused configuration %d",config_descriptor.configuration_number);
 
 	return EOK;
 	//return ENOTSUP;
 }
-
 
 
@@ -237,6 +231,6 @@
 
 /**
- * convenience function for releasing default address and writing debug info
- * (these few lines are used too often to be written again and again)
+ * Convenience function for releasing default address and writing debug info
+ * (these few lines are used too often to be written again and again).
  * @param hc
  * @return
@@ -244,8 +238,8 @@
 inline static int usb_hub_release_default_address(int hc){
 	int opResult;
-	dprintf(1,"[usb_hub] releasing default address");
+	dprintf(1, "releasing default address");
 	opResult = usb_drv_release_default_address(hc);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] failed to release default address");
+		dprintf(1, "failed to release default address");
 	}
 	return opResult;
@@ -253,5 +247,5 @@
 
 /**
- * reset the port with new device and reserve the default address
+ * Reset the port with new device and reserve the default address.
  * @param hc
  * @param port
@@ -261,9 +255,9 @@
 	usb_device_request_setup_packet_t request;
 	int opResult;
-	dprintf(1,"[usb_hub] some connection changed");
+	dprintf(1, "some connection changed");
 	//get default address
 	opResult = usb_drv_reserve_default_address(hc);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] cannot assign default address, it is probably used");
+		dprintf(1, "cannot assign default address, it is probably used");
 		return;
 	}
@@ -276,5 +270,5 @@
 			);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] something went wrong when reseting a port");
+		dprintf(1, "something went wrong when reseting a port");
 		usb_hub_release_default_address(hc);
 	}
@@ -282,5 +276,5 @@
 
 /**
- * finalize adding new device after port reset
+ * Finalize adding new device after port reset
  * @param hc
  * @param port
@@ -291,9 +285,9 @@
 
 	int opResult;
-	dprintf(1,"[usb_hub] finalizing add device");
+	dprintf(1, "finalizing add device");
 	opResult = usb_hub_clear_port_feature(hc, target.address,
 	    port, USB_HUB_FEATURE_C_PORT_RESET);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] failed to clear port reset feature");
+		dprintf(1, "failed to clear port reset feature");
 		usb_hub_release_default_address(hc);
 		return;
@@ -303,15 +297,15 @@
 	usb_address_t new_device_address = usb_drv_request_address(hc);
 	if (new_device_address < 0) {
-		dprintf(1,"[usb_hub] failed to get free USB address");
+		dprintf(1, "failed to get free USB address");
 		opResult = new_device_address;
 		usb_hub_release_default_address(hc);
 		return;
 	}
-	dprintf(1,"[usb_hub] setting new address");
+	dprintf(1, "setting new address");
 	opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
 	    new_device_address);
 
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] could not set address for new device");
+		dprintf(1, "could not set address for new device");
 		usb_hub_release_default_address(hc);
 		return;
@@ -328,5 +322,5 @@
             new_device_address, &child_handle);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] could not start driver for new device");
+		dprintf(1, "could not start driver for new device");
 		return;
 	}
@@ -336,8 +330,8 @@
 	opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] could not assign address of device in hcd");
-		return;
-	}
-	dprintf(1,"[usb_hub] new device address %d, handle %zu",
+		dprintf(1, "could not assign address of device in hcd");
+		return;
+	}
+	dprintf(1, "new device address %d, handle %zu",
 	    new_device_address, child_handle);
 
@@ -345,5 +339,5 @@
 
 /**
- * unregister device address in hc
+ * Unregister device address in hc
  * @param hc
  * @param port
@@ -355,5 +349,7 @@
 	int opResult;
 	
-	/// \TODO remove device
+	/** \TODO remove device from device manager - not yet implemented in
+	 * devide manager
+	 */
 
 	hub->attached_devs[port].devman_handle=0;
@@ -362,12 +358,10 @@
 		opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
 		if(opResult != EOK) {
-			dprintf(1,
-					"[usb_hub] could not release address of removed device: %d"
-					,opResult);
+			dprintf(1, "could not release address of " \
+			    "removed device: %d", opResult);
 		}
 		hub->attached_devs[port].address = 0;
 	}else{
-		dprintf(1,
-				"[usb_hub] this is strange, disconnected device had no address");
+		dprintf(1, "this is strange, disconnected device had no address");
 		//device was disconnected before it`s port was reset - return default address
 		usb_drv_release_default_address(hc);
@@ -376,5 +370,5 @@
 
 /**
- * process interrupts on given hub port
+ * Process interrupts on given hub port
  * @param hc
  * @param port
@@ -383,5 +377,5 @@
 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
         uint16_t port, usb_address_t address) {
-	dprintf(1,"[usb_hub] interrupt at port %d", port);
+	dprintf(1, "interrupt at port %d", port);
 	//determine type of change
 	usb_target_t target;
@@ -401,9 +395,9 @@
 			);
 	if (opResult != EOK) {
-		dprintf(1,"[usb_hub] ERROR: could not get port status");
+		dprintf(1, "ERROR: could not get port status");
 		return;
 	}
 	if (rcvd_size != sizeof (usb_port_status_t)) {
-		dprintf(1,"[usb_hub] ERROR: received status has incorrect size");
+		dprintf(1, "ERROR: received status has incorrect size");
 		return;
 	}
@@ -414,5 +408,5 @@
 		// TODO: check opResult
 		if (usb_port_dev_connected(&status)) {
-			dprintf(1,"[usb_hub] some connection changed");
+			dprintf(1, "some connection changed");
 			usb_hub_init_add_device(hc, port, target);
 		} else {
@@ -422,9 +416,9 @@
 	//port reset
 	if (usb_port_reset_completed(&status)) {
-		dprintf(1,"[usb_hub] port reset complete");
+		dprintf(1, "port reset complete");
 		if (usb_port_enabled(&status)) {
 			usb_hub_finalize_add_device(hub, hc, port, target);
 		} else {
-			dprintf(1,"[usb_hub] ERROR: port reset, but port still not enabled");
+			dprintf(1, "ERROR: port reset, but port still not enabled");
 		}
 	}
@@ -434,6 +428,7 @@
 	usb_port_set_reset_completed(&status, false);
 	usb_port_set_dev_connected(&status, false);
-	if (status) {
-		dprintf(1,"[usb_hub]there was some unsupported change on port %d",port);
+	if (status>>16) {
+		dprintf(1, "there was some unsupported change on port %d: %X",port,status);
+
 	}
 	/// \TODO handle other changes
@@ -442,5 +437,6 @@
 }
 
-/* Check changes on all known hubs.
+/**
+ * Check changes on all known hubs.
  */
 void usb_hub_check_hub_changes(void) {
@@ -462,5 +458,5 @@
 		target.address = hub_info->usb_device->address;
 		target.endpoint = 1;/// \TODO get from endpoint descriptor
-		dprintf(1,"[usb_hub] checking changes for hub at addr %d",
+		dprintf(1, "checking changes for hub at addr %d",
 		    target.address);
 
@@ -492,5 +488,5 @@
 
 		if (opResult != EOK) {
-			dprintf(1,"[usb_hub] something went wrong while getting status of hub");
+			dprintf(1, "something went wrong while getting status of hub");
 			continue;
 		}
