Changeset 56257ba in mainline for uspace/drv/bus/usb/xhci/endpoint.c


Ignore:
Timestamp:
2018-01-07T01:01:42Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63431db
Parents:
9efad54
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-07 01:01:41)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-07 01:01:42)
Message:

usbhost: manage endpoints by library + get/set_toggle → reset_toggle

That simplifies things A LOT. Now you can find endpoints for device in
an array inside device. This array is managed automatically in
register/unregister endpoint. HC drivers still needs to write to it when
setting up/tearing down the device.

Sorry for these two changes being in one commit, but splitting them
would be simply more work for no benefit.

File:
1 edited

Legend:

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

    r9efad54 r56257ba  
    469469}
    470470
    471 /** Add a new XHCI endpoint to a device. The device must be online unless
    472  * the added endpoint is number 0.
    473  * @param[in] dev XHCI device, to which to add the endpoint
    474  * @param[in] ep XHCI endpoint to add.
    475  *
    476  * @return Error code.
    477  */
    478 int xhci_device_add_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
    479 {
    480         assert(dev);
    481         assert(ep);
    482 
    483         /* Offline devices don't create new endpoints other than EP0. */
    484         if (!dev->base.online && ep->base.endpoint > 0) {
    485                 return EAGAIN;
    486         }
    487 
    488         const usb_endpoint_t ep_num = ep->base.endpoint;
    489 
    490         if (dev->endpoints[ep_num])
    491                 return EEXIST;
    492 
    493         /* Device reference */
    494         endpoint_add_ref(&ep->base);
    495         ep->base.device = &dev->base;
    496         dev->endpoints[ep_num] = ep;
    497 
    498         return EOK;
    499 }
    500 
    501 /** Remove XHCI endpoint from a device.
    502  * @param[in] ep XHCI endpoint to remove.
    503  */
    504 void xhci_device_remove_endpoint(xhci_endpoint_t *ep)
    505 {
    506         assert(ep);
    507         xhci_device_t *dev = xhci_device_get(ep->base.device);
    508 
    509         assert(dev->endpoints[ep->base.endpoint]);
    510         dev->endpoints[ep->base.endpoint] = NULL;
    511         ep->base.device = NULL;
    512 }
    513 
    514471/** Retrieve XHCI endpoint from a device by the endpoint number.
    515472 * @param[in] dev XHCI device to query.
     
    520477xhci_endpoint_t *xhci_device_get_endpoint(xhci_device_t *dev, usb_endpoint_t ep)
    521478{
    522         return dev->endpoints[ep];
     479        return xhci_endpoint_get(dev->base.endpoints[ep]);
    523480}
    524481
Note: See TracChangeset for help on using the changeset viewer.