Index: uspace/lib/usbhost/src/ddf_helpers.c
===================================================================
--- uspace/lib/usbhost/src/ddf_helpers.c	(revision 0918382f0dd2d21d3af74f39f202b3e0a296bcc8)
+++ uspace/lib/usbhost/src/ddf_helpers.c	(revision 14dd4c9a2ee1c3497cc54be9da46462b97837263)
@@ -46,29 +46,8 @@
 #define CTRL_PIPE_MIN_PACKET_SIZE 8
 
-typedef struct hc_dev {
-	ddf_fun_t *ctl_fun;
-	list_t devices;
-	fibril_mutex_t guard;
-	hcd_t hcd;
-} hc_dev_t;
-
-static hc_dev_t *dev_to_hc_dev(ddf_dev_t *dev)
-{
-	return ddf_dev_data_get(dev);
-}
-
-hcd_t *dev_to_hcd(ddf_dev_t *dev)
-{
-	hc_dev_t *hc_dev = dev_to_hc_dev(dev);
-	if (!hc_dev) {
-		usb_log_error("Invalid HCD device.\n");
-		return NULL;
-	}
-	return &hc_dev->hcd;
-}
-
 typedef struct usb_dev {
 	link_t link;
 	list_t devices;
+	fibril_mutex_t guard;
 	ddf_fun_t *fun;
 	usb_address_t address;
@@ -76,4 +55,26 @@
 	unsigned port;
 } usb_dev_t;
+
+typedef struct hc_dev {
+	ddf_fun_t *ctl_fun;
+	hcd_t hcd;
+	usb_dev_t *root_hub;
+} hc_dev_t;
+
+static hc_dev_t *dev_to_hc_dev(ddf_dev_t *dev)
+{
+	return ddf_dev_data_get(dev);
+}
+
+hcd_t *dev_to_hcd(ddf_dev_t *dev)
+{
+	hc_dev_t *hc_dev = dev_to_hc_dev(dev);
+	if (!hc_dev) {
+		usb_log_error("Invalid HCD device.\n");
+		return NULL;
+	}
+	return &hc_dev->hcd;
+}
+
 
 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port);
@@ -312,5 +313,4 @@
 	}
 
-	//TODO more checks
 	ddf_fun_t *fun = ddf_fun_create(parent, fun_inner, name);
 	if (!fun)
@@ -327,4 +327,5 @@
 	link_initialize(&info->link);
 	list_initialize(&info->devices);
+	fibril_mutex_initialize(&info->guard);
 
 	ddf_fun_set_ops(fun, &usb_ops);
@@ -341,8 +342,11 @@
 
 	if (hub_dev) {
+		fibril_mutex_lock(&hub_dev->guard);
 		list_append(&info->link, &hub_dev->devices);
+		fibril_mutex_unlock(&hub_dev->guard);
 	} else {
 		hc_dev_t *hc_dev = dev_to_hc_dev(parent);
-		list_append(&info->link, &hc_dev->devices);
+		assert(hc_dev->root_hub == NULL);
+		hc_dev->root_hub = info;
 	}
 	return EOK;
@@ -409,5 +413,5 @@
 	assert(hc_dev);
 
-	fibril_mutex_lock(&hc_dev->guard);
+	fibril_mutex_lock(&hub->guard);
 
 	usb_dev_t *victim = NULL;
@@ -420,5 +424,5 @@
 	if (victim && victim->port == port) {
 		list_remove(&victim->link);
-		fibril_mutex_unlock(&hc_dev->guard);
+		fibril_mutex_unlock(&hub->guard);
 		const int ret = ddf_fun_unbind(victim->fun);
 		if (ret == EOK) {
@@ -585,6 +589,5 @@
 		return ENOMEM;
 	}
-	list_initialize(&instance->devices);
-	fibril_mutex_initialize(&instance->guard);
+	instance->root_hub = NULL;
 	hcd_init(&instance->hcd, max_speed, bw, bw_count);
 
