Index: uspace/drv/bus/usb/usbhub/usbhub.c
===================================================================
--- uspace/drv/bus/usb/usbhub/usbhub.c	(revision bf73a0275cfecb7c3ff121a201c250829d4d3ca6)
+++ uspace/drv/bus/usb/usbhub/usbhub.c	(revision ea6de35e8a0d6a57a069013d6437a9e480208432)
@@ -69,21 +69,14 @@
 static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev);
 static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info);
-static void usb_process_hub_over_current(usb_hub_info_t *hub_info,
+static void usb_hub_over_current(const usb_hub_info_t *hub_info,
     usb_hub_status_t status);
-static void usb_hub_process_global_interrupt(usb_hub_info_t *hub_info);
+static void usb_hub_global_interrupt(const usb_hub_info_t *hub_info);
 static void usb_hub_polling_terminated_callback(usb_device_t *device,
     bool was_error, void *data);
 
-
-//*********************************************
-//
-//  hub driver code, initialization
-//
-//*********************************************
-
 /**
  * Initialize hub device driver fibril
  *
- * Creates hub representation and fibril that periodically checks hub`s status.
+ * Creates hub representation and fibril that periodically checks hub's status.
  * Hub representation is passed to the fibril.
  * @param usb_dev generic usb device information
@@ -185,5 +178,5 @@
 	const bool change = change_bitmap[0] & 1;
 	if (change) {
-		usb_hub_process_global_interrupt(hub);
+		usb_hub_global_interrupt(hub);
 	}
 
@@ -221,20 +214,20 @@
 {
 	assert(usb_dev);
-	usb_hub_info_t *result = malloc(sizeof(usb_hub_info_t));
-	if (!result)
+	usb_hub_info_t *info = malloc(sizeof(usb_hub_info_t));
+	if (!info)
 	    return NULL;
 
-	result->usb_device = usb_dev;
-	result->control_pipe = &usb_dev->ctrl_pipe;
-	result->is_default_address_used = false;
-
-	result->ports = NULL;
-	result->port_count = -1;
-	fibril_mutex_initialize(&result->port_mutex);
-	fibril_mutex_initialize(&result->pending_ops_mutex);
-	fibril_condvar_initialize(&result->pending_ops_cv);
-	result->pending_ops_count = 0;
-
-	return result;
+	info->usb_device = usb_dev;
+	info->control_pipe = &usb_dev->ctrl_pipe;
+	info->is_default_address_used = false;
+
+	info->ports = NULL;
+	info->port_count = -1;
+	fibril_mutex_initialize(&info->port_mutex);
+	fibril_mutex_initialize(&info->pending_ops_mutex);
+	fibril_condvar_initialize(&info->pending_ops_cv);
+	info->pending_ops_count = 0;
+
+	return info;
 }
 
@@ -242,6 +235,6 @@
  * Load hub-specific information into hub_info structure and process if needed
  *
- * Particularly read port count and initialize structure holding port
- * information. If there are non-removable devices, start initializing them.
+ * Read port count and initialize structures holding per port information.
+ * If there are any non-removable devices, start initializing them.
  * This function is hub-specific and should be run only after the hub is
  * configured using usb_set_first_configuration function.
@@ -252,5 +245,6 @@
 {
 	assert(hub_info);
-	// get hub descriptor
+
+	/* Get hub descriptor. */
 	usb_log_debug("Retrieving descriptor\n");
 	uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
@@ -322,5 +316,5 @@
 	return EOK;
 }
-
+/*----------------------------------------------------------------------------*/
 /**
  * Set configuration of and USB device
@@ -350,5 +344,5 @@
 
 	/* Set configuration. Use the configuration that was in
-	 * usb_device->descriptors.configuration */
+	 * usb_device->descriptors.configuration i.e. The first one. */
 	const int opResult = usb_request_set_configuration(
 	    &usb_device->ctrl_pipe, config_descriptor->configuration_number);
@@ -356,20 +350,13 @@
 		usb_log_error("Failed to set hub configuration: %s.\n",
 		    str_error(opResult));
-		return opResult;
-	}
-	usb_log_debug("\tUsed configuration %d\n",
-	    config_descriptor->configuration_number);
-
-	return EOK;
-}
-
-//*********************************************
-//
-//  change handling functions
-//
-//*********************************************
-
-/**
- * process hub over current change
+	} else {
+		usb_log_debug("\tUsed configuration %d\n",
+		    config_descriptor->configuration_number);
+	}
+	return opResult;
+}
+/*----------------------------------------------------------------------------*/
+/**
+ * Process hub over current change
  *
  * This means either to power off the hub or power it on.
@@ -378,5 +365,5 @@
  * @return error code
  */
-static void usb_process_hub_over_current(usb_hub_info_t *hub_info,
+static void usb_hub_over_current(const usb_hub_info_t *hub_info,
     usb_hub_status_t status)
 {
@@ -416,11 +403,10 @@
 /*----------------------------------------------------------------------------*/
 /**
- * process hub interrupts
- *
- * The change can be either in the over-current condition or
- * local-power change.
+ * Process hub interrupts.
+ *
+ * The change can be either in the over-current condition or local-power change.
  * @param hub_info hub instance
  */
-static void usb_hub_process_global_interrupt(usb_hub_info_t *hub_info)
+static void usb_hub_global_interrupt(const usb_hub_info_t *hub_info)
 {
 	assert(hub_info);
@@ -428,10 +414,10 @@
 	usb_log_debug("Global interrupt on a hub\n");
 	usb_pipe_t *ctrlpipe = &hub_info->usb_device->ctrl_pipe;
-	int opResult;
 
 	usb_hub_status_t status;
 	size_t rcvd_size;
-
-	opResult = usb_pipe_control_read(
+	/* NOTE: We can't use standard USB GET_STATUS request, because
+	 * hubs reply is 4byte instead of 2 */
+	const int opResult = usb_pipe_control_read(
 	    ctrlpipe, &get_hub_status_request, sizeof(get_hub_status_request),
 	    &status, sizeof(usb_hub_status_t), &rcvd_size);
@@ -448,5 +434,5 @@
 	/* Handle status changes */
 	if (status & USB_HUB_STATUS_C_OVER_CURRENT)
-		usb_process_hub_over_current(hub_info, status);
+		usb_hub_over_current(hub_info, status);
 
 	if (status & USB_HUB_STATUS_C_LOCAL_POWER) {
@@ -473,5 +459,5 @@
 	}
 }
-
+/*----------------------------------------------------------------------------*/
 /**
  * callback called from hub polling fibril when the fibril terminates
@@ -483,6 +469,7 @@
  */
 static void usb_hub_polling_terminated_callback(usb_device_t *device,
-    bool was_error, void *data) {
-	usb_hub_info_t * hub = data;
+    bool was_error, void *data)
+{
+	usb_hub_info_t *hub = data;
 	assert(hub);
 
@@ -522,8 +509,4 @@
 	free(hub);
 }
-
-
-
-
 /**
  * @}
