Ignore:
File:
1 edited

Legend:

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

    r549ff23 r2582d8f  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
     35#include <macros.h>
    3636
    3737#include <usb/usb.h>
     
    121121 * @param[in] data Data to copy to the output buffer.
    122122 * @param[in] size Size of @p data.
     123 * @param[in] error Error value to use.
    123124 */
    124 void usb_transfer_batch_finish(
    125     const usb_transfer_batch_t *instance, const void *data, size_t size)
     125void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     126    const void *data, size_t size, int error)
    126127{
    127128        assert(instance);
     
    133134                /* Check for commands that reset toggle bit */
    134135                if (instance->ep->transfer_type == USB_TRANSFER_CONTROL
    135                     && instance->error == EOK) {
     136                    && error == EOK) {
    136137                        const usb_target_t target =
    137138                            {{ instance->ep->address, instance->ep->endpoint }};
     
    139140                            instance->setup_buffer);
    140141                }
    141                 instance->callback_out(instance->fun,
    142                     instance->error, instance->arg);
     142                instance->callback_out(instance->fun, error, instance->arg);
    143143        }
    144144
    145145        if (instance->callback_in) {
    146146                /* We care about the data and there are some to copy */
     147                const size_t safe_size = min(size, instance->buffer_size);
    147148                if (data) {
    148                         const size_t min_size = size < instance->buffer_size
    149                             ? size : instance->buffer_size;
    150                         memcpy(instance->buffer, data, min_size);
     149                        memcpy(instance->buffer, data, safe_size);
    151150                }
    152                 instance->callback_in(instance->fun, instance->error,
    153                     instance->transfered_size, instance->arg);
     151                instance->callback_in(instance->fun, error,
     152                    safe_size, instance->arg);
    154153        }
    155154}
Note: See TracChangeset for help on using the changeset viewer.