Ignore:
Timestamp:
2017-10-31T19:06:57Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
479e32d
Parents:
a312d8f
Message:

usbhost endpoint: endpoint→active replaced by tracking active batch

The mechanism is optional, synchronization over endpoint is now not forced. It will be used by xhci to utilize streams.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    ra312d8f r17873ac7  
    6363void usb_transfer_batch_init(usb_transfer_batch_t *batch, endpoint_t *ep)
    6464{
    65         endpoint_use(ep);
    66 
    6765        memset(batch, 0, sizeof(*batch));
    6866        batch->ep = ep;
    6967}
    7068
    71 /** Call the handler of the batch.
     69/** Resolve resetting toggle.
    7270 *
    7371 * @param[in] batch Batch structure to use.
    7472 */
    75 static int batch_complete(usb_transfer_batch_t *batch)
     73int usb_transfer_batch_reset_toggle(usb_transfer_batch_t *batch)
    7674{
    7775        assert(batch);
    7876
    79         usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " completed.\n",
    80             batch, USB_TRANSFER_BATCH_ARGS(*batch));
     77        if (batch->error != EOK || batch->toggle_reset_mode == RESET_NONE)
     78                return EOK;
    8179
    82         if (batch->error == EOK && batch->toggle_reset_mode != RESET_NONE) {
    83                 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " resets %s",
    84                     batch, USB_TRANSFER_BATCH_ARGS(*batch),
    85                     batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle");
    86                 bus_reset_toggle(batch->ep->bus,
    87                     batch->target, batch->toggle_reset_mode == RESET_ALL);
    88         }
     80        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " resets %s",
     81            batch, USB_TRANSFER_BATCH_ARGS(*batch),
     82            batch->toggle_reset_mode == RESET_ALL ? "all EPs toggle" : "EP toggle");
    8983
    90         return batch->on_complete
    91                 ? batch->on_complete(batch)
    92                 : EOK;
     84        return bus_reset_toggle(batch->ep->bus, batch->target, batch->toggle_reset_mode);
    9385}
    9486
     
    114106                free(batch);
    115107        }
    116 
    117         endpoint_release(batch->ep);
    118108}
    119109
     
    126116void usb_transfer_batch_finish(usb_transfer_batch_t *batch)
    127117{
    128         const int err = batch_complete(batch);
    129         if (err)
    130                 usb_log_warning("batch %p failed to complete: %s", batch, str_error(err));
     118        assert(batch);
     119        assert(batch->ep);
     120
     121        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " finishing.\n",
     122            batch, USB_TRANSFER_BATCH_ARGS(*batch));
     123
     124        if (batch->on_complete) {
     125                const int err = batch->on_complete(batch);
     126                if (err)
     127                        usb_log_warning("batch %p failed to complete: %s",
     128                            batch, str_error(err));
     129        }
    131130
    132131        usb_transfer_batch_destroy(batch);
     132}
     133
     134/** Finish a transfer batch as an aborted one.
     135 *
     136 * @param[in] batch Batch structure to use.
     137 */
     138void usb_transfer_batch_abort(usb_transfer_batch_t *batch)
     139{
     140        assert(batch);
     141        assert(batch->ep);
     142
     143        batch->error = EAGAIN;
     144        usb_transfer_batch_finish(batch);
    133145}
    134146
Note: See TracChangeset for help on using the changeset viewer.