Index: uspace/drv/bus/usb/xhci/endpoint.c
===================================================================
--- uspace/drv/bus/usb/xhci/endpoint.c	(revision f4b83ccb2a833d7fd3eb2ec2e8c597708dea7288)
+++ uspace/drv/bus/usb/xhci/endpoint.c	(revision 2e2af3a5f8347d041e1a34e88f972cae4d80a570)
@@ -45,4 +45,11 @@
 #include "endpoint.h"
 
+/** Initialize new XHCI endpoint.
+ * @param[in] xhci_ep Allocated XHCI endpoint to initialize.
+ * @param[in] dev Device, to which the endpoint belongs.
+ * @param[in] desc USB endpoint descriptor carrying configuration data.
+ *
+ * @return Error code.
+ */
 int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, device_t *dev, const usb_endpoint_desc_t *desc)
 {
@@ -75,4 +82,7 @@
 }
 
+/** Finalize XHCI endpoint.
+ * @param[in] xhci_ep XHCI endpoint to finalize.
+ */
 void xhci_endpoint_fini(xhci_endpoint_t *xhci_ep)
 {
@@ -82,4 +92,9 @@
 }
 
+/** Determine the type of a XHCI endpoint.
+ * @param[in] ep XHCI endpoint to query.
+ *
+ * @return EP_TYPE_[CONTROL|ISOCH|BULK|INTERRUPT]_[IN|OUT]
+ */
 static int xhci_endpoint_type(xhci_endpoint_t *ep)
 {
@@ -106,4 +121,9 @@
 }
 
+/** Test whether an XHCI endpoint uses streams.
+ * @param[in] xhci_ep XHCI endpoint to query.
+ *
+ * @return True if the endpoint uses streams.
+ */
 static bool endpoint_using_streams(xhci_endpoint_t *xhci_ep)
 {
@@ -111,4 +131,9 @@
 }
 
