Changeset d60115a in mainline for uspace/drv/bus/usb/ohci/ohci_bus.c


Ignore:
Timestamp:
2018-01-17T17:55:35Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ad2b0a
Parents:
ed8575f
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-17 17:54:31)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-17 17:55:35)
Message:

ohci: implement transfer abort on endpoint unregister

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_bus.c

    red8575f rd60115a  
    8282        }
    8383
    84         link_initialize(&ohci_ep->link);
     84        link_initialize(&ohci_ep->eplist_link);
     85        link_initialize(&ohci_ep->pending_link);
    8586        return &ohci_ep->base;
    8687}
     
    120121static void ohci_unregister_ep(endpoint_t *ep)
    121122{
    122         ohci_bus_t *bus = (ohci_bus_t *) endpoint_get_bus(ep);
     123        ohci_bus_t * const bus = (ohci_bus_t *) endpoint_get_bus(ep);
     124        hc_t * const hc = bus->hc;
    123125        assert(ep);
    124126
    125127        usb2_bus_ops.endpoint_unregister(ep);
    126128        hc_dequeue_endpoint(bus->hc, ep);
     129
     130        ohci_endpoint_t * const ohci_ep = ohci_endpoint_get(ep);
     131
     132        /*
     133         * Now we can be sure the active transfer will not be completed. But first,
     134         * make sure that the handling fibril won't use its link in pending list.
     135         */
     136        fibril_mutex_lock(&hc->guard);
     137        if (link_in_use(&ohci_ep->pending_link))
     138                /* pending list reference */
     139                endpoint_del_ref(ep);
     140        list_remove(&ohci_ep->pending_link);
     141        fibril_mutex_unlock(&hc->guard);
     142
     143        /*
     144         * Finally, the endpoint shall not be used anywhere else. Finish the
     145         * pending batch.
     146         */
     147        fibril_mutex_lock(&ep->guard);
     148        usb_transfer_batch_t * const batch = ep->active_batch;
     149        endpoint_deactivate_locked(ep);
     150        fibril_mutex_unlock(&ep->guard);
     151
     152        if (batch) {
     153                batch->error = EINTR;
     154                batch->transfered_size = 0;
     155                usb_transfer_batch_finish(batch);
     156        }
    127157}
    128158
Note: See TracChangeset for help on using the changeset viewer.