Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f18d82f0 in mainline


Ignore:
Timestamp:
2011-08-31T21:45:59Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
9c10e51
Parents:
70fb822
Message:

libusbhost: change finish functions to do the data copying if necessary

uhci: use new finish functions instead of manual copy

Location:
uspace
Files:
3 edited

Legend:

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

    r70fb822 rf18d82f0  
    6666        assert(uhci_batch);
    6767        assert(uhci_batch->usb_batch);
    68         /* Copy data unless we are sure we sent it */
    69         if (uhci_batch->usb_batch->ep->direction != USB_DIRECTION_OUT) {
    70                 memcpy(uhci_batch->usb_batch->buffer,
    71                     uhci_transfer_batch_data_buffer(uhci_batch),
    72                     uhci_batch->usb_batch->buffer_size);
    73         }
    74         if (uhci_batch->usb_batch->callback_out)
    75                 usb_transfer_batch_call_out(uhci_batch->usb_batch);
    76         if (uhci_batch->usb_batch->callback_in)
    77                 usb_transfer_batch_call_in(uhci_batch->usb_batch);
     68        usb_transfer_batch_finish(uhci_batch->usb_batch,
     69            uhci_transfer_batch_data_buffer(uhci_batch),
     70            uhci_batch->usb_batch->buffer_size);
    7871        uhci_transfer_batch_dispose(uhci_batch);
    7972}
  • uspace/lib/usbhost/include/usb/host/batch.h

    r70fb822 rf18d82f0  
    9090);
    9191
    92 void usb_transfer_batch_finish(usb_transfer_batch_t *instance);
     92void usb_transfer_batch_finish(usb_transfer_batch_t *instance,
     93    const void* data, size_t size);
    9394void usb_transfer_batch_call_in(usb_transfer_batch_t *instance);
    9495void usb_transfer_batch_call_out(usb_transfer_batch_t *instance);
     
    120121/*----------------------------------------------------------------------------*/
    121122static inline void usb_transfer_batch_finish_error(
    122     usb_transfer_batch_t *instance, int error)
     123    usb_transfer_batch_t *instance, const void* data, size_t size, int error)
    123124{
    124125        assert(instance);
    125126        instance->error = error;
    126         usb_transfer_batch_finish(instance);
     127        usb_transfer_batch_finish(instance, data, size);
    127128}
    128129/*----------------------------------------------------------------------------*/
  • uspace/lib/usbhost/src/batch.c

    r70fb822 rf18d82f0  
    8484 *
    8585 */
    86 void usb_transfer_batch_finish(usb_transfer_batch_t *instance)
     86void usb_transfer_batch_finish(
     87    usb_transfer_batch_t *instance, const void *data, size_t size)
    8788{
    8889        assert(instance);
    89         if (instance->next_step)
    90                 instance->next_step(instance);
     90        assert(instance->ep);
     91        /* we care about the data and there are some to copy */
     92        if (instance->ep->direction != USB_DIRECTION_OUT
     93            && data) {
     94                const size_t min_size =
     95                    size < instance->buffer_size ? size : instance->buffer_size;
     96                memcpy(instance->buffer, data, min_size);
     97        }
     98        if (instance->callback_out)
     99                usb_transfer_batch_call_out(instance);
     100        if (instance->callback_in)
     101                usb_transfer_batch_call_in(instance);
     102
    91103}
    92104/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.