Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0eadfd1e in mainline


Ignore:
Timestamp:
2018-01-09T14:14:32Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
dfa1fc8
Parents:
17c5e62
Message:

xhci: allocate/free transfer ring internally in endpoint init/fini

Location:
uspace/drv/bus/usb/xhci
Files:
3 edited

Legend:

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

    r17c5e62 r0eadfd1e  
    9393        xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base);
    9494
    95         if ((err = xhci_endpoint_alloc_transfer_ds(ep0)))
    96                 goto err_added;
    97 
    9895        /* Address device */
    9996        if ((err = hc_address_device(bus->hc, dev, ep0)))
    100                 goto err_prepared;
    101 
    102         return EOK;
    103 
    104 err_prepared:
    105         xhci_endpoint_free_transfer_ds(ep0);
     97                goto err_added;
     98
     99        return EOK;
     100
    106101err_added:
    107102        /* Bus reference */
     
    354349                        continue;
    355350
    356                 xhci_endpoint_free_transfer_ds(xhci_endpoint_get(endpoints[i]));
    357351                /* Bus reference */
    358352                endpoint_del_ref(endpoints[i]);
     
    411405        xhci_device_t *dev = xhci_device_get(ep_base->device);
    412406
    413         if ((err = xhci_endpoint_alloc_transfer_ds(ep)))
    414                 return err;
    415 
    416407        usb_log_info("Endpoint " XHCI_EP_FMT " registered to XHCI bus.", XHCI_EP_ARGS(*ep));
    417408
     
    420411
    421412        if ((err = hc_add_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep), &ep_ctx)))
    422                 goto err_prepared;
    423 
    424         return EOK;
    425 
    426 err_prepared:
    427         xhci_endpoint_free_transfer_ds(ep);
    428         return err;
     413                return err;
     414
     415        return EOK;
    429416}
    430417
     
    454441        }
    455442
    456         /* Tear down TRB ring / PSA. */
    457         xhci_endpoint_free_transfer_ds(ep);
    458 
    459443        return EOK;
    460444}
  • uspace/drv/bus/usb/xhci/endpoint.c

    r17c5e62 r0eadfd1e  
    4545#include "endpoint.h"
    4646
     47static int alloc_transfer_ds(xhci_endpoint_t *);
     48static void free_transfer_ds(xhci_endpoint_t *);
     49
    4750/**
    4851 * Initialize new XHCI endpoint.
     
    5558int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, device_t *dev, const usb_endpoint_descriptors_t *desc)
    5659{
     60        int rc;
    5761        assert(xhci_ep);
    5862
     
    103107        }
    104108
     109        if ((rc = alloc_transfer_ds(xhci_ep)))
     110                goto err;
     111
    105112        return EOK;
     113
     114err:
     115        return rc;
    106116}
    107117
     
    113123{
    114124        assert(xhci_ep);
     125
     126        free_transfer_ds(xhci_ep);
    115127
    116128        // TODO: Something missed?
     
    291303 * @return Error code.
    292304 */
    293 int xhci_endpoint_alloc_transfer_ds(xhci_endpoint_t *xhci_ep)
     305static int alloc_transfer_ds(xhci_endpoint_t *xhci_ep)
    294306{
    295307        /* Can't use XHCI_EP_FMT because the endpoint may not have device. */
     
    316328 * @param[in] xhci_ep XHCI endpoint to free data structures for.
    317329 */
    318 void xhci_endpoint_free_transfer_ds(xhci_endpoint_t *xhci_ep)
     330static void free_transfer_ds(xhci_endpoint_t *xhci_ep)
    319331{
    320332        if (endpoint_using_streams(xhci_ep)) {
  • uspace/drv/bus/usb/xhci/endpoint.h

    r17c5e62 r0eadfd1e  
    150150int xhci_endpoint_init(xhci_endpoint_t *, device_t *, const usb_endpoint_descriptors_t *);
    151151void xhci_endpoint_fini(xhci_endpoint_t *);
    152 int xhci_endpoint_alloc_transfer_ds(xhci_endpoint_t *);
    153 void xhci_endpoint_free_transfer_ds(xhci_endpoint_t *);
    154152
    155153int xhci_endpoint_request_streams(xhci_hc_t *, xhci_device_t *, xhci_endpoint_t *, unsigned);
Note: See TracChangeset for help on using the changeset viewer.