Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision 67352d2ce57d0bbae9f4f2b0a767afb56ae158b6)
+++ uspace/drv/uhci-rhd/port.c	(revision 4f66cc7ba6fe619d454d7dc98d744ace7725d190)
@@ -26,10 +26,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/** @addtogroup usb
+/** @addtogroup drvusbuhcirh
  * @{
  */
 /** @file
- * @brief UHCI driver
- */
+ * @brief UHCI root hub port routines
+ */
+#include <libarch/ddi.h> /* pio_read and pio_write */
 #include <errno.h>
 #include <str_error.h>
@@ -37,9 +38,6 @@
 
 #include <usb/usb.h>    /* usb_address_t */
-#include <usb/usbdevice.h>
 #include <usb/hub.h>
-#include <usb/request.h>
 #include <usb/debug.h>
-#include <usb/recognise.h>
 
 #include "port.h"
@@ -50,6 +48,33 @@
 static int uhci_port_check(void *port);
 static int uhci_port_reset_enable(int portno, void *arg);
-/*----------------------------------------------------------------------------*/
-/** Initializes UHCI root hub port instance.
+static void uhci_port_print_status(
+    uhci_port_t *port, const port_status_t value);
+
+/** Register reading helper function.
+ *
+ * @param[in] port Structure to use.
+ * @return Error code. (Always EOK)
+ */
+static inline port_status_t uhci_port_read_status(uhci_port_t *port)
+{
+	assert(port);
+	return pio_read_16(port->address);
+}
+/*----------------------------------------------------------------------------*/
+/** Register writing helper function.
+ *
+ * @param[in] port Structure to use.
+ * @param[in] value New register value.
+ * @return Error code. (Always EOK)
+ */
+static inline void uhci_port_write_status(
+    uhci_port_t *port, port_status_t value)
+{
+	assert(port);
+	pio_write_16(port->address, value);
+}
+
+/*----------------------------------------------------------------------------*/
+/** Initialize UHCI root hub port instance.
  *
  * @param[in] port Memory structure to use.
@@ -60,5 +85,5 @@
  * @return Error code.
  *
- * Starts the polling fibril.
+ * Creates and starts the polling fibril.
  */
 int uhci_port_init(uhci_port_t *port,
@@ -86,16 +111,16 @@
 	port->checker = fibril_create(uhci_port_check, port);
 	if (port->checker == 0) {
-		usb_log_error("Port(%p - %d): failed to launch root hub fibril.",
-		    port->address, port->number);
+		usb_log_error("%s: failed to create polling fibril.",
+		    port->id_string);
 		return ENOMEM;
 	}
 
 	fibril_add_ready(port->checker);
-	usb_log_debug("Port(%p - %d): Added fibril. %x\n",
-	    port->address, port->number, port->checker);
-	return EOK;
-}
-/*----------------------------------------------------------------------------*/
-/** Finishes UHCI root hub port instance.
+	usb_log_debug("%s: Started polling fibril(%x).\n",
+	    port->id_string, port->checker);
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+/** Cleanup UHCI root hub port instance.
  *
  * @param[in] port Memory structure to use.
@@ -105,4 +130,6 @@
 void uhci_port_fini(uhci_port_t *port)
 {
+	assert(port);
+	free(port->id_string);
 	/* TODO: Kill fibril here */
 	return;
@@ -111,5 +138,5 @@
 /** Periodically checks port status and reports new devices.
  *
- * @param[in] port Memory structure to use.
+ * @param[in] port Port structure to use.
  * @return Error code.
  */
@@ -122,8 +149,8 @@
 		async_usleep(instance->wait_period_usec);
 
-		/* read register value */
+		/* Read register value */
 		port_status_t port_status = uhci_port_read_status(instance);
 
-		/* print the value if it's interesting */
+		/* Print the value if it's interesting */
 		if (port_status & ~STATUS_ALWAYS_ONE)
 			uhci_port_print_status(instance, port_status);
@@ -177,4 +204,6 @@
  * @param arg Pointer to uhci_port_t of port with the new device.
  * @return Error code.
+ *
+ * Resets and enables the ub port.
  */
 int uhci_port_reset_enable(int portno, void *arg)
@@ -214,7 +243,7 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Initializes and reports connected device.
- *
- * @param[in] port Memory structure to use.
+/** Initialize and report connected device.
+ *
+ * @param[in] port Port structure to use.
  * @param[in] speed Detected speed.
  * @return Error code.
@@ -247,10 +276,12 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Removes device.
+/** Remove device.
  *
  * @param[in] port Memory structure to use.
  * @return Error code.
  *
- * Does not work DDF does not support device removal.
+ * Does not work, DDF does not support device removal.
+ * Does not even free used USB address (it would be dangerous if tis driver
+ * is still running).
  */
 int uhci_port_remove_device(uhci_port_t *port)
@@ -261,7 +292,8 @@
 }
 /*----------------------------------------------------------------------------*/
-/** Enables and disables port.
- *
- * @param[in] port Memory structure to use.
+/** Enable or disable root hub port.
+ *
+ * @param[in] port Port structure to use.
+ * @param[in] enabled Port status to set.
  * @return Error code. (Always EOK)
  */
@@ -288,4 +320,28 @@
 }
 /*----------------------------------------------------------------------------*/
+/** Print the port status value in a human friendly way
+ *
+ * @param[in] port Port structure to use.
+ * @param[in] value Port register value to print.
+ * @return Error code. (Always EOK)
+ */
+void uhci_port_print_status(uhci_port_t *port, const port_status_t value)
+{
+	assert(port);
+	usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n",
+	    port->id_string, value,
+	    (value & STATUS_SUSPEND) ? " SUSPENDED," : "",
+	    (value & STATUS_RESUME) ? " IN RESUME," : "",
+	    (value & STATUS_IN_RESET) ? " IN RESET," : "",
+	    (value & STATUS_LINE_D_MINUS) ? " VD-," : "",
+	    (value & STATUS_LINE_D_PLUS) ? " VD+," : "",
+	    (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",
+	    (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",
+	    (value & STATUS_ENABLED) ? " ENABLED," : "",
+	    (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
+	    (value & STATUS_CONNECTED) ? " CONNECTED," : "",
+	    (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
+	);
+}
 /**
  * @}
