Index: uspace/lib/usbhost/src/endpoint.c
===================================================================
--- uspace/lib/usbhost/src/endpoint.c	(revision 48ae3ef60beee610cc95a4e34ea78d76a44715e0)
+++ uspace/lib/usbhost/src/endpoint.c	(revision 1db6dfd43e6af5b83407ca9b1ef75a0eaddfc7f4)
@@ -26,6 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
-/** @addtogroup drvusbuhcihc
+/** @addtogroup libusbhost
  * @{
  */
@@ -39,4 +38,14 @@
 #include <usb/host/endpoint.h>
 
+/** Allocate ad initialize endpoint_t structure.
+ * @param address USB address.
+ * @param endpoint USB endpoint number.
+ * @param direction Communication direction.
+ * @param type USB transfer type.
+ * @param speed Communication speed.
+ * @param max_packet_size Maximum size of data packets.
+ * @param bw Required bandwidth.
+ * @return Pointer to initialized endpoint_t structure, NULL on failure.
+ */
 endpoint_t * endpoint_create(usb_address_t address, usb_endpoint_t endpoint,
     usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed,
@@ -60,12 +69,15 @@
 		fibril_mutex_initialize(&instance->guard);
 		fibril_condvar_initialize(&instance->avail);
-		endpoint_clear_hc_data(instance);
 	}
 	return instance;
 }
 /*----------------------------------------------------------------------------*/
+/** Properly dispose of endpoint_t structure.
+ * @param instance endpoint_t structure.
+ */
 void endpoint_destroy(endpoint_t *instance)
 {
 	assert(instance);
+	//TODO: Do something about waiting fibrils.
 	assert(!instance->active);
 	assert(instance->hc_data.data == NULL);
@@ -73,21 +85,38 @@
 }
 /*----------------------------------------------------------------------------*/
+/** Set device specific data and hooks.
+ * @param instance endpoint_t structure.
+ * @param data device specific data.
+ * @param toggle_get Hook to call when retrieving value of toggle bit.
+ * @param toggle_set Hook to call when setting the value of toggle bit.
+ */
 void endpoint_set_hc_data(endpoint_t *instance,
     void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int))
 {
 	assert(instance);
+	fibril_mutex_lock(&instance->guard);
 	instance->hc_data.data = data;
 	instance->hc_data.toggle_get = toggle_get;
 	instance->hc_data.toggle_set = toggle_set;
+	fibril_mutex_unlock(&instance->guard);
 }
 /*----------------------------------------------------------------------------*/
+/** Clear device specific data and hooks.
+ * @param instance endpoint_t structure.
+ * @note This function does not free memory pointed to by data pointer.
+ */
 void endpoint_clear_hc_data(endpoint_t *instance)
 {
 	assert(instance);
+	fibril_mutex_lock(&instance->guard);
 	instance->hc_data.data = NULL;
 	instance->hc_data.toggle_get = NULL;
 	instance->hc_data.toggle_set = NULL;
+	fibril_mutex_unlock(&instance->guard);
 }
 /*----------------------------------------------------------------------------*/
+/** Mark the endpoint as active and block access for further fibrils.
+ * @param instance endpoint_t structure.
+ */
 void endpoint_use(endpoint_t *instance)
 {
@@ -100,4 +129,7 @@
 }
 /*----------------------------------------------------------------------------*/
+/** Mark the endpoint as inactive and allow access for further fibrils.
+ * @param instance endpoint_t structure.
+ */
 void endpoint_release(endpoint_t *instance)
 {
@@ -109,20 +141,33 @@
 }
 /*----------------------------------------------------------------------------*/
+/** Get the value of toggle bit.
+ * @param instance endpoint_t structure.
+ * @note Will use provided hook.
+ */
 int endpoint_toggle_get(endpoint_t *instance)
 {
 	assert(instance);
+	fibril_mutex_lock(&instance->guard);
 	if (instance->hc_data.toggle_get)
 		instance->toggle =
 		    instance->hc_data.toggle_get(instance->hc_data.data);
-	return (int)instance->toggle;
+	const int ret = instance->toggle;
+	fibril_mutex_unlock(&instance->guard);
+	return ret;
 }
 /*----------------------------------------------------------------------------*/
+/** Set the value of toggle bit.
+ * @param instance endpoint_t structure.
+ * @note Will use provided hook.
+ */
 void endpoint_toggle_set(endpoint_t *instance, int toggle)
 {
 	assert(instance);
 	assert(toggle == 0 || toggle == 1);
+	fibril_mutex_lock(&instance->guard);
+	instance->toggle = toggle;
 	if (instance->hc_data.toggle_set)
 		instance->hc_data.toggle_set(instance->hc_data.data, toggle);
-	instance->toggle = toggle;
+	fibril_mutex_unlock(&instance->guard);
 }
 /**
