Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 3eaa5a5e2a2abcbfcd52ad1b3e21314c5147c3ad)
+++ uspace/drv/usbhub/usbhub.c	(revision c50941fd0b3723a4ed5ea15d4ac8d4816bf4ab93)
@@ -53,34 +53,6 @@
 #include "usb/classes/classes.h"
 
-
-//static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-//		usb_speed_t speed);
-
 static int usb_hub_trigger_connecting_non_removable_devices(
 		usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);
-
-#if 0
-/**
- * control loop running in hub`s fibril
- *
- * Hub`s fibril periodically asks for changes on hub and if needded calls
- * change handling routine.
- * @warning currently hub driver asks for changes once a second
- * @param hub_info_param hub representation pointer
- * @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 errorCode = EOK;
-
-	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);
-
-	return 0;
-}
-#endif
 
 
@@ -427,139 +399,4 @@
 }
 
-#if 0
-/**
- * Reset the port with new device and reserve the default address.
- * @param hub hub representation
- * @param port port number, starting from 1
- * @param speed transfer speed of attached device, one of low, full or high
- */
-static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-		usb_speed_t speed) {
-	//if this hub already uses default address, it cannot request it once more
-	if(hub->is_default_address_used) return;
-	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){
-		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);
-		return;
-	}
-	hub->is_default_address_used = true;
-	//reset port
-	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);
-		usb_hub_release_default_address(hub);
-	}
-	return;
-}
-#endif
-
-#if 0
-/**
- * Finalize adding new device after port reset
- *
- * Set device`s address and start it`s driver.
- * @param hub hub representation
- * @param port port number, starting from 1
- * @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) {
-
-	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);
-
-	if (opResult != EOK) {
-		usb_log_error("failed to clear port reset feature\n");
-		usb_hub_release_default_address(hub);
-		return;
-	}
-	//create connection to device
-	usb_pipe_t new_device_pipe;
-	usb_device_connection_t new_device_connection;
-	usb_device_connection_initialize_on_default_address(
-			&new_device_connection,
-			&hub->connection
-			);
-	usb_pipe_initialize_default_control(
-			&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
-			);
-	if (new_device_address < 0) {
-		usb_log_error("failed to get free USB address\n");
-		opResult = new_device_address;
-		usb_hub_release_default_address(hub);
-		return;
-	}
-	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);
-	usb_pipe_end_session(&new_device_pipe);
-	if (opResult != EOK) {
-		usb_log_error("could not set address for new device %d\n",opResult);
-		usb_hub_release_default_address(hub);
-		return;
-	}
-
-	//opResult = usb_hub_release_default_address(hc);
-	opResult = usb_hub_release_default_address(hub);
-	if(opResult!=EOK){
-		return;
-	}
-
-	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);
-		return;
-	}
-	hub->attached_devs[port].handle = child_handle;
-	hub->attached_devs[port].address = new_device_address;
-
-	//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);
-		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);
-}
-#endif
-
 /**
  * routine called when a device on port has been removed
@@ -622,154 +459,4 @@
 }
 
-#if 0
-/**
- * Process interrupts on given hub port
- *
- * Accepts connection, over current and port reset change.
- * @param hub hub representation
- * @param port port number, starting from 1
- */
-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;
-
-	usb_port_status_t status;
-	size_t rcvd_size;
-	usb_device_request_setup_packet_t request;
-	//int opResult;
-	usb_hub_set_port_status_request(&request, port);
-	//endpoint 0
-
-	opResult = usb_pipe_control_read(
-			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");
-		return;
-	}
-	if (rcvd_size != sizeof (usb_port_status_t)) {
-		usb_log_error("received status has incorrect size\n");
-		return;
-	}
-	//something connected/disconnected
-	if (usb_port_connect_change(&status)) {
-		usb_log_debug("connection change on port\n");
-		if (usb_port_dev_connected(&status)) {
-			usb_log_debug("some connection changed\n");
-			usb_hub_init_add_device(hub, port, usb_port_speed(&status));
-		} else {
-			usb_hub_removed_device(hub, port);
-		}
-	}
-	//over current
-	if (usb_port_overcurrent_change(&status)) {
-		//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);
-		}
-	}
-	//port reset
-	if (usb_port_reset_completed(&status)) {
-		usb_log_debug("port reset complete\n");
-		if (usb_port_enabled(&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_debug("status %x\n ",status);
-
-	usb_port_set_connect_change(&status, false);
-	usb_port_set_reset(&status, false);
-	usb_port_set_reset_completed(&status, false);
-	usb_port_set_dev_connected(&status, false);
-	if (status>>16) {
-		usb_log_info("there was some unsupported change on port %d: %X\n",
-				port,status);
-
-	}
-}
-
-/**
- * check changes on hub
- *
- * Handles changes on each port with a status change.
- * @param hub_info hub representation
- * @return error code
- */
-int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
-	int opResult;
-	opResult = usb_pipe_start_session(
-			hub_info->status_change_pipe);
-	if(opResult != EOK){
-		usb_log_error("could not initialize communication for hub; %d\n",
-				opResult);
-		return opResult;
-	}
-
-	size_t port_count = hub_info->port_count;
-
-	/// FIXME: count properly
-	size_t byte_length = ((port_count+1) / 8) + 1;
-		void *change_bitmap = malloc(byte_length);
-	size_t actual_size;
-
-	/*
-	 * Send the request.
-	 */
-	opResult = usb_pipe_read(
-			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_pipe_end_session(hub_info->status_change_pipe);
-		return opResult;
-	}
-	unsigned int port;
-	opResult = usb_pipe_start_session(hub_info->control_pipe);
-	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){
-		usb_log_error("could not start host controller session %d\n",
-				opResult);
-		usb_pipe_end_session(hub_info->control_pipe);
-		usb_pipe_end_session(hub_info->status_change_pipe);
-		return opResult;
-	}
-
-	///todo, opresult check, pre obe konekce
-	for (port = 1; port < port_count+1; ++port) {
-		bool interrupt =
-				(((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
-		if (interrupt) {
-			usb_hub_process_interrupt(
-			        hub_info, port);
-		}
-	}
-	usb_hc_connection_close(&hub_info->connection);
-	usb_pipe_end_session(hub_info->control_pipe);
-	usb_pipe_end_session(hub_info->status_change_pipe);
-	free(change_bitmap);
-	return EOK;
-}
-#endif
-
 
 /**