+/** Determine maximum size of XHCI endpoint's Primary Stream Context Array.
+ * @param[in] xhci_ep XHCI endpoint to query.
+ *
+ * @return Number of items in the Primary Stream Context Array.
+ */
 static size_t primary_stream_ctx_array_max_size(xhci_endpoint_t *xhci_ep)
 {
@@ -130,4 +155,9 @@
 // }
 
+/** Initialize primary streams of XHCI bulk endpoint.
+ * @param[in] hc Host controller of the endpoint.
+ * @param[in] xhci_epi XHCI bulk endpoint to use.
+ * @param[in] count Number of primary streams to initialize.
+ */
 static void initialize_primary_streams(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep, unsigned count) {
 	for (size_t index = 0; index < count; ++index) {
@@ -136,5 +166,5 @@
 
 		/* Init and register TRB ring for every primary stream */
-		xhci_trb_ring_init(ring);
+		xhci_trb_ring_init(ring); // FIXME: Not checking error code?
 		XHCI_STREAM_DEQ_PTR_SET(*ctx, ring->dequeue);
 
@@ -144,4 +174,9 @@
 }
 
+/** Configure XHCI bulk endpoint's stream context.
+ * @param[in] xhci_ep Associated XHCI bulk endpoint.
+ * @param[in] ctx Endpoint context to configure.
+ * @param[in] pstreams The value of MaxPStreams.
+ */
 static void setup_stream_context(xhci_endpoint_t *xhci_ep, xhci_ep_ctx_t *ctx, unsigned pstreams) {
 	XHCI_EP_TYPE_SET(*ctx, xhci_endpoint_type(xhci_ep));
@@ -156,4 +191,6 @@
 }
 
+/** TODO document this
+ */
 int xhci_endpoint_request_streams(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *xhci_ep, unsigned count) {
 	if (xhci_ep->base.transfer_type != USB_TRANSFER_BULK
@@ -210,4 +247,6 @@
 }
 
+/** TODO document this
+ */
 static int xhci_isoch_alloc_transfers(xhci_endpoint_t *xhci_ep) {
 	int i = 0;
@@ -234,4 +273,9 @@
 }
 
+/** Allocate transfer data structures for XHCI endpoint.
+ * @param[in] xhci_ep XHCI endpoint to allocate data structures for.
+ *
+ * @return Error code.
+ */
 int xhci_endpoint_alloc_transfer_ds(xhci_endpoint_t *xhci_ep)
 {
@@ -256,4 +300,7 @@
 }
 
+/** Free transfer data structures for XHCI endpoint.
+ * @param[in] xhci_ep XHCI endpoint to free data structures for.
+ */
 void xhci_endpoint_free_transfer_ds(xhci_endpoint_t *xhci_ep)
 {
@@ -311,4 +358,8 @@
 }
 
+/** Configure endpoint context of a control endpoint.
+ * @param[in] ep XHCI control endpoint.
+ * @param[in] ctx Endpoint context to configure.
+ */
 static void setup_control_ep_ctx(xhci_endpoint_t *ep, xhci_ep_ctx_t *ctx)
 {
@@ -322,4 +373,8 @@
 }
 
+/** Configure endpoint context of a bulk endpoint.
+ * @param[in] ep XHCI bulk endpoint.
+ * @param[in] ctx Endpoint context to configure.
+ */
 static void setup_bulk_ep_ctx(xhci_endpoint_t *ep, xhci_ep_ctx_t *ctx)
 {
@@ -334,4 +389,8 @@
 }
 
+/** Configure endpoint context of a isochronous endpoint.
+ * @param[in] ep XHCI isochronous endpoint.
+ * @param[in] ctx Endpoint context to configure.
+ */
 static void setup_isoch_ep_ctx(xhci_endpoint_t *ep, xhci_ep_ctx_t *ctx)
 {
@@ -348,4 +407,8 @@
 }
 
+/** Configure endpoint context of a interrupt endpoint.
+ * @param[in] ep XHCI interrupt endpoint.
+ * @param[in] ctx Endpoint context to configure.
+ */
 static void setup_interrupt_ep_ctx(xhci_endpoint_t *ep, xhci_ep_ctx_t *ctx)
 {
@@ -360,6 +423,8 @@
 }
 
+/** Type of endpoint context configuration function. */
 typedef void (*setup_ep_ctx_helper)(xhci_endpoint_t *, xhci_ep_ctx_t *);
 
+/** Static array, which maps USB endpoint types to their respective endpoint context configuration functions. */
 static const setup_ep_ctx_helper setup_ep_ctx_helpers[] = {
 	[USB_TRANSFER_CONTROL] = setup_control_ep_ctx,
@@ -369,4 +434,8 @@
 };
 
+/** Configure endpoint context of XHCI endpoint.
+ * @param[in] ep Associated XHCI endpoint.
+ * @param[in] ep_ctx Endpoint context to configure.
+ */
 void xhci_setup_endpoint_context(xhci_endpoint_t *ep, xhci_ep_ctx_t *ep_ctx)
 {
@@ -381,4 +450,11 @@
 }
 
+/** Add a new XHCI endpoint to a device. The device must be online unless
+ * the added endpoint is number 0.
+ * @param[in] dev XHCI device, to which to add the endpoint
+ * @param[in] ep XHCI endpoint to add.
+ *
+ * @return Error code.
+ */
 int xhci_device_add_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
 {
@@ -404,4 +480,7 @@
 }
 
+/** Remove XHCI endpoint from a device.
+ * @param[in] ep XHCI endpoint to remove.
+ */
 void xhci_device_remove_endpoint(xhci_endpoint_t *ep)
 {
@@ -416,4 +495,10 @@
 }
 
+/** Retrieve XHCI endpoint from a device by the endpoint number.
+ * @param[in] dev XHCI device to query.
+ * @param[in] ep Endpoint number identifying the endpoint to retrieve.
+ *
+ * @return XHCI endpoint with the specified number or NULL if no such endpoint exists.
+ */
 xhci_endpoint_t *xhci_device_get_endpoint(xhci_device_t *dev, usb_endpoint_t ep)
 {
