Changeset 81487c4a in mainline for uspace/drv/bus/usb/xhci/endpoint.c
- Timestamp:
- 2017-10-23T09:33:25Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31cca4f3
- Parents:
- 82fe063
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/endpoint.c
r82fe063 r81487c4a 64 64 } 65 65 66 static bool endpoint_uses_streams(xhci_endpoint_t *xhci_ep) 67 { 68 return xhci_ep->base.transfer_type == USB_TRANSFER_BULK 69 && xhci_ep->max_streams; 70 } 71 72 static size_t primary_stream_ctx_array_size(xhci_endpoint_t *xhci_ep) 73 { 74 if (!endpoint_uses_streams(xhci_ep)) 75 return 0; 76 77 /* Section 6.2.3, Table 61 */ 78 return 1 << (xhci_ep->max_streams + 1); 79 } 80 66 81 int xhci_endpoint_alloc_transfer_ds(xhci_endpoint_t *xhci_ep) 67 82 { 68 83 int err; 69 84 70 if (xhci_ep->max_streams > 0) { 71 // Set up primary stream context array if needed. 72 xhci_ep->primary_stream_ctx_array = malloc32(xhci_ep->max_streams * sizeof(xhci_stream_ctx_t)); 85 if (endpoint_uses_streams(xhci_ep)) { 86 /* Set up primary stream context array if needed. */ 87 const size_t size = primary_stream_ctx_array_size(xhci_ep); 88 89 xhci_ep->primary_stream_ctx_array = malloc32(size * sizeof(xhci_stream_ctx_t)); 73 90 if (!xhci_ep->primary_stream_ctx_array) { 74 91 return ENOMEM; 75 92 } 76 memset(xhci_ep->primary_stream_ctx_array, 0, xhci_ep->max_streams * sizeof(xhci_stream_ctx_t)); 93 94 memset(xhci_ep->primary_stream_ctx_array, 0, size * sizeof(xhci_stream_ctx_t)); 77 95 } else { 78 96 xhci_ep->primary_stream_ctx_array = NULL; … … 89 107 int err; 90 108 91 if ( xhci_ep->max_streams > 0) {109 if (endpoint_uses_streams(xhci_ep)) { 92 110 // TODO: What about secondaries? 93 111 free32(xhci_ep->primary_stream_ctx_array); … … 169 187 XHCI_EP_ERROR_COUNT_SET(*ctx, 3); 170 188 171 if (e p->max_streams > 0) {189 if (endpoint_uses_streams(ep)) { 172 190 XHCI_EP_MAX_P_STREAMS_SET(*ctx, ep->max_streams); 173 191 XHCI_EP_TR_DPTR_SET(*ctx, addr_to_phys(ep->primary_stream_ctx_array));
Note:
See TracChangeset
for help on using the changeset viewer.