Changeset c21e6a5 in mainline for uspace/drv/bus/usb/ohci/ohci_batch.c


Ignore:
Timestamp:
2018-02-05T00:54:08Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af16ebe
Parents:
65c059f
git-author:
Ondřej Hlavatý <aearsis@…> (2018-02-05 00:27:40)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-02-05 00:54:08)
Message:

usbhost: prepare buffers for transfers in library

File:
1 edited

Legend:

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

    r65c059f rc21e6a5  
    113113                : 0;
    114114
    115         if (dma_buffer_alloc(&ohci_batch->ohci_dma_buffer, td_size + setup_size + usb_batch->buffer_size)) {
     115        if (dma_buffer_alloc(&ohci_batch->ohci_dma_buffer, td_size + setup_size)) {
    116116                usb_log_error("Failed to allocate OHCI DMA buffer.");
    117117                return ENOMEM;
     
    129129        memcpy(ohci_batch->setup_buffer, usb_batch->setup.buffer, setup_size);
    130130
    131         ohci_batch->data_buffer = ohci_batch->setup_buffer + setup_size;
    132         if (usb_batch->dir == USB_DIRECTION_OUT)
    133                 memcpy(ohci_batch->data_buffer, usb_batch->buffer, usb_batch->buffer_size);
     131        ohci_batch->data_buffer = usb_batch->dma_buffer.virt;
    134132
    135133        batch_setup[usb_batch->ep->transfer_type](ohci_batch);
     
    151149        assert(ohci_batch);
    152150
    153         ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ohci_batch->base.ep);
     151        usb_transfer_batch_t *usb_batch = &ohci_batch->base;
     152        ohci_endpoint_t *ohci_ep = ohci_endpoint_get(usb_batch->ep);
    154153        assert(ohci_ep);
    155154
    156155        usb_log_debug("Batch %p checking %zu td(s) for completion.",
    157             &ohci_batch->base, ohci_batch->td_count);
     156            ohci_batch, ohci_batch->td_count);
    158157        usb_log_debug2("ED: %08x:%08x:%08x:%08x.",
    159158            ohci_ep->ed->status, ohci_ep->ed->td_head,
     
    167166
    168167        /* Assume all data got through */
    169         ohci_batch->base.transferred_size = ohci_batch->base.buffer_size;
     168        usb_batch->transferred_size = usb_batch->buffer_size;
    170169
    171170        /* Check all TDs */
     
    176175                    ohci_batch->tds[i]->next, ohci_batch->tds[i]->be);
    177176
    178                 ohci_batch->base.error = td_error(ohci_batch->tds[i]);
    179                 if (ohci_batch->base.error == EOK) {
     177                usb_batch->error = td_error(ohci_batch->tds[i]);
     178                if (usb_batch->error == EOK) {
    180179                        /* If the TD got all its data through, it will report
    181180                         * 0 bytes remain, the sole exception is INPUT with
     
    190189                         * we leave the very last(unused) TD behind.
    191190                         */
    192                         ohci_batch->base.transferred_size
     191                        usb_batch->transferred_size
    193192                            -= td_remain_size(ohci_batch->tds[i]);
    194193                } else {
    195194                        usb_log_debug("Batch %p found error TD(%zu):%08x.",
    196                             &ohci_batch->base, i, ohci_batch->tds[i]->status);
     195                            ohci_batch, i, ohci_batch->tds[i]->status);
    197196
    198197                        /* ED should be stopped because of errors */
     
    213212                }
    214213        }
    215         assert(ohci_batch->base.transferred_size <=
    216             ohci_batch->base.buffer_size);
    217 
    218         if (ohci_batch->base.dir == USB_DIRECTION_IN)
    219                 memcpy(ohci_batch->base.buffer,
    220                     ohci_batch->data_buffer,
    221                     ohci_batch->base.transferred_size);
     214        assert(usb_batch->transferred_size <= usb_batch->buffer_size);
    222215
    223216        /* Make sure that we are leaving the right TD behind */
Note: See TracChangeset for help on using the changeset viewer.