Changeset 929599a8 in mainline for uspace/drv/bus/usb/uhci/hc.c


Ignore:
Timestamp:
2018-01-11T13:30:37Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ed803f1
Parents:
351113f
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-11 13:30:31)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-11 13:30:37)
Message:

uhci: implemented transfer abort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/hc.c

    r351113f r929599a8  
    5353
    5454#include "uhci_batch.h"
     55#include "transfer_list.h"
    5556#include "hc.h"
    5657
     
    323324static void endpoint_unregister(endpoint_t *ep)
    324325{
     326        hc_t * const hc = bus_to_hc(endpoint_get_bus(ep));
    325327        usb2_bus_ops.endpoint_unregister(ep);
     328
     329        uhci_transfer_batch_t *batch = NULL;
    326330
    327331        fibril_mutex_lock(&ep->guard);
    328332        if (ep->active_batch) {
    329                 uhci_transfer_batch_t *ub = uhci_transfer_batch_get(ep->active_batch);
    330                 uhci_transfer_batch_abort(ub);
    331 
    332                 assert(ep->active_batch == NULL);
     333                batch = uhci_transfer_batch_get(ep->active_batch);
     334
     335                transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
     336                assert(list);
     337
     338                fibril_mutex_lock(&list->guard);
     339                transfer_list_remove_batch(list, batch);
     340                fibril_mutex_unlock(&list->guard);
     341
     342                endpoint_wait_timeout_locked(ep, 2000);
     343
     344                batch = uhci_transfer_batch_get(ep->active_batch);
     345                if (ep->active_batch) {
     346                        endpoint_deactivate_locked(ep);
     347                }
    333348        }
    334349        fibril_mutex_unlock(&ep->guard);
     350
     351        if (batch) {
     352                batch->base.error = EINTR;
     353                batch->base.transfered_size = 0;
     354                usb_transfer_batch_finish(&batch->base);
     355        }
    335356}
    336357
     
    486507static int hc_schedule(usb_transfer_batch_t *batch)
    487508{
    488         assert(batch);
    489         hc_t *instance = bus_to_hc(endpoint_get_bus(batch->ep));
    490 
    491         if (batch->target.address == uhci_rh_get_address(&instance->rh))
    492                 return uhci_rh_schedule(&instance->rh, batch);
    493 
    494         uhci_transfer_batch_t *uhci_batch = (uhci_transfer_batch_t *) batch;
    495         if (!uhci_batch) {
    496                 usb_log_error("Failed to create UHCI transfer structures.\n");
    497                 return ENOMEM;
    498         }
     509        uhci_transfer_batch_t *uhci_batch = uhci_transfer_batch_get(batch);
     510        endpoint_t *ep = batch->ep;
     511        hc_t *hc = bus_to_hc(endpoint_get_bus(ep));
     512
     513        if (batch->target.address == uhci_rh_get_address(&hc->rh))
     514                return uhci_rh_schedule(&hc->rh, batch);
     515
    499516
    500517        const int err = uhci_transfer_batch_prepare(uhci_batch);
     
    502519                return err;
    503520
    504         transfer_list_t *list =
    505             instance->transfers[batch->ep->device->speed][batch->ep->transfer_type];
     521        transfer_list_t *list = hc->transfers[ep->device->speed][ep->transfer_type];
    506522        assert(list);
    507523        transfer_list_add_batch(list, uhci_batch);
     524
     525        return EOK;
     526}
     527
     528int hc_unschedule_batch(usb_transfer_batch_t *batch)
     529{
    508530
    509531        return EOK;
Note: See TracChangeset for help on using the changeset viewer.