Changeset 30fc56f in mainline for uspace/drv/bus/usb/xhci/bus.c


Ignore:
Timestamp:
2018-01-11T09:38:40Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
92caadd
Parents:
53a9d02
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-11 09:38:32)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-11 09:38:40)
Message:

xhci: stop endpoint on unregister

File:
1 edited

Legend:

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

    r53a9d02 r30fc56f  
    323323
    324324/**
     325 * Abort a transfer on an endpoint.
     326 */
     327static int endpoint_abort(endpoint_t *ep)
     328{
     329        xhci_bus_t *bus = bus_to_xhci_bus(endpoint_get_bus(ep));
     330        xhci_device_t *dev = xhci_device_get(ep->device);
     331
     332        usb_transfer_batch_t *batch = NULL;
     333        fibril_mutex_lock(&ep->guard);
     334        if (ep->active_batch) {
     335                if (dev->slot_id) {
     336                        const int err = hc_stop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_dci(xhci_endpoint_get(ep)));
     337                        if (err) {
     338                                usb_log_warning("Failed to stop endpoint %u of device " XHCI_DEV_FMT ": %s",
     339                                    ep->endpoint, XHCI_DEV_ARGS(*dev), str_error(err));
     340                        }
     341
     342                        endpoint_wait_timeout_locked(ep, 2000);
     343                }
     344
     345                batch = ep->active_batch;
     346                if (batch) {
     347                        endpoint_deactivate_locked(ep);
     348                }
     349        }
     350        fibril_mutex_unlock(&ep->guard);
     351
     352        if (batch) {
     353                batch->error = EINTR;
     354                batch->transfered_size = 0;
     355                usb_transfer_batch_finish(batch);
     356        }
     357        return EOK;
     358}
     359
     360/**
    325361 * Unregister an endpoint. If the device is still available, inform the xHC
    326362 * about it.
     
    335371        xhci_device_t *dev = xhci_device_get(ep_base->device);
    336372
     373        endpoint_abort(ep_base);
     374
    337375        /* If device slot is still available, drop the endpoint. */
    338376        if (dev->slot_id) {
     377
    339378                if ((err = hc_drop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep)))) {
    340379                        usb_log_error("Failed to drop endpoint " XHCI_EP_FMT ": %s", XHCI_EP_ARGS(*ep), str_error(err));
Note: See TracChangeset for help on using the changeset viewer.