Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision aee6c733e31cce6abb49278bbf6be466ed901caf)
+++ uspace/drv/ohci/root_hub.c	(revision 79e1abd99eedd6899d3f7ffb35c9b79040fafb5b)
@@ -43,4 +43,7 @@
 #include <usb/classes/hub.h>
 
+/**
+ *	standart device descriptor for ohci root hub
+ */
 static const usb_standard_device_descriptor_t ohci_rh_device_descriptor =
 {
@@ -61,4 +64,8 @@
 };
 
+/**
+ * standart configuration descriptor with filled common values
+ * for ohci root hubs
+ */
 static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor =
 {
@@ -73,4 +80,7 @@
 };
 
+/**
+ * standart ohci root hub interface descriptor
+ */
 static const usb_standard_interface_descriptor_t ohci_rh_iface_descriptor =
 {
@@ -87,4 +97,7 @@
 };
 
+/**
+ * standart ohci root hub endpoint descriptor
+ */
 static const usb_standard_endpoint_descriptor_t ohci_rh_ep_descriptor =
 {
@@ -273,31 +286,4 @@
 
 /**
- * create standard device descriptor for a hub
- * @return newly allocated descriptor
- */
-static usb_standard_device_descriptor_t *
-	usb_ohci_rh_create_standard_device_descriptor(){
-	usb_standard_device_descriptor_t * descriptor =
-				(usb_standard_device_descriptor_t*)
-				malloc(sizeof(usb_standard_device_descriptor_t));
-	descriptor->configuration_count = 1;
-	descriptor->descriptor_type = USB_DESCTYPE_DEVICE;
-	descriptor->device_class = USB_CLASS_HUB;
-	descriptor->device_protocol = 0;
-	descriptor->device_subclass = 0;
-	descriptor->device_version = 0;
-	descriptor->length = sizeof(usb_standard_device_descriptor_t);
-	/// \TODO this value is guessed
-	descriptor->max_packet_size = 8;
-	descriptor->product_id = 0x0001;
-	/// \TODO these values migt be different
-	descriptor->str_serial_number = 0;
-	descriptor->str_serial_number = 0;
-	descriptor->usb_spec_version = 0;
-	descriptor->vendor_id = 0x16db;
-	return descriptor;
-}
-
-/**
  * create standart configuration descriptor for the root hub instance
  * @param instance root hub instance
@@ -307,16 +293,9 @@
 usb_ohci_rh_create_standart_configuration_descriptor(rh_t *instance){
 	usb_standard_configuration_descriptor_t * descriptor =
-			(usb_standard_configuration_descriptor_t*)
 			malloc(sizeof(usb_standard_configuration_descriptor_t));
-	/// \TODO some values are default or guessed
-	descriptor->attributes = 1<<7;
-	descriptor->configuration_number = 1;
-	descriptor->descriptor_type = USB_DESCTYPE_CONFIGURATION;
-	descriptor->interface_count = 1;
-	descriptor->length = sizeof(usb_standard_configuration_descriptor_t);
-	descriptor->max_power = 100;
-	descriptor->str_configuration = 0;
+	memcpy(descriptor, &ohci_rh_conf_descriptor,
+		sizeof(usb_standard_configuration_descriptor_t));
 	/// \TODO should this include device descriptor?
-	size_t hub_descriptor_size = 7 +
+	const size_t hub_descriptor_size = 7 +
 			2* (instance->port_count / 8 +
 			((instance->port_count % 8 > 0) ? 1 : 0));
@@ -330,44 +309,4 @@
 
 /**
- * create standard interface descriptor for a root hub
- * @return newly allocated descriptor
- */
-static usb_standard_interface_descriptor_t *
-usb_ohci_rh_create_standard_interface_descriptor(){
-	usb_standard_interface_descriptor_t * descriptor =
-				(usb_standard_interface_descriptor_t*)
-				malloc(sizeof(usb_standard_interface_descriptor_t));
-	descriptor->alternate_setting = 0;
-	descriptor->descriptor_type = USB_DESCTYPE_INTERFACE;
-	descriptor->endpoint_count = 1;
-	descriptor->interface_class = USB_CLASS_HUB;
-	/// \TODO is this correct?
-	descriptor->interface_number = 1;
-	descriptor->interface_protocol = 0;
-	descriptor->interface_subclass = 0;
-	descriptor->length = sizeof(usb_standard_interface_descriptor_t);
-	descriptor->str_interface = 0;
-	return descriptor;
-}
-
-/**
- * create standard endpoint descriptor for a root hub
- * @return newly allocated descriptor
- */
-static usb_standard_endpoint_descriptor_t *
-usb_ohci_rh_create_standard_endpoint_descriptor(){
-	usb_standard_endpoint_descriptor_t * descriptor =
-			(usb_standard_endpoint_descriptor_t*)
-			malloc(sizeof(usb_standard_endpoint_descriptor_t));
-	descriptor->attributes = USB_TRANSFER_INTERRUPT;
-	descriptor->descriptor_type = USB_DESCTYPE_ENDPOINT;
-	descriptor->endpoint_address = 1 + (1<<7);
-	descriptor->length = sizeof(usb_standard_endpoint_descriptor_t);
-	descriptor->max_packet_size = 8;
-	descriptor->poll_interval = 255;
-	return descriptor;
-}
-
-/**
  * create answer to a descriptor request
  *
@@ -386,106 +325,54 @@
 	const uint16_t setup_request_value = setup_request->value_high;
 			//(setup_request->value_low << 8);
-#if 0
 	bool del = false;
-	//this code was merged from development and has to be reviewed
 	switch (setup_request_value)
 	{
-	case USB_DESCTYPE_HUB: {
-		uint8_t * descriptor;
-		usb_create_serialized_hub_descriptor(
-		    instance, &descriptor, &size);
-		result_descriptor = descriptor;
-		break;
-	}
-	case USB_DESCTYPE_DEVICE: {
-		usb_log_debug("USB_DESCTYPE_DEVICE\n");
-		result_descriptor = &ohci_rh_device_descriptor;
-		size = sizeof(ohci_rh_device_descriptor);
-		break;
-	}
-	case USB_DESCTYPE_CONFIGURATION: {
-		usb_log_debug("USB_DESCTYPE_CONFIGURATION\n");
-		usb_standard_configuration_descriptor_t * descriptor =
-				malloc(sizeof(usb_standard_configuration_descriptor_t));
-		memcpy(descriptor, &ohci_rh_conf_descriptor,
-		    sizeof(usb_standard_configuration_descriptor_t));
-		/// \TODO should this include device descriptor?
-		const size_t hub_descriptor_size = 7 +
-				2* (instance->port_count / 8 +
-				((instance->port_count % 8 > 0) ? 1 : 0));
-		descriptor->total_length =
-				sizeof(usb_standard_configuration_descriptor_t)+
-				sizeof(usb_standard_endpoint_descriptor_t)+
-				sizeof(usb_standard_interface_descriptor_t)+
-				hub_descriptor_size;
-		result_descriptor = descriptor;
-		size = sizeof(usb_standard_configuration_descriptor_t);
-		del = true;
-		break;
-	}
-	case USB_DESCTYPE_INTERFACE: {
-		usb_log_debug("USB_DESCTYPE_INTERFACE\n");
-		result_descriptor = &ohci_rh_iface_descriptor;
-		size = sizeof(ohci_rh_iface_descriptor);
-		break;
-	}
-	case USB_DESCTYPE_ENDPOINT: {
-		usb_log_debug("USB_DESCTYPE_ENDPOINT\n");
-		result_descriptor = &ohci_rh_ep_descriptor;
-		size = sizeof(ohci_rh_ep_descriptor);
-		break;
-	}
-	default: {
-		usb_log_debug("USB_DESCTYPE_EINVAL %d \n",setup_request->value);
-		usb_log_debug("\ttype %d\n\trequest %d\n\tvalue %d\n\tindex %d\n\tlen %d\n ",
-				setup_request->request_type,
-				setup_request->request,
-				setup_request_value,
-				setup_request->index,
-				setup_request->length
-				);
-		return EINVAL;
-	}
-	}
-#endif
-	if(setup_request_value == USB_DESCTYPE_HUB){
-		usb_log_debug("USB_DESCTYPE_HUB\n");
-		//create hub descriptor
-		uint8_t * descriptor;
-		usb_create_serialized_hub_descriptor(instance, 
-				&descriptor, &size);
-		result_descriptor = descriptor;
-	}else if(setup_request_value == USB_DESCTYPE_DEVICE){
-		//create std device descriptor
-		usb_log_debug("USB_DESCTYPE_DEVICE\n");
-		result_descriptor =
-				usb_ohci_rh_create_standard_device_descriptor();
-		size = sizeof(usb_standard_device_descriptor_t);
-	}else if(setup_request_value == USB_DESCTYPE_CONFIGURATION){
-		usb_log_debug("USB_DESCTYPE_CONFIGURATION\n");
-		result_descriptor =
-				usb_ohci_rh_create_standart_configuration_descriptor(instance);
-		size = sizeof(usb_standard_configuration_descriptor_t);
-
-	}else if(setup_request_value == USB_DESCTYPE_INTERFACE){
-		usb_log_debug("USB_DESCTYPE_INTERFACE\n");
-		result_descriptor =
-				usb_ohci_rh_create_standard_interface_descriptor();
-		size = sizeof(usb_standard_interface_descriptor_t);
-	}else if(setup_request_value == USB_DESCTYPE_ENDPOINT){
-		usb_log_debug("USB_DESCTYPE_ENDPOINT\n");
-		result_descriptor =
-				usb_ohci_rh_create_standard_endpoint_descriptor();
-		size = sizeof(usb_standard_endpoint_descriptor_t);
-	}else{
-		usb_log_debug("USB_DESCTYPE_EINVAL %d \n",setup_request->value);
-		usb_log_debug("\ttype %d\n\trequest %d\n\tvalue %d\n\tindex %d\n\tlen %d\n ",
-				setup_request->request_type,
-				setup_request->request,
-				setup_request_value,
-				setup_request->index,
-				setup_request->length
-				);
-		return EINVAL;
+		case USB_DESCTYPE_HUB: {
+			uint8_t * descriptor;
+			usb_create_serialized_hub_descriptor(
+				instance, &descriptor, &size);
+			result_descriptor = descriptor;
+			if(result_descriptor) del = true;
+			break;
+		}
+		case USB_DESCTYPE_DEVICE: {
+			usb_log_debug("USB_DESCTYPE_DEVICE\n");
+			result_descriptor = &ohci_rh_device_descriptor;
+			size = sizeof(ohci_rh_device_descriptor);
+			break;
+		}
+		case USB_DESCTYPE_CONFIGURATION: {
+			usb_log_debug("USB_DESCTYPE_CONFIGURATION\n");
+			usb_standard_configuration_descriptor_t * descriptor =
+					usb_ohci_rh_create_standart_configuration_descriptor(
+						instance);
+			result_descriptor = descriptor;
+			size = sizeof(usb_standard_configuration_descriptor_t);
+			del = true;
+			break;
+		}
+		case USB_DESCTYPE_INTERFACE: {
+			usb_log_debug("USB_DESCTYPE_INTERFACE\n");
+			result_descriptor = &ohci_rh_iface_descriptor;
+			size = sizeof(ohci_rh_iface_descriptor);
+			break;
+		}
+		case USB_DESCTYPE_ENDPOINT: {
+			usb_log_debug("USB_DESCTYPE_ENDPOINT\n");
+			result_descriptor = &ohci_rh_ep_descriptor;
+			size = sizeof(ohci_rh_ep_descriptor);
+			break;
+		}
+		default: {
+			usb_log_debug("USB_DESCTYPE_EINVAL %d \n",setup_request->value);
+			usb_log_debug("\ttype %d\n\trequest %d\n\tvalue %d\n\tindex %d\n\tlen %d\n ",
+					setup_request->request_type,
+					setup_request->request,
+					setup_request_value,
+					setup_request->index,
+					setup_request->length
+					);
+			return EINVAL;
+		}
 	}
 	if(request->buffer_size < size){
@@ -494,5 +381,5 @@
 	request->transfered_size = size;
 	memcpy(request->buffer,result_descriptor,size);
-	if (result_descriptor)
+	if (del)
 		free(result_descriptor);
 	return EOK;
@@ -761,5 +648,5 @@
 void rh_interrupt(rh_t *instance)
 {
-	usb_log_info("Whoa whoa wait, I`m not supposed to receive interrupts, am I?\n");
+	usb_log_info("Whoa whoa wait, I`m not supposed to receive any interrupts, am I?\n");
 	/* TODO: implement? */
 }
