Ignore:
File:
1 edited

Legend:

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

    r549ff23 rcbd568b  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
     35#include <macros.h>
    3636
    3737#include <usb/usb.h>
     
    4848 * @param func_in callback on IN transfer completion.
    4949 * @param func_out callback on OUT transfer completion.
     50 * @param fun DDF function (passed to callback function).
    5051 * @param arg Argument to pass to the callback function.
    5152 * @param private_data driver specific per batch data.
     
    121122 * @param[in] data Data to copy to the output buffer.
    122123 * @param[in] size Size of @p data.
     124 * @param[in] error Error value to use.
    123125 */
    124 void usb_transfer_batch_finish(
    125     const usb_transfer_batch_t *instance, const void *data, size_t size)
     126void usb_transfer_batch_finish_error(const usb_transfer_batch_t *instance,
     127    const void *data, size_t size, int error)
    126128{
    127129        assert(instance);
     
    133135                /* Check for commands that reset toggle bit */
    134136                if (instance->ep->transfer_type == USB_TRANSFER_CONTROL
    135                     && instance->error == EOK) {
     137                    && error == EOK) {
    136138                        const usb_target_t target =
    137139                            {{ instance->ep->address, instance->ep->endpoint }};
     
    139141                            instance->setup_buffer);
    140142                }
    141                 instance->callback_out(instance->fun,
    142                     instance->error, instance->arg);
     143                instance->callback_out(instance->fun, error, instance->arg);
    143144        }
    144145
    145146        if (instance->callback_in) {
    146147                /* We care about the data and there are some to copy */
     148                const size_t safe_size = min(size, instance->buffer_size);
    147149                if (data) {
    148                         const size_t min_size = size < instance->buffer_size
    149                             ? size : instance->buffer_size;
    150                         memcpy(instance->buffer, data, min_size);
     150                        memcpy(instance->buffer, data, safe_size);
    151151                }
    152                 instance->callback_in(instance->fun, instance->error,
    153                     instance->transfered_size, instance->arg);
     152                instance->callback_in(instance->fun, error,
     153                    safe_size, instance->arg);
    154154        }
    155155}
Note: See TracChangeset for help on using the changeset viewer.