Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 6c399765066bb4c35f189205cab7bbd61db00d88)
+++ uspace/drv/usbhub/usbhub.c	(revision 195890bda66ae3a7eba6423621ee7ce2d6cd1ebf)
@@ -55,8 +55,8 @@
 
 static int usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-		usb_speed_t speed);
+	usb_speed_t speed);
 
 static int usb_hub_trigger_connecting_non_removable_devices(
-		usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);
+	usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);
 
 /**
@@ -69,14 +69,15 @@
  * @return zero
  */
-int usb_hub_control_loop(void * hub_info_param){
-	usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param;
+int usb_hub_control_loop(void * hub_info_param) {
+	usb_hub_info_t * hub_info = (usb_hub_info_t*) hub_info_param;
 	int errorCode = EOK;
 
-	while(errorCode == EOK){
-		async_usleep(1000 * 1000 * 10 );/// \TODO proper number once
+	while (errorCode == EOK) {
+		async_usleep(1000 * 1000 * 10); /// \TODO proper number once
 		errorCode = usb_hub_check_hub_changes(hub_info);
-		
-	}
-	usb_log_error("something in ctrl loop went wrong, errno %d\n",errorCode);
+
+	}
+	usb_log_error("something in ctrl loop went wrong, errno %d\n",
+		errorCode);
 
 	return 0;
@@ -99,5 +100,5 @@
 static usb_hub_info_t * usb_hub_info_create(usb_device_t * usb_dev) {
 	usb_hub_info_t * result = usb_new(usb_hub_info_t);
-	if(!result) return NULL;
+	if (!result) return NULL;
 	result->usb_device = usb_dev;
 	result->status_change_pipe = usb_dev->pipes[0].pipe;
@@ -117,5 +118,5 @@
  * @return error code
  */
-static int usb_hub_process_hub_specific_info(usb_hub_info_t * hub_info){
+static int usb_hub_process_hub_specific_info(usb_hub_info_t * hub_info) {
 	// get hub descriptor
 	usb_log_debug("creating serialized descriptor\n");
@@ -128,21 +129,23 @@
 	 */
 	int opResult = usb_request_set_configuration(hub_info->control_pipe,
-			1);
-	if(opResult!=EOK){
-		usb_log_error("could not set default configuration, errno %d",opResult);
-		return opResult;
-	}
-	 
-	 
+		1);
+	if (opResult != EOK) {
+		usb_log_error("could not set default configuration, errno %d",
+			opResult);
+		return opResult;
+	}
+
+
 	size_t received_size;
 	opResult = usb_request_get_descriptor(&hub_info->usb_device->ctrl_pipe,
-			USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
-			USB_DESCTYPE_HUB,
-			0, 0, serialized_descriptor,
-			USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
-
-	if (opResult != EOK) {
-		usb_log_error("failed when receiving hub descriptor, badcode = %d\n",
-				opResult);
+		USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
+		USB_DESCTYPE_HUB,
+		0, 0, serialized_descriptor,
+		USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
+
+	if (opResult != EOK) {
+		usb_log_error("failed when receiving hub descriptor, "
+			"badcode = %d\n",
+			opResult);
 		free(serialized_descriptor);
 		return opResult;
@@ -150,16 +153,18 @@
 	usb_log_debug2("deserializing descriptor\n");
 	descriptor = usb_deserialize_hub_desriptor(serialized_descriptor);
-	if(descriptor==NULL){
+	if (descriptor == NULL) {
 		usb_log_warning("could not deserialize descriptor \n");
 		return opResult;
 	}
-	usb_log_debug("setting port count to %d\n",descriptor->ports_count);
+	usb_log_debug("setting port count to %d\n", descriptor->ports_count);
 	hub_info->port_count = descriptor->ports_count;
 	hub_info->attached_devs = (usb_hc_attached_device_t*)
-	    malloc((hub_info->port_count+1) * sizeof(usb_hc_attached_device_t));
+		malloc((hub_info->port_count + 1) *
+			sizeof (usb_hc_attached_device_t)
+		);
 	int i;
-	for(i=0;i<hub_info->port_count+1;++i){
-		hub_info->attached_devs[i].handle=0;
-		hub_info->attached_devs[i].address=0;
+	for (i = 0; i < hub_info->port_count + 1; ++i) {
+		hub_info->attached_devs[i].handle = 0;
+		hub_info->attached_devs[i].address = 0;
 	}
 	//handle non-removable devices
@@ -169,8 +174,8 @@
 	hub_info->descriptor = descriptor;
 	hub_info->not_initialized_non_removables =
-		(uint8_t*)malloc((hub_info->port_count+8)/8);
+		(uint8_t*) malloc((hub_info->port_count + 8) / 8);
 	memcpy(hub_info->not_initialized_non_removables,
 		descriptor->devices_removable,
-		(hub_info->port_count+8)/8
+		(hub_info->port_count + 8) / 8
 		);
 
@@ -179,4 +184,5 @@
 	return EOK;
 }
+
 /**
  * Set configuration of hub
@@ -187,11 +193,11 @@
  * @return error code
  */
-static int usb_hub_set_configuration(usb_hub_info_t * hub_info){
+static int usb_hub_set_configuration(usb_hub_info_t * hub_info) {
 	//device descriptor
 	usb_standard_device_descriptor_t *std_descriptor
-	    = &hub_info->usb_device->descriptors.device;
+		= &hub_info->usb_device->descriptors.device;
 	usb_log_debug("hub has %d configurations\n",
-	    std_descriptor->configuration_count);
-	if(std_descriptor->configuration_count<1){
+		std_descriptor->configuration_count);
+	if (std_descriptor->configuration_count < 1) {
 		usb_log_error("there are no configurations available\n");
 		return EINVAL;
@@ -199,19 +205,19 @@
 
 	usb_standard_configuration_descriptor_t *config_descriptor
-	    = (usb_standard_configuration_descriptor_t *)
-	    hub_info->usb_device->descriptors.configuration;
+		= (usb_standard_configuration_descriptor_t *)
+		hub_info->usb_device->descriptors.configuration;
 
 	/* Set configuration. */
 	int opResult = usb_request_set_configuration(
-	    &hub_info->usb_device->ctrl_pipe,
-	    config_descriptor->configuration_number);
+		&hub_info->usb_device->ctrl_pipe,
+		config_descriptor->configuration_number);
 
 	if (opResult != EOK) {
 		usb_log_error("Failed to set hub configuration: %s.\n",
-		    str_error(opResult));
+			str_error(opResult));
 		return opResult;
 	}
 	usb_log_debug("\tused configuration %d\n",
-			config_descriptor->configuration_number);
+		config_descriptor->configuration_number);
 
 	return EOK;
@@ -226,24 +232,26 @@
  * @return error code
  */
-int usb_hub_add_device(usb_device_t * usb_dev){
-	if(!usb_dev) return EINVAL;
+int usb_hub_add_device(usb_device_t * usb_dev) {
+	if (!usb_dev) return EINVAL;
 	usb_hub_info_t * hub_info = usb_hub_info_create(usb_dev);
 	//create hc connection
 	usb_log_debug("Initializing USB wire abstraction.\n");
 	int opResult = usb_hc_connection_initialize_from_device(
-			&hub_info->connection,
-			hub_info->usb_device->ddf_dev);
-	if(opResult != EOK){
-		usb_log_error("could not initialize connection to device, errno %d\n",
-				opResult);
+		&hub_info->connection,
+		hub_info->usb_device->ddf_dev);
+	if (opResult != EOK) {
+		usb_log_error("could not initialize connection to device, "
+			"errno %d\n",
+			opResult);
 		free(hub_info);
 		return opResult;
 	}
-	
+
 	usb_pipe_start_session(hub_info->control_pipe);
 	//set hub configuration
 	opResult = usb_hub_set_configuration(hub_info);
-	if(opResult!=EOK){
-		usb_log_error("could not set hub configuration, errno %d\n",opResult);
+	if (opResult != EOK) {
+		usb_log_error("could not set hub configuration, errno %d\n",
+			opResult);
 		free(hub_info);
 		return opResult;
@@ -251,6 +259,7 @@
 	//get port count and create attached_devs
 	opResult = usb_hub_process_hub_specific_info(hub_info);
-	if(opResult!=EOK){
-		usb_log_error("could not set hub configuration, errno %d\n",opResult);
+	if (opResult != EOK) {
+		usb_log_error("could not set hub configuration, errno %d\n",
+			opResult);
 		free(hub_info);
 		return opResult;
@@ -262,5 +271,5 @@
 	usb_log_debug("Creating `hub' function.\n");
 	ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
-			fun_exposed, "hub");
+		fun_exposed, "hub");
 	assert(hub_fun != NULL);
 	hub_fun->ops = NULL;
@@ -274,5 +283,6 @@
 	fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
 	if (fid == 0) {
-		usb_log_error("failed to start monitoring fibril for new hub.\n");
+		usb_log_error("failed to start monitoring fibril for new"
+			" hub.\n");
 		return ENOMEM;
 	}
@@ -281,5 +291,5 @@
 
 	usb_log_info("Controlling hub `%s' (%d ports).\n",
-	    hub_info->usb_device->ddf_dev->name, hub_info->port_count);
+		hub_info->usb_device->ddf_dev->name, hub_info->port_count);
 	return EOK;
 }
@@ -302,7 +312,6 @@
  */
 static int usb_hub_trigger_connecting_non_removable_devices(
-		usb_hub_info_t * hub,
-		usb_hub_descriptor_t * descriptor)
-{
+	usb_hub_info_t * hub,
+	usb_hub_descriptor_t * descriptor) {
 	usb_log_info("attaching non-removable devices(if any)\n");
 	//usb_device_request_setup_packet_t request;
@@ -314,73 +323,89 @@
 
 	opResult = usb_request_set_configuration(hub->control_pipe,
-			1);
-	if(opResult!=EOK){
-		usb_log_error("could not set default configuration, errno %d",opResult);
+		1);
+	if (opResult != EOK) {
+		usb_log_error("could not set default configuration, errno %d",
+			opResult);
 		return opResult;
 	}
 #if 0
-	for(port=1;port<=descriptor->ports_count;++port){
+	for (port = 1; port <= descriptor->ports_count; ++port) {
 		bool is_non_removable =
-				((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;
-		if(is_non_removable){
-			usb_log_debug("non-removable device on port %d\n",port);
+			((non_removable_dev_bitmap[port / 8]) >> (port % 8)) % 2;
+		if (is_non_removable) {
+			usb_log_debug("non-removable device on port %d\n", port);
 			usb_hub_set_port_status_request(&request, port);
 			opResult = usb_pipe_control_read(
-					hub->control_pipe,
-					&request, sizeof(usb_device_request_setup_packet_t),
-					&status, 4, &rcvd_size
-					);
+				hub->control_pipe,
+				&request,
+				sizeof (usb_device_request_setup_packet_t),
+				&status, 4, &rcvd_size
+				);
 			if (opResult != EOK) {
-				usb_log_error("could not get port status of port %d errno:%d\n",
-						port, opResult);
+				usb_log_error("could not get port status of "
+					"port %d errno:%d\n",
+					port, opResult);
 				return opResult;
 			}
 			//try to reset port
-			if(usb_port_dev_connected(&status) || true){
-				usb_hub_set_enable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_PORT_RESET);
+			if (usb_port_dev_connected(&status) || true) {
+				usb_hub_set_enable_port_feature_request(
+					&request, port,
+					USB_HUB_FEATURE_PORT_RESET);
 				opResult = usb_pipe_control_read(
-						hub->control_pipe,
-						&request, sizeof(usb_device_request_setup_packet_t),
-						&status, 4, &rcvd_size
-						);
+					hub->control_pipe,
+					&request,
+					sizeof (usb_device_request_setup_packet_t),
+					&status, 4, &rcvd_size
+					);
 				if (opResult != EOK) {
 					usb_log_warning(
-							"could not reset port %d errno:%d\n",
-							port, opResult);
+						"could not reset port %d "
+						"errno:%d\n",
+						port, opResult);
 				}
-				usb_log_debug("port reset, should look like %d,x%x\n",
-						(1<<USB_HUB_FEATURE_PORT_RESET),
-						(1<<USB_HUB_FEATURE_PORT_RESET)
-						);
+				usb_log_debug("port reset, should look like "
+					"%d,x%x\n",
+					(1 << USB_HUB_FEATURE_PORT_RESET),
+					(1 << USB_HUB_FEATURE_PORT_RESET)
+					);
 			}
-			//set the status change bit, so it will be noticed in driver loop
-			if(usb_port_dev_connected(&status) && false){
-				usb_hub_set_disable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_PORT_CONNECTION);
+			//set the status change bit, so it will be noticed
+			//in driver loop
+			if (usb_port_dev_connected(&status) && false) {
+				usb_hub_set_disable_port_feature_request(
+					&request, port,
+					USB_HUB_FEATURE_PORT_CONNECTION);
 				opResult = usb_pipe_control_read(
-						hub->control_pipe,
-						&request, sizeof(usb_device_request_setup_packet_t),
-						&status, 4, &rcvd_size
-						);
+					hub->control_pipe,
+					&request,
+					sizeof (usb_device_request_setup_packet_t),
+					&status, 4, &rcvd_size
+					);
 				if (opResult != EOK) {
 					usb_log_warning(
-							"could not clear port connection on port %d errno:%d\n",
-							port, opResult);
+						"could not clear port "
+						"connection on port %d "
+						"errno:%d\n",
+						port, opResult);
 				}
 				usb_log_debug("cleared port connection\n");
-				usb_hub_set_enable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_PORT_ENABLE);
+				usb_hub_set_enable_port_feature_request(&request,
+					port,
+					USB_HUB_FEATURE_PORT_ENABLE);
 				opResult = usb_pipe_control_read(
-						hub->control_pipe,
-						&request, sizeof(usb_device_request_setup_packet_t),
-						&status, 4, &rcvd_size
-						);
+					hub->control_pipe,
+					&request,
+					sizeof (usb_device_request_setup_packet_t),
+					&status, 4, &rcvd_size
+					);
 				if (opResult != EOK) {
 					usb_log_warning(
-							"could not set port enabled on port %d errno:%d\n",
-							port, opResult);
+						"could not set port enabled "
+						"on port %d errno:%d\n",
+						port, opResult);
 				}
-				usb_log_debug("port set to enabled - should lead to connection change\n");
+				usb_log_debug("port set to enabled - "
+					"should lead to connection change\n");
 			}
 		}
@@ -389,9 +414,10 @@
 
 	/// \TODO this is just a debug code
-	for(port=1;port<=descriptor->ports_count;++port){
+	for (port = 1; port <= descriptor->ports_count; ++port) {
 		bool is_non_removable =
-				((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;
-		if(is_non_removable){
-			usb_log_debug("CHECKING port %d is non-removable\n",port);
+			((non_removable_dev_bitmap[port / 8]) >> (port % 8)) % 2;
+		if (is_non_removable) {
+			usb_log_debug("CHECKING port %d is non-removable\n",
+				port);
 			usb_port_status_t status;
 			size_t rcvd_size;
@@ -401,13 +427,16 @@
 			//endpoint 0
 			opResult = usb_pipe_control_read(
-					hub->control_pipe,
-					&request, sizeof(usb_device_request_setup_packet_t),
-					&status, 4, &rcvd_size
-					);
+				hub->control_pipe,
+				&request,
+				sizeof (usb_device_request_setup_packet_t),
+				&status, 4, &rcvd_size
+				);
 			if (opResult != EOK) {
-				usb_log_error("could not get port status %d\n",opResult);
+				usb_log_error("could not get port status %d\n",
+					opResult);
 			}
 			if (rcvd_size != sizeof (usb_port_status_t)) {
-				usb_log_error("received status has incorrect size\n");
+				usb_log_error("received status has incorrect"
+					" size\n");
 			}
 			//something connected/disconnected
@@ -415,6 +444,6 @@
 				usb_log_debug("some connection changed\n");
 			}
-			usb_log_debug("status: %s\n",usb_debug_str_buffer(
-					(uint8_t *)&status,4,4));
+			usb_log_debug("status: %s\n", usb_debug_str_buffer(
+				(uint8_t *) & status, 4, 4));
 		}
 	}
@@ -422,5 +451,4 @@
 	return EOK;
 }
-
 
 /**
@@ -432,8 +460,9 @@
  * @return error code
  */
-static int usb_hub_release_default_address(usb_hub_info_t * hub){
+static int usb_hub_release_default_address(usb_hub_info_t * hub) {
 	int opResult = usb_hc_release_default_address(&hub->connection);
-	if(opResult!=EOK){
-		usb_log_error("could not release default address, errno %d\n",opResult);
+	if (opResult != EOK) {
+		usb_log_error("could not release default address, errno %d\n",
+			opResult);
 		return opResult;
 	}
@@ -450,22 +479,23 @@
  */
 static int usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-		usb_speed_t speed) {
+	usb_speed_t speed) {
 	//if this hub already uses default address, it cannot request it once more
-	if(hub->is_default_address_used) return EREFUSED;
+	if (hub->is_default_address_used) return EREFUSED;
 	usb_log_debug("some connection changed\n");
 	assert(hub->control_pipe->hc_phone);
 	int opResult = usb_hub_clear_port_feature(hub->control_pipe,
-				port, USB_HUB_FEATURE_C_PORT_CONNECTION);
-	if(opResult != EOK){
+		port, USB_HUB_FEATURE_C_PORT_CONNECTION);
+	if (opResult != EOK) {
 		usb_log_warning("could not clear port-change-connection flag\n");
 	}
 	usb_device_request_setup_packet_t request;
-	
+
 	//get default address
 	opResult = usb_hc_reserve_default_address(&hub->connection, speed);
-	
-	if (opResult != EOK) {
-		usb_log_warning("cannot assign default address, it is probably used %d\n",
-				opResult);
+
+	if (opResult != EOK) {
+		usb_log_warning("cannot assign default address, it is probably "
+			"used %d\n",
+			opResult);
 		return opResult;
 	}
@@ -474,10 +504,11 @@
 	usb_hub_set_reset_port_request(&request, port);
 	opResult = usb_pipe_control_write(
-			hub->control_pipe,
-			&request,sizeof(usb_device_request_setup_packet_t),
-			NULL, 0
-			);
-	if (opResult != EOK) {
-		usb_log_error("something went wrong when reseting a port %d\n",opResult);
+		hub->control_pipe,
+		&request, sizeof (usb_device_request_setup_packet_t),
+		NULL, 0
+		);
+	if (opResult != EOK) {
+		usb_log_error("something went wrong when reseting a port %d\n",
+			opResult);
 		usb_hub_release_default_address(hub);
 	}
@@ -493,11 +524,11 @@
  * @param speed transfer speed of attached device, one of low, full or high
  */
-static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
-		uint16_t port, usb_speed_t speed) {
+static void usb_hub_finalize_add_device(usb_hub_info_t * hub,
+	uint16_t port, usb_speed_t speed) {
 
 	int opResult;
 	usb_log_debug("finalizing add device\n");
 	opResult = usb_hub_clear_port_feature(hub->control_pipe,
-	    port, USB_HUB_FEATURE_C_PORT_RESET);
+		port, USB_HUB_FEATURE_C_PORT_RESET);
 
 	if (opResult != EOK) {
@@ -510,17 +541,17 @@
 	usb_device_connection_t new_device_connection;
 	usb_device_connection_initialize_on_default_address(
-			&new_device_connection,
-			&hub->connection
-			);
+		&new_device_connection,
+		&hub->connection
+		);
 	usb_pipe_initialize_default_control(
-			&new_device_pipe,
-			&new_device_connection);
+		&new_device_pipe,
+		&new_device_connection);
 	usb_pipe_probe_default_control(&new_device_pipe);
 
 	/* Request address from host controller. */
 	usb_address_t new_device_address = usb_hc_request_address(
-			&hub->connection,
-			speed
-			);
+		&hub->connection,
+		speed
+		);
 	if (new_device_address < 0) {
 		usb_log_error("failed to get free USB address\n");
@@ -529,12 +560,14 @@
 		return;
 	}
-	usb_log_debug("setting new address %d\n",new_device_address);
+	usb_log_debug("setting new address %d\n", new_device_address);
 	//opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
 	//    new_device_address);
 	usb_pipe_start_session(&new_device_pipe);
-	opResult = usb_request_set_address(&new_device_pipe,new_device_address);
+	opResult = usb_request_set_address(&new_device_pipe,
+		new_device_address);
 	usb_pipe_end_session(&new_device_pipe);
 	if (opResult != EOK) {
-		usb_log_error("could not set address for new device %d\n",opResult);
+		usb_log_error("could not set address for new device %d\n",
+			opResult);
 		usb_hub_release_default_address(hub);
 		return;
@@ -543,5 +576,5 @@
 	//opResult = usb_hub_release_default_address(hc);
 	opResult = usb_hub_release_default_address(hub);
-	if(opResult!=EOK){
+	if (opResult != EOK) {
 		return;
 	}
@@ -549,10 +582,12 @@
 	devman_handle_t child_handle;
 	//??
-    opResult = usb_device_register_child_in_devman(new_device_address,
-            hub->connection.hc_handle, hub->usb_device->ddf_dev, &child_handle,
-            NULL, NULL, NULL);
-
-	if (opResult != EOK) {
-		usb_log_error("could not start driver for new device %d\n",opResult);
+	opResult = usb_device_register_child_in_devman(new_device_address,
+		hub->connection.hc_handle, hub->usb_device->ddf_dev,
+		&child_handle,
+		NULL, NULL, NULL);
+
+	if (opResult != EOK) {
+		usb_log_error("could not start driver for new device %d\n",
+			opResult);
 		return;
 	}
@@ -562,14 +597,15 @@
 	//opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
 	opResult = usb_hc_register_device(
-			&hub->connection,
-			&hub->attached_devs[port]);
-	if (opResult != EOK) {
-		usb_log_error("could not assign address of device in hcd %d\n",opResult);
+		&hub->connection,
+		&hub->attached_devs[port]);
+	if (opResult != EOK) {
+		usb_log_error("could not assign address of device in hcd %d\n",
+			opResult);
 		return;
 	}
 	usb_log_info("Detected new device on `%s' (port %d), " \
 	    "address %d (handle %llu).\n",
-	    hub->usb_device->ddf_dev->name, (int) port,
-	    new_device_address, child_handle);
+		hub->usb_device->ddf_dev->name, (int) port,
+		new_device_address, child_handle);
 }
 
@@ -584,9 +620,9 @@
  */
 static void usb_hub_removed_device(
-    usb_hub_info_t * hub,uint16_t port) {
+	usb_hub_info_t * hub, uint16_t port) {
 
 	int opResult = usb_hub_clear_port_feature(hub->control_pipe,
-				port, USB_HUB_FEATURE_C_PORT_CONNECTION);
-	if(opResult != EOK){
+		port, USB_HUB_FEATURE_C_PORT_CONNECTION);
+	if (opResult != EOK) {
 		usb_log_warning("could not clear port-change-connection flag\n");
 	}
@@ -594,12 +630,14 @@
 	 * devide manager
 	 */
-	
+
 	//close address
-	if(hub->attached_devs[port].address!=0){
+	if (hub->attached_devs[port].address != 0) {
 		/*uncomment this code to use it when DDF allows device removal
 		opResult = usb_hc_unregister_device(
-				&hub->connection, hub->attached_devs[port].address);
+			&hub->connection,
+			hub->attached_devs[port].address);
 		if(opResult != EOK) {
-			dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \
+			dprintf(USB_LOG_LEVEL_WARNING, "could not release "
+				"address of "
 			    "removed device: %d", opResult);
 		}
@@ -607,15 +645,16 @@
 		hub->attached_devs[port].handle = 0;
 		 */
-	}else{
-		usb_log_warning("this is strange, disconnected device had no address\n");
-		//device was disconnected before it`s port was reset - return default address
+	} else {
+		usb_log_warning("this is strange, disconnected device had "
+			"no address\n");
+		//device was disconnected before it`s port was reset -
+		//return default address
 		usb_hub_release_default_address(hub);
 	}
 }
 
-
 /**
  * Process over current condition on port.
- * 
+ *
  * Turn off the power on the port.
  *
@@ -623,12 +662,12 @@
  * @param port port number, starting from 1
  */
-static void usb_hub_over_current( usb_hub_info_t * hub,
-		uint16_t port){
+static void usb_hub_over_current(usb_hub_info_t * hub,
+	uint16_t port) {
 	int opResult;
 	opResult = usb_hub_clear_port_feature(hub->control_pipe,
-	    port, USB_HUB_FEATURE_PORT_POWER);
-	if(opResult!=EOK){
+		port, USB_HUB_FEATURE_PORT_POWER);
+	if (opResult != EOK) {
 		usb_log_error("cannot power off port %d;  %d\n",
-				port, opResult);
+			port, opResult);
 	}
 }
@@ -641,10 +680,10 @@
  * @param port port number, starting from 1
  */
-static void usb_hub_process_interrupt(usb_hub_info_t * hub, 
-        uint16_t port) {
+static void usb_hub_process_interrupt(usb_hub_info_t * hub,
+	uint16_t port) {
 	usb_log_debug("interrupt at port %d\n", port);
 	//determine type of change
 	usb_pipe_t *pipe = hub->control_pipe;
-	
+
 	int opResult;
 
@@ -657,8 +696,8 @@
 
 	opResult = usb_pipe_control_read(
-			pipe,
-			&request, sizeof(usb_device_request_setup_packet_t),
-			&status, 4, &rcvd_size
-			);
+		pipe,
+		&request, sizeof (usb_device_request_setup_packet_t),
+		&status, 4, &rcvd_size
+		);
 	if (opResult != EOK) {
 		usb_log_error("could not get port status\n");
@@ -674,5 +713,6 @@
 		if (usb_port_dev_connected(&status)) {
 			usb_log_debug("some connection changed\n");
-			usb_hub_init_add_device(hub, port, usb_port_speed(&status));
+			usb_hub_init_add_device(hub, port,
+				usb_port_speed(&status));
 		} else {
 			usb_hub_removed_device(hub, port);
@@ -683,9 +723,10 @@
 		//check if it was not auto-resolved
 		usb_log_debug("overcurrent change on port\n");
-		if(usb_port_over_current(&status)){
-			usb_hub_over_current(hub,port);
-		}else{
-			usb_log_debug("over current condition was auto-resolved on port %d\n",
-					port);
+		if (usb_port_over_current(&status)) {
+			usb_hub_over_current(hub, port);
+		} else {
+			usb_log_debug("over current condition was "
+				"auto-resolved on port %d\n",
+				port);
 		}
 	}
@@ -694,10 +735,12 @@
 		usb_log_debug("port reset complete\n");
 		if (usb_port_enabled(&status)) {
-			usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
+			usb_hub_finalize_add_device(hub, port,
+				usb_port_speed(&status));
 		} else {
-			usb_log_warning("port reset, but port still not enabled\n");
+			usb_log_warning("port reset, but port still not "
+				"enabled\n");
 		}
 	}
-	usb_log_debug("status x%x : %d\n ",status,status);
+	usb_log_debug("status x%x : %d\n ", status, status);
 
 	usb_port_set_connect_change(&status, false);
@@ -705,17 +748,16 @@
 	usb_port_set_reset_completed(&status, false);
 	usb_port_set_dev_connected(&status, false);
-	if (status>>16) {
+	if (status >> 16) {
 		usb_log_info("there was some unsupported change on port %d: %X\n",
-				port,status);
-
-	}
-}
-
+			port, status);
+
+	}
+}
 
 static int initialize_non_removable(usb_hub_info_t * hub_info,
-	unsigned int port){
+	unsigned int port) {
 	int opResult;
 	usb_log_debug("there is not pluged in non-removable device on "
-		"port %d\n",port
+		"port %d\n", port
 		);
 	//usb_hub_init_add_device(hub_info, port, usb_port_speed(&status));
@@ -728,10 +770,10 @@
 
 	opResult = usb_pipe_control_read(
-			hub_info->control_pipe,
-			&request, sizeof(usb_device_request_setup_packet_t),
-			&status, 4, &rcvd_size
-			);
-	if (opResult != EOK) {
-		usb_log_error("could not get port status %d\n",opResult);
+		hub_info->control_pipe,
+		&request, sizeof (usb_device_request_setup_packet_t),
+		&status, 4, &rcvd_size
+		);
+	if (opResult != EOK) {
+		usb_log_error("could not get port status %d\n", opResult);
 		return opResult;
 	}
@@ -740,10 +782,11 @@
 		return opResult;
 	}
-	usb_log_debug("port status %d, x%x\n",status,status);
-	if(usb_port_dev_connected(&status)){
+	usb_log_debug("port status %d, x%x\n", status, status);
+	if (usb_port_dev_connected(&status)) {
 		usb_log_debug("there is connected device on this port\n");
 	}
-	if(!hub_info->is_default_address_used)
-		usb_hub_init_add_device(hub_info, port, usb_port_speed(&status));
+	if (!hub_info->is_default_address_used)
+		usb_hub_init_add_device(hub_info, port,
+			usb_port_speed(&status));
 	return opResult;
 }
@@ -756,13 +799,14 @@
  * @return error code
  */
-int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
+int usb_hub_check_hub_changes(usb_hub_info_t * hub_info) {
 	int opResult;
 	opResult = usb_pipe_start_session(
-			hub_info->status_change_pipe);
-	//this might not be necessary - if all non-removables are ok, it is not needed here
+		hub_info->status_change_pipe);
+	//this might not be necessary - if all non-removables are ok, it is
+	//not needed here
 	opResult = usb_pipe_start_session(hub_info->control_pipe);
-	if(opResult != EOK){
+	if (opResult != EOK) {
 		usb_log_error("could not initialize communication for hub; %d\n",
-				opResult);
+			opResult);
 		return opResult;
 	}
@@ -771,19 +815,20 @@
 	//first check non-removable devices
 	{
-	unsigned int port;
-	for(port = 1; port<=port_count; ++port){
-		bool is_non_removable =
-			hub_info->not_initialized_non_removables[port/8]
-			& (1 << (port%8));
-		if(is_non_removable){
-			opResult = initialize_non_removable(hub_info,port);
+		unsigned int port;
+		for (port = 1; port <= port_count; ++port) {
+			bool is_non_removable =
+				hub_info->not_initialized_non_removables[port/8]
+				& (1 << (port % 8));
+			if (is_non_removable) {
+				opResult = initialize_non_removable(hub_info,
+					port);
+			}
 		}
 	}
-	}
 
 
 	/// FIXME: count properly
-	size_t byte_length = ((port_count+1) / 8) + 1;
-		void *change_bitmap = malloc(byte_length);
+	size_t byte_length = ((port_count + 1) / 8) + 1;
+	void *change_bitmap = malloc(byte_length);
 	size_t actual_size;
 
@@ -792,25 +837,27 @@
 	 */
 	opResult = usb_pipe_read(
-			hub_info->status_change_pipe,
-			change_bitmap, byte_length, &actual_size
-			);
+		hub_info->status_change_pipe,
+		change_bitmap, byte_length, &actual_size
+		);
 
 	if (opResult != EOK) {
 		free(change_bitmap);
-		usb_log_warning("something went wrong while getting status of hub\n");
+		usb_log_warning("something went wrong while getting the"
+			"status of hub\n");
 		usb_pipe_end_session(hub_info->status_change_pipe);
 		return opResult;
 	}
 	unsigned int port;
-	
-	if(opResult!=EOK){
-		usb_log_error("could not start control pipe session %d\n", opResult);
+
+	if (opResult != EOK) {
+		usb_log_error("could not start control pipe session %d\n",
+			opResult);
 		usb_pipe_end_session(hub_info->status_change_pipe);
 		return opResult;
 	}
 	opResult = usb_hc_connection_open(&hub_info->connection);
-	if(opResult!=EOK){
+	if (opResult != EOK) {
 		usb_log_error("could not start host controller session %d\n",
-				opResult);
+			opResult);
 		usb_pipe_end_session(hub_info->control_pipe);
 		usb_pipe_end_session(hub_info->status_change_pipe);
@@ -819,10 +866,10 @@
 
 	///todo, opresult check, pre obe konekce
-	for (port = 1; port < port_count+1; ++port) {
+	for (port = 1; port < port_count + 1; ++port) {
 		bool interrupt =
-				(((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
+			(((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
 		if (interrupt) {
 			usb_hub_process_interrupt(
-			        hub_info, port);
+				hub_info, port);
 		}
 	}
