Changeset 8033f89 in mainline for uspace/drv/bus/usb/xhci/streams.c


Ignore:
Timestamp:
2018-01-23T12:41:22Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7e1fd3
Parents:
e546142
Message:

xhci: cstyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/streams.c

    re546142 r8033f89  
    3939#include "streams.h"
    4040
    41 /** Finds stream data with given stream ID if it exists.
     41/**
     42 * Finds stream data with given stream ID if it exists.
    4243 * Note that streams with ID 0, 65534 and 65535 are reserved.
    4344 * Splits the ID into primary and secondary context ID and searches the structures.
     
    5253
    5354        /* See 4.12.2.1 for the calculation of the IDs and dividing the stream_id */
    54         uint32_t primary_stream_id = (uint32_t) (stream_id & (ep->primary_stream_data_size - 1));
    55         uint32_t secondary_stream_id = (uint32_t) ((stream_id / ep->primary_stream_data_size) & 0xFF);
     55        uint32_t primary_stream_id =
     56            (uint32_t) (stream_id & (ep->primary_stream_data_size - 1));
     57        uint32_t secondary_stream_id =
     58            (uint32_t) ((stream_id / ep->primary_stream_data_size) & 0xFF);
    5659
    5760        if (primary_stream_id >= ep->primary_stream_data_size) {
     
    5962        }
    6063
    61         xhci_stream_data_t *primary_data = &ep->primary_stream_data_array[primary_stream_id];
     64        xhci_stream_data_t *primary_data =
     65            &ep->primary_stream_data_array[primary_stream_id];
    6266        if (secondary_stream_id != 0 && !primary_data->secondary_size) {
    6367                return NULL;
     
    7680}
    7781
    78 /** Initializes primary stream data structures in endpoint.
     82/**
     83 * Initializes primary stream data structures in endpoint.
    7984 * @param[in] xhci_ep Used XHCI bulk endpoint.
    8085 * @param[in] count Amount of primary streams.
     
    8287static int initialize_primary_structures(xhci_endpoint_t *xhci_ep, unsigned count)
    8388{
    84         usb_log_debug("Allocating primary stream context array of size %u for endpoint " XHCI_EP_FMT,
    85                 count, XHCI_EP_ARGS(*xhci_ep));
    86 
    87         if ((dma_buffer_alloc(&xhci_ep->primary_stream_ctx_dma, count * sizeof(xhci_stream_ctx_t)))) {
     89        usb_log_debug("Allocating primary stream context array of size %u "
     90                "for endpoint " XHCI_EP_FMT, count, XHCI_EP_ARGS(*xhci_ep));
     91
     92        if ((dma_buffer_alloc(&xhci_ep->primary_stream_ctx_dma,
     93                count * sizeof(xhci_stream_ctx_t)))) {
    8894                return ENOMEM;
    8995        }
     
    101107}
    102108
    103 /**
    104  *
    105  */
    106109static void clear_primary_structures(xhci_endpoint_t *xhci_ep)
    107110{
    108         usb_log_debug("Deallocating primary stream structures for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
     111        usb_log_debug("Deallocating primary stream structures for "
     112                "endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    109113
    110114        dma_buffer_free(&xhci_ep->primary_stream_ctx_dma);
     
    133137void xhci_stream_free_ds(xhci_endpoint_t *xhci_ep)
    134138{
    135         usb_log_debug("Freeing stream rings and context arrays of endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
     139        usb_log_debug("Freeing stream rings and context arrays of endpoint "
     140                XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    136141
    137142        for (size_t index = 0; index < xhci_ep->primary_stream_data_size; ++index) {
     
    141146}
    142147
    143 /** Initialize a single primary stream structure with given index.
     148/**
     149 * Initialize a single primary stream structure with given index.
    144150 * @param[in] hc Host controller of the endpoint.
    145151 * @param[in] xhci_ep XHCI bulk endpoint to use.
    146152 * @param[in] index index of the initialized stream structure.
    147153 */
    148 static int initialize_primary_stream(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep, unsigned index) {
     154static int initialize_primary_stream(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep,
     155    unsigned index)
     156{
    149157        xhci_stream_ctx_t *ctx = &xhci_ep->primary_stream_ctx_array[index];
    150158        xhci_stream_data_t *data = &xhci_ep->primary_stream_data_array[index];
     
    165173}
    166174
    167 /** Initialize primary streams of XHCI bulk endpoint.
     175/**
     176 * Initialize primary streams of XHCI bulk endpoint.
    168177 * @param[in] hc Host controller of the endpoint.
    169178 * @param[in] xhci_ep XHCI bulk endpoint to use.
     
    189198}
    190199
    191 /** Initialize secondary streams of XHCI bulk endpoint.
     200/**
     201 * Initialize secondary streams of XHCI bulk endpoint.
    192202 * @param[in] hc Host controller of the endpoint.
    193203 * @param[in] xhci_epi XHCI bulk endpoint to use.
     
    195205 * @param[in] count Number of secondary streams to initialize.
    196206 */
    197 static int initialize_secondary_streams(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep, unsigned idx, unsigned count)
     207static int initialize_secondary_streams(xhci_hc_t *hc, xhci_endpoint_t *xhci_ep,
     208    unsigned idx, unsigned count)
    198209{
    199210        if (count == 0) {
    200                 /* The primary stream context can still point to a single ring, not a secondary. */
     211                /*
     212                 * The primary stream context can still point to a single ring, not
     213                 * a secondary.
     214                 */
    201215                return initialize_primary_stream(hc, xhci_ep, idx);
    202216        }
    203217
    204218        if ((count & (count - 1)) != 0 || count < 8 || count > 256) {
    205                 usb_log_error("The secondary stream array size must be a power of 2 between 8 and 256.");
     219                usb_log_error("The secondary stream array size must be a power of 2 "
     220                        "between 8 and 256.");
    206221                return EINVAL;
    207222        }
     
    217232        }
    218233
    219         if ((dma_buffer_alloc(&data->secondary_stream_ctx_dma, count * sizeof(xhci_stream_ctx_t)))) {
     234        if ((dma_buffer_alloc(&data->secondary_stream_ctx_dma,
     235                count * sizeof(xhci_stream_ctx_t)))) {
    220236                free(data->secondary_data);
    221237                return ENOMEM;
     
    251267}
    252268
    253 /** Configure XHCI bulk endpoint's stream context.
     269/**
     270 * Configure XHCI bulk endpoint's stream context.
    254271 * @param[in] xhci_ep Associated XHCI bulk endpoint.
    255272 * @param[in] ctx Endpoint context to configure.
     
    257274 * @param[in] lsa Specifies if the stream IDs point to primary stream array.
    258275 */
    259 static void setup_stream_context(xhci_endpoint_t *xhci_ep, xhci_ep_ctx_t *ctx, unsigned pstreams, unsigned lsa)
     276static void setup_stream_context(xhci_endpoint_t *xhci_ep, xhci_ep_ctx_t *ctx,
     277    unsigned pstreams, unsigned lsa)
    260278{
    261279        XHCI_EP_TYPE_SET(*ctx, xhci_endpoint_type(xhci_ep));
     
    269287}
    270288
    271 /** Verifies if all the common preconditions are satisfied.
     289/**
     290 * Verifies if all the common preconditions are satisfied.
    272291 * @param[in] hc Host controller of the endpoint.
    273292 * @param[in] dev Used device.
     
    285304
    286305        if (xhci_ep->max_streams <= 1) {
    287                 usb_log_error("Streams are not supported by endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
     306                usb_log_error("Streams are not supported by endpoint "
     307                    XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
    288308                return EINVAL;
    289309        }
     
    294314        }
    295315
    296         /* The maximum amount of primary streams is 2 ^ (MaxPSA + 1) (See table 26 of XHCI specification) */
     316        /*
     317         * The maximum amount of primary streams is 2 ^ (MaxPSA + 1)
     318         * See table 26 of XHCI specification.
     319         */
    297320        uint8_t max_psa_size = 1 << (XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_PSA_SIZE) + 1);
    298321        if (count > max_psa_size) {
    299                 usb_log_error("Host controller only supports %u primary streams.", max_psa_size);
     322                usb_log_error("Host controller only supports "
     323                        "%u primary streams.", max_psa_size);
    300324                return EINVAL;
    301325        }
     
    315339}
    316340
    317 /** Cancels streams and reconfigures endpoint back to single ring no stream endpoint.
     341/**
     342 * Cancels streams and reconfigures endpoint back to single ring no stream endpoint.
    318343 * @param[in] hc Host controller of the endpoint.
    319344 * @param[in] dev Used device.
    320345 * @param[in] xhci_ep Associated XHCI bulk endpoint.
    321346 */
    322 int xhci_endpoint_remove_streams(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *xhci_ep)
     347int xhci_endpoint_remove_streams(xhci_hc_t *hc, xhci_device_t *dev,
     348    xhci_endpoint_t *xhci_ep)
    323349{
    324350        if (!xhci_ep->primary_stream_data_size) {
     
    340366}
    341367
    342 /** Initialize, setup and register primary streams.
     368/**
     369 * Initialize, setup and register primary streams.
    343370 * @param[in] hc Host controller of the endpoint.
    344371 * @param[in] dev Used device.
     
    374401
    375402        xhci_ep_ctx_t ep_ctx;
    376         /* Allowed values are 1-15, where 2 ^ pstreams is the actual amount of streams. */
     403        /*
     404         * Allowed values are 1-15, where 2 ^ pstreams is the actual amount of
     405         * streams.
     406         */
    377407        const size_t pstreams = fnzb32(count) - 1;
    378408        setup_stream_context(xhci_ep, &ep_ctx, pstreams, 1);
     
    381411}
    382412
    383 /** Initialize, setup and register secondary streams.
     413/**
     414 * Initialize, setup and register secondary streams.
    384415 * @param[in] hc Host controller of the endpoint.
    385416 * @param[in] dev Used device.
    386417 * @param[in] xhci_ep Associated XHCI bulk endpoint.
    387  * @param[in] sizes Amount of secondary streams in each primary stream.
    388                                         This array should have exactly count elements.
    389                                         If the size is 0, then a primary ring is created with that index.
     418 * @param[in] sizes Amount of secondary streams in each of the primary streams.
     419 *                  This array should have exactly count elements. If the size
     420 *                  is 0, then a primary ring is created with that index.
    390421 * @param[in] count Amount of primary streams requested.
    391422 */
Note: See TracChangeset for help on using the changeset viewer.